Ejemplo n.º 1
0
void SuperNET_hexmsgadd(struct supernet_info *myinfo,bits256 categoryhash,bits256 subhash,char *hexmsg,struct tai now,char *remoteaddr)
{
    char str[512],str2[65];
    str[0] = 0;
    if ( memcmp(categoryhash.bytes,GENESIS_PUBKEY.bytes,sizeof(categoryhash)) == 0 )
        strcpy(str,"BROADCAST.");
    else bits256_str(str+strlen(str),categoryhash);
    if ( memcmp(subhash.bytes,GENESIS_PUBKEY.bytes,sizeof(subhash)) != 0 )
    {
        bits256_str(str2,subhash);
        strcat(str,str2);
    }
    category_posthexmsg(myinfo,categoryhash,subhash,hexmsg,now,remoteaddr);
    //printf("HEXMSG.(%s).%llx -> %s\n",hexmsg,(long long)subhash.txid,str);
}
Ejemplo n.º 2
0
void SuperNET_hexmsgprocess(struct supernet_info *myinfo,cJSON *retjson,cJSON *json,char *hexmsg,char *remoteaddr)
{
    int32_t len,flag=0; char *str; uint8_t _buf[8192],*buf = _buf; bits256 categoryhash,subhash; struct private_chain *cat;
    if ( hexmsg != 0 )
    {
        len = (int32_t)strlen(hexmsg);
        if ( is_hexstr(hexmsg,len) > 0 )
        {
            len >>= 1;
            if ( len > sizeof(_buf) )
                buf = malloc(len);
            decode_hex(buf,len,hexmsg);
            //printf("hex.(%s) -> (%s)\n",hexmsg,buf);
            categoryhash = jbits256(json,"categoryhash");
            subhash = jbits256(json,"categoryhash");
            if ( bits256_nonz(subhash) == 0 )
                subhash = GENESIS_PUBKEY;
            if ( (cat= category_find(categoryhash,subhash)) != 0 )
            {
                if ( cat->processfunc != 0 )
                {
                    if ( (str= (*cat->processfunc)(myinfo,cat,buf,len,remoteaddr)) != 0 )
                    {
                        if ( retjson != 0 )
                            jaddstr(retjson,"processfunc",str);
                        else free(str);
                    }
                    flag = 1;
                    //printf("PROCESSFUNC\n");
                }
            }
            if ( flag == 0 )
            {
                printf("no processfunc, posthexmsg\n");
                category_posthexmsg(myinfo,categoryhash,jbits256(json,"subhash"),hexmsg,tai_now(),remoteaddr);
            }
            //char str[65]; printf("HEXPROCESS.(%s) -> %s\n",hexmsg,bits256_str(str,categoryhash));
            if ( buf != _buf )
                free(buf);
        }