From 95c6166d193f03b3b1dd7fbd392cfcac8bf9e683 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 12 Sep 2016 11:58:08 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 12 ++++++------ iguana/iguana_wallet.c | 28 +++++++++++++++++++++++++--- 2 files changed, 31 insertions(+), 9 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index e6076478b..fde733a5b 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -425,7 +425,7 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add if ( RELAYID >= 0 && basilisk_specialcmd(CMD) == 0 ) return(clonestr("{\"error\":\"unsupported special relay command\"}")); data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); - printf("request.(%s)\n",jprint(valsobj,0)); + //printf("request.(%s)\n",jprint(valsobj,0)); ptr = basilisk_requestservice(myinfo,_addr,CMD,blockflag,valsobj,hash,data,datalen,nBits); if ( allocptr != 0 ) free(allocptr); @@ -725,7 +725,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende hash = jbits256(valsobj,"hash"); timeoutmillis = jint(valsobj,"timeout"); if ( (numrequired= jint(valsobj,"numrequired")) == 0 ) - numrequired = sqrt(NUMRELAYS); + numrequired = sqrt(NUMRELAYS)+1; if ( senderipbits != 0 ) expand_ipbits(remoteaddr,senderipbits); else remoteaddr[0] = 0; @@ -735,7 +735,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende { if ( coin->FULLNODE != 0 || RELAYID >= 0 ) // iguana node { - //printf("services %s\n",type); + printf("FULL.%d RELAYID.%d NUMRELAYS.%d services %s\n",coin->FULLNODE,RELAYID,NUMRELAYS,type); if ( (retstr= (*basilisk_services[i][1])(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk)) != 0 ) { //printf("from_basilisk.%d ret.(%s)\n",from_basilisk,retstr); @@ -783,8 +783,8 @@ void basilisk_p2p(void *_myinfo,void *_addr,char *senderip,uint8_t *data,int32_t len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag); //int32_t i; for (i=0; i= 0 ) - printf(" ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",datalen,type,senderip!=0?senderip:"?",basilisktag); + //if ( RELAYID >= 0 ) + printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",RELAYID,datalen,type,senderip!=0?senderip:"?",basilisktag); basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len); } if ( ptr != 0 ) @@ -930,7 +930,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr) if ( jobj(vals,"fanout") == 0 ) jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); if ( jobj(vals,"numrequired") == 0 ) - jaddnum(vals,"numrequired",sqrt(NUMRELAYS)); + jaddnum(vals,"numrequired",juint(vals,"fanout")); if ( coin != 0 ) { if ( jobj(vals,"addresses") == 0 ) diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index d2402594d..c250bb156 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -1138,7 +1138,7 @@ cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) ZERO_ARGS(bitcoinrpc,getinfo) { - struct basilisk_item Lptr,*ptr; cJSON *valsobj,*getinfoobj=0,*array; + struct basilisk_item Lptr,*ptr; int32_t i,j,m,n,longest; cJSON *valsobj,*getinfoobj=0,*array,*item,*fullnodes; if ( remoteaddr != 0 ) return(clonestr("{\"error\":\"no remote\"}")); if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 ) @@ -1155,18 +1155,40 @@ ZERO_ARGS(bitcoinrpc,getinfo) if ( is_cJSON_Array(array) != 0 ) { getinfoobj = jduplicate(jitem(array,0)); + longest = juint(getinfoobj,"longestchain"); + if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && (n= cJSON_GetArraySize(array)) > 1 ) + { + jdelete(getinfoobj,"longestchain"); + for (i=1; i longest ) + longest = juint(getinfoobj,"longestchain"); + if ( (fullnodes= jarray(&m,item,"supernet")) != 0 ) + { + for (j=0; jretstr); return(jprint(array,1)); } + free_json(array); } free(ptr->retstr); - return(jprint(array,1)); + if ( getinfoobj != 0 ) + return(jprint(getinfoobj,1)); } - else return(clonestr("{\"error\":\"null basilisk_getinfo\"}")); } + return(clonestr("{\"error\":\"null basilisk_getinfo\"}")); } TWO_STRINGS(bitcoinrpc,setaccount,address,account)