bool CTestClient::init(const char* username, const char* password)
{
    do
    {
        BREAK_IF(nullptr == username);
        BREAK_IF(nullptr == password);
        m_username = username;
        m_password = password;
        
        int index = POMELO_NEW;
        m_pomelo = POMELO(index);
        BREAK_IF(nullptr == m_pomelo);
        
        std::string ip = "127.0.0.1";
        int port = 3017;
        
        m_pomelo->asyncConnect(ip.c_str(), port, [&](Node* node, void* resp)
                               {
                                   CCPomeloReponse* pr = (CCPomeloReponse*)resp;
                                   if (pr->status != 0)
                                   {
                                       MT->print("not connected!");
                                       return;
                                   }
                                   CCLOG("connect ok");
                                   const char *route = "gate.gateHandler.queryConnectorEntry";
                                   CJsonT msg;
                                   msg.setChild("userName", m_username.c_str());
                                   msg.setChild("password", m_password.c_str());
                                   
                                   m_pomelo->request(route, msg, [&](Node* node, void* resp){
                                       CCPomeloReponse* ccpomeloresp = (CCPomeloReponse*)resp;
                                       
                                       CJsonT docs(ccpomeloresp->docs);
                                       
                                       CCLOG("entryCB %s", docs.dump().c_str());
                                       
                                       if (200 != docs.getInt("code"))
                                       {
                                           return;
                                       }
                                       
                                       connectToConnector(docs.getString("host"), docs.getInt("port"));
                                   });
                                   
                                   msg.release();
                               });
        
        return true;
    } while (false);
    
    return false;
}
Example #2
0
void hive_hash(const char* input, char* output)
{
    sph_blake256_context     ctx_blake;
    sph_shabal256_context       ctx_shabal;
    sph_keccak256_context    ctx_keccak;


//    uint32_t hashA[16], hashB[16];
    uint32_t  hashA[8], hashB[8];



    sph_shabal256_init(&ctx_shabal);
    sph_shabal256 (&ctx_shabal, input, 80);
    sph_shabal256_close (&ctx_shabal, hashA);	 //0


    POMELO(hashB, 32, hashA, 32, hashA, 32, 2, 10);


    sph_blake256_init(&ctx_blake);
    sph_blake256 (&ctx_blake, hashA, 32);    //0
    sph_blake256_close(&ctx_blake, hashB);   //1


    sph_keccak256_init(&ctx_keccak);
    sph_keccak256 (&ctx_keccak, hashB, 32); //2
    sph_keccak256_close(&ctx_keccak, hashA); //3



	memcpy(output, hashA, 32);





}