jl777 8 years ago
parent
commit
e05ea137ec
  1. 10
      basilisk/basilisk.c
  2. 15
      basilisk/basilisk_MSG.c

10
basilisk/basilisk.c

@ -778,9 +778,7 @@ int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters)
{
if ( myinfo->NOTARY.RELAYID >= 0 )
{
fprintf(stderr,"P.%d ",ptr->datalen);
basilisk_ping_process(myinfo,ptr->addr,ptr->ipbits,ptr->data,ptr->datalen);
fprintf(stderr,"p");
}
}
else
@ -788,9 +786,7 @@ int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters)
len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag);
if ( 0 && myinfo->IAMLP == 0 )
printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip!=0?senderip:"?",basilisktag);
fprintf(stderr,"%s ",ptr->type);
basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len);
fprintf(stderr,"%s n.%d\n",ptr->type,n);
if ( 0 && myinfo->IAMLP == 0 )
printf("processed.%s from %s\n",ptr->type,senderip!=0?senderip:"?");
}
@ -832,9 +828,7 @@ void basilisk_p2p(struct supernet_info *myinfo,struct iguana_info *coin,struct i
if ( senderip != 0 && senderip[0] != 0 && strcmp(senderip,"127.0.0.1") != 0 )
ipbits = (uint32_t)calc_ipbits(senderip);
else ipbits = myinfo->myaddr.myipbits;
fprintf(stderr,"p2pQ.%d ",datalen);
ptr = basilisk_p2pitem_create(coin,addr,type,ipbits,data,datalen);
queue_enqueue("p2pQ",&myinfo->p2pQ,ptr,0);
}
void basilisk_requests_poll(struct supernet_info *myinfo)
@ -930,13 +924,9 @@ void basilisks_loop(void *arg)
while ( 1 )
{
startmilli = OS_milliseconds();
fprintf(stderr,"G");
basilisk_issued_purge(myinfo,600000);
fprintf(stderr,"I");
basilisk_iteration(myinfo);
fprintf(stderr," backI\n");
basilisk_p2pQ_process(myinfo,777);
fprintf(stderr,"\n");
if ( myinfo->NOTARY.RELAYID >= 0 )
endmilli = startmilli + 2500;
else endmilli = startmilli + 5000;

15
basilisk/basilisk_MSG.c

@ -85,7 +85,7 @@ int32_t basilisk_msgcmp(struct basilisk_message *msg,int32_t width,uint32_t chan
char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_t msgid,bits256 srchash,bits256 desthash,int32_t origwidth)
{
uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *msgjson,*item,*retjson,*array; bits256 zero; struct basilisk_message *msg,*tmpmsg,*firstmsg = 0; uint32_t now = (uint32_t)time(NULL);
uint8_t key[BASILISK_KEYSIZE]; int32_t allflag,i,keylen,width; cJSON *msgjson,*item,*retjson,*array; bits256 zero; struct basilisk_message *msg,*tmpmsg; uint32_t now = (uint32_t)time(NULL);
memset(zero.bytes,0,sizeof(zero));
if ( (width= origwidth) > 3600 )
width = 3600;
@ -93,24 +93,14 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
width = 1;
allflag = (bits256_nonz(srchash) == 0 && bits256_nonz(desthash) == 0);
array = cJSON_CreateArray();
fprintf(stderr,"[");
portable_mutex_lock(&myinfo->messagemutex);
HASH_ITER(hh,myinfo->messagetable,msg,tmpmsg)
{
if ( firstmsg == 0 )
firstmsg = msg;
else if ( firstmsg == msg )
{
printf("got 1stmsg.%p again?\n",firstmsg);
break;
}
if ( allflag != 0 || (msg->broadcast != 0 && basilisk_msgcmp(msg,origwidth,channel,msgid,zero,zero) == 0) )
{
fprintf(stderr,".");
if ( (msgjson= basilisk_msgjson(msg,msg->key,msg->keylen)) != 0 )
jaddi(array,msgjson);
}
fprintf(stderr,"(%p).%d 1st.%p\n",msg,msg->datalen,firstmsg);
if ( now > msg->expiration )
{
printf("delete expired message.%p QUEUEITEMS.%d\n",msg,QUEUEITEMS);
@ -160,7 +150,6 @@ char *basilisk_iterate_MSG(struct supernet_info *myinfo,uint32_t channel,uint32_
msgid--;
}
portable_mutex_unlock(&myinfo->messagemutex);
fprintf(stderr,"]");
if ( cJSON_GetArraySize(array) > 0 )
{
retjson = cJSON_CreateObject();
@ -229,7 +218,7 @@ char *basilisk_respond_OUT(struct supernet_info *myinfo,char *CMD,void *addr,cha
}
retstr = basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1,duration);
// printf("OUT keylen.%d datalen.%d\n",keylen,datalen);
char str[65]; printf("add message.[%d] channel.%u msgid.%x %s\n",datalen,juint(valsobj,"channel"),juint(valsobj,"msgid"),bits256_str(str,hash));
//char str[65]; printf("add message.[%d] channel.%u msgid.%x %s\n",datalen,juint(valsobj,"channel"),juint(valsobj,"msgid"),bits256_str(str,hash));
return(retstr);
}

Loading…
Cancel
Save