Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
2148107cfb
  1. 31
      basilisk/basilisk.c
  2. 2
      basilisk/basilisk_CMD.c
  3. 10
      basilisk/basilisk_bitcoin.c
  4. 2
      iguana/main.c

31
basilisk/basilisk.c

@ -328,7 +328,7 @@ char *basilisk_waitresponse(struct supernet_info *myinfo,char *CMD,char *symbol,
return(retstr); return(retstr);
} }
struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t *numsentp,char *CMD,char *symbol,cJSON *valsobj,int32_t fanout,int32_t minresults,uint32_t basilisktag,int32_t timeoutmillis,void *_metricfunc,char *retstr,int32_t encryptflag,int32_t delaymillis,uint32_t nBits) struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t *numsentp,char *CMD,char *symbol,int32_t blockflag,cJSON *valsobj,int32_t fanout,int32_t minresults,uint32_t basilisktag,int32_t timeoutmillis,void *_metricfunc,char *retstr,int32_t encryptflag,int32_t delaymillis,uint32_t nBits)
{ {
struct basilisk_item *ptr; uint8_t *allocptr,*data,space[4096]; int32_t datalen; basilisk_metricfunc metricfunc = _metricfunc; struct basilisk_item *ptr; uint8_t *allocptr,*data,space[4096]; int32_t datalen; basilisk_metricfunc metricfunc = _metricfunc;
ptr = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,minresults,valsobj,timeoutmillis,metricfunc); ptr = basilisk_itemcreate(myinfo,CMD,symbol,basilisktag,minresults,valsobj,timeoutmillis,metricfunc);
@ -345,23 +345,27 @@ struct basilisk_item *basilisk_issueremote(struct supernet_info *myinfo,int32_t
{ {
data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag); data = basilisk_jsondata(sizeof(struct iguana_msghdr),&allocptr,space,sizeof(space),&datalen,symbol,valsobj,basilisktag);
*numsentp = ptr->numsent = basilisk_sendcmd(myinfo,0,CMD,&ptr->basilisktag,encryptflag,delaymillis,data,datalen,1,ptr->nBits); *numsentp = ptr->numsent = basilisk_sendcmd(myinfo,0,CMD,&ptr->basilisktag,encryptflag,delaymillis,data,datalen,1,ptr->nBits);
queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); if ( blockflag != 0 )
queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
else ptr->finished = (uint32_t)time(NULL);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
} }
return(ptr); return(ptr);
} }
struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char *CMD,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits) struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char *CMD,int32_t blockflag,cJSON *valsobj,bits256 hash,uint8_t *data,int32_t datalen,uint32_t nBits)
{ {
int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt,*btcd; int32_t minresults,timeoutmillis,numsent,delaymillis,encryptflag; struct basilisk_item *ptr; char buf[4096],*symbol,*str = 0; struct iguana_info *virt,*btcd;
if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->RELAYNODE != 0 ) if ( (btcd= iguana_coinfind("BTCD")) != 0 && btcd->RELAYNODE != 0 )
jaddnum(valsobj,"iamrelay",1); jaddnum(valsobj,"iamrelay",1);
basilisk_addhexstr(&str,valsobj,buf,sizeof(buf),data,datalen); basilisk_addhexstr(&str,valsobj,buf,sizeof(buf),data,datalen);
if ( jobj(valsobj,"hash") != 0 )
jdelete(valsobj,"hash");
if ( bits256_cmp(hash,GENESIS_PUBKEY) != 0 && bits256_nonz(hash) != 0 ) if ( bits256_cmp(hash,GENESIS_PUBKEY) != 0 && bits256_nonz(hash) != 0 )
{
if ( jobj(valsobj,"hash") != 0 )
jdelete(valsobj,"hash");
jaddbits256(valsobj,"hash",hash); jaddbits256(valsobj,"hash",hash);
}
if ( (minresults= jint(valsobj,"minresults")) <= 0 ) if ( (minresults= jint(valsobj,"minresults")) <= 0 )
minresults = 1; minresults = 1;
if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 ) if ( (timeoutmillis= jint(valsobj,"timeout")) == 0 )
@ -377,7 +381,7 @@ struct basilisk_item *basilisk_requestservice(struct supernet_info *myinfo,char
} }
encryptflag = jint(valsobj,"encrypt"); encryptflag = jint(valsobj,"encrypt");
delaymillis = jint(valsobj,"delay"); delaymillis = jint(valsobj,"delay");
ptr = basilisk_issueremote(myinfo,&numsent,CMD,"BTCD",valsobj,1,minresults,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits); ptr = basilisk_issueremote(myinfo,&numsent,CMD,"BTCD",blockflag,valsobj,1,minresults,0,timeoutmillis,0,0,encryptflag,delaymillis,nBits);
return(ptr); return(ptr);
} }
@ -386,7 +390,7 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,bits256 ha
uint32_t nBits = 0; uint8_t space[8192],*allocptr=0,*data = 0; struct basilisk_item *ptr,Lptr; int32_t datalen = 0; cJSON *retjson; uint32_t nBits = 0; uint8_t space[8192],*allocptr=0,*data = 0; struct basilisk_item *ptr,Lptr; int32_t datalen = 0; cJSON *retjson;
retjson = cJSON_CreateObject(); retjson = cJSON_CreateObject();
data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr); data = get_dataptr(BASILISK_HDROFFSET,&allocptr,&datalen,space,sizeof(space),hexstr);
ptr = basilisk_requestservice(myinfo,CMD,valsobj,hash,data,datalen,nBits); ptr = basilisk_requestservice(myinfo,CMD,blockflag,valsobj,hash,data,datalen,nBits);
if ( allocptr != 0 ) if ( allocptr != 0 )
free(allocptr); free(allocptr);
if ( ptr != 0 ) if ( ptr != 0 )
@ -786,9 +790,9 @@ void basilisks_loop(void *arg)
iter++; iter++;
if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 )
{ {
//if ( ptr->finished == 0 ) if ( ptr->finished == 0 )
HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr);
//else free(ptr); else free(ptr);
continue; continue;
} }
if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 )
@ -1014,7 +1018,7 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
symbol = "BTCD"; symbol = "BTCD";
if ( (valsobj= cJSON_Parse((char *)data)) != 0 ) if ( (valsobj= cJSON_Parse((char *)data)) != 0 )
{ {
printf("MSGVALS.(%s)\n",(char *)data); //printf("MSGVALS.(%s)\n",(char *)data);
if ( jobj(valsobj,"coin") != 0 ) if ( jobj(valsobj,"coin") != 0 )
coin = iguana_coinfind(jstr(valsobj,"coin")); coin = iguana_coinfind(jstr(valsobj,"coin"));
else if ( jobj(valsobj,"symbol") != 0 ) else if ( jobj(valsobj,"symbol") != 0 )
@ -1089,11 +1093,14 @@ void basilisk_msgprocess(struct supernet_info *myinfo,void *_addr,uint32_t sende
if ( senderipbits != 0 ) if ( senderipbits != 0 )
expand_ipbits(remoteaddr,senderipbits); expand_ipbits(remoteaddr,senderipbits);
else remoteaddr[0] = 0; else remoteaddr[0] = 0;
if ( valsobj != 0 && remoteaddr != 0 && juint(valsobj,"iamrelay") != 0 ) if ( valsobj != 0 && remoteaddr != 0 )
{ {
if ( strcmp(CMD,"RLY") == 0 ) if ( strcmp(CMD,"RLY") == 0 )
{ {
retstr = basilisk_respond_relays(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk); if ( juint(valsobj,"iamrelay") != 0 )
{
retstr = basilisk_respond_relays(myinfo,type,addr,remoteaddr,basilisktag,valsobj,data,datalen,hash,from_basilisk);
}
free_json(valsobj); free_json(valsobj);
myinfo->basilisk_busy = 0; myinfo->basilisk_busy = 0;
return; return;

2
basilisk/basilisk_CMD.c

@ -144,7 +144,7 @@ void basilisk_request_goodbye(struct supernet_info *myinfo)
{ {
cJSON *valsobj = cJSON_CreateObject(); cJSON *valsobj = cJSON_CreateObject();
jaddnum(valsobj,"timeout",-1); jaddnum(valsobj,"timeout",-1);
basilisk_requestservice(myinfo,"BYE",valsobj,GENESIS_PUBKEY,0,0,0); basilisk_requestservice(myinfo,"BYE",0,valsobj,GENESIS_PUBKEY,0,0,0);
free_json(valsobj); free_json(valsobj);
} }

10
basilisk/basilisk_bitcoin.c

@ -360,15 +360,15 @@ void *basilisk_bitcoinvalue(struct basilisk_item *Lptr,struct supernet_info *myi
if ( v->vout == vout && bits256_cmp(txid,v->txid) == 0 && strcmp(v->coinaddr,coinaddr) == 0 ) if ( v->vout == vout && bits256_cmp(txid,v->txid) == 0 && strcmp(v->coinaddr,coinaddr) == 0 )
{ {
printf("bitcoinvalue local ht.%d %s %.8f\n",v->height,v->coinaddr,dstr(v->value)); printf("bitcoinvalue local ht.%d %s %.8f\n",v->height,v->coinaddr,dstr(v->value));
ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,basilisk_valuestr(coin,v->coinaddr,v->value,v->height,txid,vout),0,0,BASILISK_DEFAULTDIFF); ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,basilisk_valuestr(coin,v->coinaddr,v->value,v->height,txid,vout),0,0,BASILISK_DEFAULTDIFF);
queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); //queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
return(ptr); return(ptr);
} }
} }
} }
printf("bitcoinvalue issue remote tag.%u\n",basilisktag); printf("bitcoinvalue issue remote tag.%u\n",basilisktag);
ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,0,0,0,BASILISK_DEFAULTDIFF); ptr = basilisk_issueremote(myinfo,&numsent,"VAL",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_valuemetric,0,0,0,BASILISK_DEFAULTDIFF);
queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0); //queue_enqueue("submitQ",&myinfo->basilisks.submitQ,&ptr->DL,0);
return(ptr); return(ptr);
} }
@ -630,6 +630,6 @@ void *basilisk_bitcoinrawtx(struct basilisk_item *Lptr,struct supernet_info *myi
Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx\"}"); Lptr->retstr = clonestr("{\"error\":\"couldnt create rawtx\"}");
return(Lptr); return(Lptr);
} }
return(basilisk_issueremote(myinfo,&numsent,"RAW",coin->symbol,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_rawtxmetric,0,0,0,BASILISK_DEFAULTDIFF)); return(basilisk_issueremote(myinfo,&numsent,"RAW",coin->symbol,1,valsobj,juint(valsobj,"fanout"),juint(valsobj,"minresults"),basilisktag,timeoutmillis,coin->basilisk_rawtxmetric,0,0,0,BASILISK_DEFAULTDIFF));
} }

2
iguana/main.c

@ -1150,7 +1150,7 @@ void iguana_appletests(struct supernet_info *myinfo)
bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33);
printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i);
getchar();**/ getchar();**/
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":0,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":128,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 ) if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":0,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":64,\"endpend\":64,\"services\":129,\"maxpeers\":128,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":4,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{ {
free(str); free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":64,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":4,\"poll\":100}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save