Browse Source

test

release/v0.1
jl777 8 years ago
parent
commit
95c6166d19
  1. 12
      basilisk/basilisk.c
  2. 28
      iguana/iguana_wallet.c

12
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 ) if ( RELAYID >= 0 && basilisk_specialcmd(CMD) == 0 )
return(clonestr("{\"error\":\"unsupported special relay command\"}")); return(clonestr("{\"error\":\"unsupported special relay command\"}"));
data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); 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); ptr = basilisk_requestservice(myinfo,_addr,CMD,blockflag,valsobj,hash,data,datalen,nBits);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
@ -725,7 +725,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
hash = jbits256(valsobj,"hash"); hash = jbits256(valsobj,"hash");
timeoutmillis = jint(valsobj,"timeout"); timeoutmillis = jint(valsobj,"timeout");
if ( (numrequired= jint(valsobj,"numrequired")) == 0 ) if ( (numrequired= jint(valsobj,"numrequired")) == 0 )
numrequired = sqrt(NUMRELAYS); numrequired = sqrt(NUMRELAYS)+1;
if ( senderipbits != 0 ) if ( senderipbits != 0 )
expand_ipbits(remoteaddr,senderipbits); expand_ipbits(remoteaddr,senderipbits);
else remoteaddr[0] = 0; 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 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 ) 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); //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); len += iguana_rwnum(0,data,sizeof(basilisktag),&basilisktag);
//int32_t i; for (i=0; i<datalen-len; i++) //int32_t i; for (i=0; i<datalen-len; i++)
// printf("%02x",data[len+i]); // printf("%02x",data[len+i]);
if ( 0 && RELAYID >= 0 ) //if ( RELAYID >= 0 )
printf(" ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",datalen,type,senderip!=0?senderip:"?",basilisktag); 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); basilisk_msgprocess(myinfo,_addr,ipbits,type,basilisktag,&data[len],datalen - len);
} }
if ( ptr != 0 ) if ( ptr != 0 )
@ -930,7 +930,7 @@ HASH_ARRAY_STRING(basilisk,balances,hash,vals,hexstr)
if ( jobj(vals,"fanout") == 0 ) if ( jobj(vals,"fanout") == 0 )
jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1)); jaddnum(vals,"fanout",MAX(5,(int32_t)sqrt(NUMRELAYS)+1));
if ( jobj(vals,"numrequired") == 0 ) if ( jobj(vals,"numrequired") == 0 )
jaddnum(vals,"numrequired",sqrt(NUMRELAYS)); jaddnum(vals,"numrequired",juint(vals,"fanout"));
if ( coin != 0 ) if ( coin != 0 )
{ {
if ( jobj(vals,"addresses") == 0 ) if ( jobj(vals,"addresses") == 0 )

28
iguana/iguana_wallet.c

@ -1138,7 +1138,7 @@ cJSON *iguana_getinfo(struct supernet_info *myinfo,struct iguana_info *coin)
ZERO_ARGS(bitcoinrpc,getinfo) 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 ) if ( remoteaddr != 0 )
return(clonestr("{\"error\":\"no remote\"}")); return(clonestr("{\"error\":\"no remote\"}"));
if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 ) if ( coin->FULLNODE != 0 || coin->VALIDATENODE != 0 )
@ -1155,18 +1155,40 @@ ZERO_ARGS(bitcoinrpc,getinfo)
if ( is_cJSON_Array(array) != 0 ) if ( is_cJSON_Array(array) != 0 )
{ {
getinfoobj = jduplicate(jitem(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<n; i++)
{
item = jitem(array,i);
if ( juint(getinfoobj,"longestchain") > longest )
longest = juint(getinfoobj,"longestchain");
if ( (fullnodes= jarray(&m,item,"supernet")) != 0 )
{
for (j=0; j<m; j++)
{
fprintf(stderr,"[%s] ",jstri(fullnodes,j));
iguana_launchpeer(coin,jstri(fullnodes,j),1);
}
}
}
jaddnum(getinfoobj,"longestchain",longest);
}
} }
else else
{ {
free(ptr->retstr); free(ptr->retstr);
return(jprint(array,1)); return(jprint(array,1));
} }
free_json(array);
} }
free(ptr->retstr); 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) TWO_STRINGS(bitcoinrpc,setaccount,address,account)

Loading…
Cancel
Save