Example #1
0
HASH_ARRAY_STRING(basilisk,sendmessage,hash,vals,hexstr)
{
    int32_t keylen,datalen; uint8_t key[64],space[16384],*data,*ptr = 0; char *retstr=0;
    if ( myinfo->RELAYID >= 0 )
    {
        keylen = basilisk_messagekey(key,hash,vals);
        if ( (data= get_dataptr(BASILISK_HDROFFSET,&ptr,&datalen,space,sizeof(space),hexstr)) != 0 )
            retstr = basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1);
        if ( ptr != 0 )
            free(ptr);
        if ( retstr != 0 )
            free(retstr);
    }
    if ( vals != 0 )
        jaddnum(vals,"fanout",BASILISK_MAXFANOUT);
    return(basilisk_standardservice("OUT",myinfo,0,hash,vals,hexstr,1));
}
Example #2
0
int32_t gecko_blocksubmit(struct supernet_info *myinfo,struct iguana_info *btcd,struct iguana_info *virt,char *blockstr,bits256 hash2,int32_t height)
{
    uint8_t *data,space[16384],*allocptr=0; int32_t i,len,numranked=0; struct iguana_peers *peers; struct iguana_peer *addr;
    //printf("submit.(%s)\n",blockstr);
    if ( (peers= virt->peers) == 0 || (numranked= peers->numranked) <= 0 )
    {
        if ( basilisk_blocksubmit(myinfo,btcd,virt,0,blockstr,hash2,height) < 0 )//(NUMRELAYS >> 1) )
            return(-1);
    }
    else // physical node for geckochain
    {
        if ( (data= get_dataptr(sizeof(struct iguana_msghdr),&allocptr,&len,space,sizeof(space),blockstr)) != 0 )
        {
            for (i=0; i<numranked; i++)
            {
                if ( (addr= peers->ranked[i]) != 0 && addr->usock >= 0 && addr->supernet != 0 )
                    iguana_queue_send(addr,0,data,"block",len);
            }
        }
        if ( allocptr != 0 )
            free(allocptr);
    }
    return(0);
}