Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
195cba47e3
  1. 12
      basilisk/basilisk_MSG.c
  2. 10
      iguana/iguana_unspents.c

12
basilisk/basilisk_MSG.c

@ -42,7 +42,7 @@ int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipb
int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key; int32_t i,msglen,len=0; uint8_t num,keylen,*msg,*key;
if ( (num= data[len++]) > 0 ) if ( (num= data[len++]) > 0 )
{ {
printf("processMSG num.%d datalen.%d\n",num,datalen); //printf("processMSG num.%d datalen.%d\n",num,datalen);
for (i=0; i<num; i++) for (i=0; i<num; i++)
{ {
keylen = data[len++]; keylen = data[len++];
@ -82,7 +82,7 @@ int32_t basilisk_ping_genMSG(struct supernet_info *myinfo,uint8_t *data,int32_t
datalen += iguana_rwnum(1,&data[datalen],sizeof(msg->datalen),&msg->datalen); datalen += iguana_rwnum(1,&data[datalen],sizeof(msg->datalen),&msg->datalen);
if ( maxlen > datalen+msg->datalen ) if ( maxlen > datalen+msg->datalen )
{ {
printf("SEND keylen.%d msglen.%d\n",msg->keylen,msg->datalen); //printf("SEND keylen.%d msglen.%d\n",msg->keylen,msg->datalen);
memcpy(&data[datalen],msg->data,msg->datalen), datalen += msg->datalen; memcpy(&data[datalen],msg->data,msg->datalen), datalen += msg->datalen;
} }
else else
@ -137,7 +137,7 @@ char *basilisk_respond_OUT(struct supernet_info *myinfo,char *CMD,void *addr,cha
int32_t keylen; uint8_t key[64]; int32_t keylen; uint8_t key[64];
keylen = basilisk_messagekey(key,hash,valsobj); keylen = basilisk_messagekey(key,hash,valsobj);
//printf("keylen.%d datalen.%d\n",keylen,datalen); //printf("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(basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1)); return(basilisk_respond_addmessage(myinfo,key,keylen,data,datalen,1));
} }
@ -145,7 +145,7 @@ char *basilisk_respond_MSG(struct supernet_info *myinfo,char *CMD,void *addr,cha
{ {
int32_t keylen; uint8_t key[64]; int32_t keylen; uint8_t key[64];
keylen = basilisk_messagekey(key,hash,valsobj); keylen = basilisk_messagekey(key,hash,valsobj);
char str[65]; printf("%s channel.%u msgid.%u datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen); //char str[65]; printf("%s channel.%u msgid.%u datalen.%d\n",bits256_str(str,hash),juint(valsobj,"channel"),juint(valsobj,"msgid"),datalen);
return(basilisk_respond_getmessage(myinfo,key,keylen)); return(basilisk_respond_getmessage(myinfo,key,keylen));
} }
@ -189,7 +189,7 @@ int32_t basilisk_channelsend(struct supernet_info *myinfo,bits256 hash,uint32_t
valsobj = cJSON_CreateObject(); valsobj = cJSON_CreateObject();
jaddnum(valsobj,"channel",channel); jaddnum(valsobj,"channel",channel);
jaddnum(valsobj,"msgid",msgid); jaddnum(valsobj,"msgid",msgid);
char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s\n",datalen,channel,msgid,bits256_str(str,hash)); //char str[65]; printf("sendmessage.[%d] channel.%u msgid.%x -> %s\n",datalen,channel,msgid,bits256_str(str,hash));
if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 ) if ( (retstr= basilisk_sendmessage(myinfo,0,0,0,hash,valsobj,hexstr)) != 0 )
{ {
retval = 0; retval = 0;
@ -230,7 +230,7 @@ int32_t basilisk_channelget(struct supernet_info *myinfo,bits256 hash,uint32_t c
jaddnum(valsobj,"fanout",1); jaddnum(valsobj,"fanout",1);
if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 ) if ( (retstr= basilisk_getmessage(myinfo,0,0,0,hash,valsobj,0)) != 0 )
{ {
printf("gotmessage.(%s)\n",retstr); //printf("gotmessage.(%s)\n",retstr);
if ( (retarray= cJSON_Parse(retstr)) != 0 ) if ( (retarray= cJSON_Parse(retstr)) != 0 )
{ {
if ( is_cJSON_Array(retarray) != 0 ) if ( is_cJSON_Array(retarray) != 0 )

10
iguana/iguana_unspents.c

@ -544,7 +544,7 @@ int32_t iguana_unspent_check(struct supernet_info *myinfo,struct iguana_info *co
memset(&txid,0,sizeof(txid)); memset(&txid,0,sizeof(txid));
if ( iguana_unspentind2txid(myinfo,coin,&spentheight,&txid,&vout,hdrsi,unspentind) == 0 ) if ( iguana_unspentind2txid(myinfo,coin,&spentheight,&txid,&vout,hdrsi,unspentind) == 0 )
{ {
char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout); //char str[65]; printf("verify %s/v%d is not already used\n",bits256_str(str,txid),vout);
if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 ) if ( basilisk_addspend(myinfo,coin->symbol,txid,vout,0) != 0 )
{ {
char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",hdrsi,unspentind,bits256_str(str,txid)); char str[65]; printf("iguana_unspent_check found unspentind (%u %d) %s\n",hdrsi,unspentind,bits256_str(str,txid));
@ -570,7 +570,7 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
{ {
if ( (coinaddr= jstri(addresses,i)) != 0 ) if ( (coinaddr= jstri(addresses,i)) != 0 )
{ {
printf("i.%d coinaddr.(%s) minconf.%d longest.%d diff.%d\n",i,coinaddr,minconf,coin->longestchain,coin->blocks.hwmchain.height - minconf); //printf("i.%d coinaddr.(%s) minconf.%d longest.%d diff.%d\n",i,coinaddr,minconf,coin->longestchain,coin->blocks.hwmchain.height - minconf);
total = 0; total = 0;
n = 0; n = 0;
if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 ) if ( coin->RELAYNODE != 0 || coin->VALIDATENODE != 0 )
@ -586,7 +586,9 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
unspentind = (int32_t)candidates[j << 1]; unspentind = (int32_t)candidates[j << 1];
if ( iguana_unspent_check(myinfo,coin,hdrsi,unspentind) == 0 ) if ( iguana_unspent_check(myinfo,coin,hdrsi,unspentind) == 0 )
{ {
printf("(%d u%d) %.8f not in mempool\n",hdrsi,unspentind,dstr(candidates[(j << 1) + 1])); //printf("(%d u%d) %.8f not in mempool\n",hdrsi,unspentind,dstr(candidates[(j << 1) + 1]));
unspents[numunspents << 1] = candidates[j << 1];
unspents[(numunspents << 1) + 1] = candidates[(j << 1) + 1];
sum += candidates[(j << 1) + 1]; sum += candidates[(j << 1) + 1];
unspents += 2; unspents += 2;
numunspents++; numunspents++;
@ -616,7 +618,7 @@ int32_t iguana_unspentslists(struct supernet_info *myinfo,struct iguana_info *co
} }
} }
} }
if ( numunspents > max ) if ( numunspents > max || sum > required )
break; break;
//printf("n.%d max.%d total %.8f\n",n,max,dstr(total)); //printf("n.%d max.%d total %.8f\n",n,max,dstr(total));
} }

Loading…
Cancel
Save