jl777 8 years ago
parent
commit
79051fa811
  1. 40
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_DEX.c
  3. 4
      basilisk/basilisk_MSG.c

40
basilisk/basilisk.c

@ -258,7 +258,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ
} }
if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) ) if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) )
{ {
fprintf(stderr,"(%s).%u ",addr->ipaddr,coin->chain->portp2p); //fprintf(stderr,"(%s).%u ",addr->ipaddr,coin->chain->portp2p);
//printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast"); //printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s.(%s) [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,(char *)&data[4],*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast");
if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 ) if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 )
{ {
@ -802,20 +802,19 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t
void basilisk_requests_poll(struct supernet_info *myinfo) void basilisk_requests_poll(struct supernet_info *myinfo)
{ {
char *retstr; cJSON *outerarray; int32_t i,n; struct basilisk_request issueR; double hwm = 0.; char *retstr; cJSON *outerarray,*retjson; int32_t i,n; struct basilisk_request issueR; double hwm = 0.;
memset(&issueR,0,sizeof(issueR)); memset(&issueR,0,sizeof(issueR));
if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 ) if ( (retstr= InstantDEX_incoming(myinfo,0,0,0,0)) != 0 )
{ {
//printf("poll.(%s)\n",retstr); //printf("poll.(%s)\n",retstr);
if ( (outerarray= cJSON_Parse(retstr)) != 0 ) if ( (retjson= cJSON_Parse(retstr)) != 0 )
{ {
if ( is_cJSON_Array(outerarray) != 0 ) if ( (outerarray= jarray(&n,retjson,"responses")) != 0 )
{ {
n = cJSON_GetArraySize(outerarray);
for (i=0; i<n; i++) for (i=0; i<n; i++)
hwm = basilisk_process_results(myinfo,&issueR,jitem(outerarray,i),hwm); hwm = basilisk_process_results(myinfo,&issueR,jitem(outerarray,i),hwm);
} else hwm = basilisk_process_results(myinfo,&issueR,outerarray,hwm); } //else hwm = basilisk_process_results(myinfo,&issueR,outerarray,hwm);
free_json(outerarray); free_json(retjson);
} }
free(retstr); free(retstr);
} else printf("null incoming\n"); } else printf("null incoming\n");
@ -857,26 +856,30 @@ void basilisks_loop(void *arg)
free(pending); free(pending);
} }
} }
notary = iguana_coinfind("NOTARY");
portable_mutex_unlock(&myinfo->basilisk_mutex); portable_mutex_unlock(&myinfo->basilisk_mutex);
if ( (notary= iguana_coinfind("NOTARY")) != 0 && myinfo->NOTARY.RELAYID >= 0 ) if ( myinfo->NOTARY.RELAYID >= 0 )
{ {
maxmillis = (1000 / (myinfo->allcoins_numvirts + 1)) + 1; if ( notary != 0 )
//portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ITER(hh,myinfo->allcoins,virt,tmpcoin)
{ {
if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 ) maxmillis = (1000 / (myinfo->allcoins_numvirts + 1)) + 1;
//portable_mutex_lock(&myinfo->allcoins_mutex);
HASH_ITER(hh,myinfo->allcoins,virt,tmpcoin)
{ {
gecko_iteration(myinfo,notary,virt,maxmillis), flag++; if ( virt->started != 0 && virt->active != 0 && virt->virtualchain != 0 )
{
gecko_iteration(myinfo,notary,virt,maxmillis), flag++;
}
} }
//portable_mutex_unlock(&myinfo->allcoins_mutex);
basilisk_ping_send(myinfo,notary);
} }
//portable_mutex_unlock(&myinfo->allcoins_mutex);
basilisk_ping_send(myinfo,notary);
} // else printf("not notary %p %d\n",notary,myinfo->NOTARY.RELAYID); } // else printf("not notary %p %d\n",notary,myinfo->NOTARY.RELAYID);
if ( myinfo->expiration != 0 ) else if ( myinfo->expiration != 0 )
{ {
HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin) HASH_ITER(hh,myinfo->allcoins,coin,tmpcoin)
{ {
if ( myinfo->Cunspents == 0 || time(NULL) > coin->lastunspentsupdate+60 ) if ( strcmp(coin->symbol,"NOTARY") != 0 && (myinfo->Cunspents == 0 || time(NULL) > coin->lastunspentsupdate+60) )
{ {
//printf(">>>>>>>>>>>>> update %s\n",coin->symbol); //printf(">>>>>>>>>>>>> update %s\n",coin->symbol);
basilisk_unspents_update(myinfo,coin); basilisk_unspents_update(myinfo,coin);
@ -884,8 +887,7 @@ void basilisks_loop(void *arg)
//printf(">>>>>>>>>>>>> update %s finished\n",coin->symbol); //printf(">>>>>>>>>>>>> update %s finished\n",coin->symbol);
} }
} }
if ( myinfo->NOTARY.RELAYID < 0 ) basilisk_requests_poll(myinfo);
basilisk_requests_poll(myinfo);
} }
now = (uint32_t)time(NULL); now = (uint32_t)time(NULL);
portable_mutex_lock(&myinfo->messagemutex); portable_mutex_lock(&myinfo->messagemutex);

2
basilisk/basilisk_DEX.c

@ -528,7 +528,7 @@ INT_ARG(InstantDEX,incoming,requestid)
msgid = (uint32_t)time(NULL) + drift; msgid = (uint32_t)time(NULL) + drift;
if ( (retarray= basilisk_channelget(myinfo,myinfo->myaddr.persistent,DEX_channel,msgid,width)) != 0 ) if ( (retarray= basilisk_channelget(myinfo,myinfo->myaddr.persistent,DEX_channel,msgid,width)) != 0 )
{ {
//printf("GOT.(%s)\n",jprint(retarray,0)); printf("GOT.(%s)\n",jprint(retarray,0));
if ( (retval= basilisk_process_retarray(myinfo,0,InstantDEX_process_channelget,data,sizeof(data),DEX_channel,msgid,retarray,InstantDEX_incoming_func)) > 0 ) if ( (retval= basilisk_process_retarray(myinfo,0,InstantDEX_process_channelget,data,sizeof(data),DEX_channel,msgid,retarray,InstantDEX_incoming_func)) > 0 )
{ {
jaddstr(retjson,"result","success"); jaddstr(retjson,"result","success");

4
basilisk/basilisk_MSG.c

@ -107,9 +107,13 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
width = 3600; width = 3600;
else if ( width < 1 ) else if ( width < 1 )
width = 1; width = 1;
printf("iterate_MSG width.%d channel.%d msgid.%d src.%llx -> %llx\n",origwidth,channel,msgid,(long long)srchash.txid,(long long)desthash.txid);
for (i=0; i<width; i++) for (i=0; i<width; i++)
{ {
keylen = basilisk_messagekey(key,channel,msgid,srchash,desthash); keylen = basilisk_messagekey(key,channel,msgid,srchash,desthash);
int32_t j; for (j=0; j<keylen; j++)
printf("%02x",key[j]);
printf(" <- key\n");
if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 ) if ( (item= basilisk_respond_getmessage(myinfo,key,keylen)) != 0 )
jaddi(array,item); jaddi(array,item);
if ( origwidth > 0 ) if ( origwidth > 0 )

Loading…
Cancel
Save