From 8d1d187f69bd2c9af062bc6b2c0254d61b3d1bff Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 21 Jun 2016 08:30:47 -0300 Subject: [PATCH] test --- basilisk/basilisk.c | 8 +++++++- basilisk/basilisk_CMD.c | 6 +++--- gecko/gecko.c | 4 ++-- gecko/gecko_blocks.c | 1 + iguana/iguana_json.c | 5 ----- iguana/main.c | 2 +- 6 files changed, 14 insertions(+), 12 deletions(-) diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index 6306efdf9..0feae08fc 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -799,14 +799,18 @@ void basilisks_loop(void *arg) iter++; if ( (ptr= queue_dequeue(&myinfo->basilisks.submitQ,0)) != 0 ) { + portable_mutex_lock(&myinfo->basilisk_mutex); HASH_ADD(hh,myinfo->basilisks.issued,basilisktag,sizeof(ptr->basilisktag),ptr); + portable_mutex_unlock(&myinfo->basilisk_mutex); ptr->refcount++; continue; } //fprintf(stderr,"A"); if ( (ptr= queue_dequeue(&myinfo->basilisks.resultsQ,0)) != 0 ) { + portable_mutex_lock(&myinfo->basilisk_mutex); HASH_FIND(hh,myinfo->basilisks.issued,&ptr->basilisktag,sizeof(ptr->basilisktag),pending); + portable_mutex_unlock(&myinfo->basilisk_mutex); if ( pending != 0 ) { if ( (n= pending->numresults) < sizeof(pending->results)/sizeof(*pending->results) ) @@ -844,6 +848,7 @@ void basilisks_loop(void *arg) } //fprintf(stderr,"B"); flag = 0; + portable_mutex_lock(&myinfo->basilisk_mutex); HASH_ITER(hh,myinfo->basilisks.issued,pending,tmp) { //printf("pending.%u numresults.%d m %f func.%p\n",pending->basilisktag,pending->numresults,pending->metrics[0],pending->metricfunc); @@ -894,12 +899,13 @@ void basilisks_loop(void *arg) free(pending->results[i]), pending->results[i] = 0; if ( pending->vals != 0 ) free_json(pending->vals), pending->vals = 0; - //free(pending); + free(pending); } else printf("illegal refcount for pending\n"); flag++; } } } + portable_mutex_unlock(&myinfo->basilisk_mutex); //fprintf(stderr,"D"); if ( (btcd= iguana_coinfind("BTCD")) != 0 ) { diff --git a/basilisk/basilisk_CMD.c b/basilisk/basilisk_CMD.c index fbf332def..0d2c0c49d 100755 --- a/basilisk/basilisk_CMD.c +++ b/basilisk/basilisk_CMD.c @@ -59,14 +59,14 @@ char *basilisk_addrelay_info(struct supernet_info *myinfo,uint8_t *pubkey33,uint myinfo->numrelays++; for (i=0; inumrelays; i++) memcpy(&myinfo->relaybits[i],&myinfo->relays[i].ipbits,sizeof(myinfo->relaybits[i])); - /*revsort32(&myinfo->relaybits[0],myinfo->numrelays,sizeof(myinfo->relaybits[0])); + revsort32(&myinfo->relaybits[0],myinfo->numrelays,sizeof(myinfo->relaybits[0])); for (i=0; inumrelays; i++) { char ipaddr[64]; expand_ipbits(ipaddr,myinfo->relaybits[i]); printf("%s ",ipaddr); } - printf("sorted\n");*/ + printf("sorted\n"); return(clonestr("{\"result\":\"relay added\"}")); } @@ -114,7 +114,7 @@ int32_t basilisk_relays_send(struct supernet_info *myinfo,struct iguana_peer *ad init_hexbytes_noT(hexstr,serialized,len); //printf("send relays.(%s)\n",hexstr); vcalc_sha256(0,txhash2.bytes,serialized,len); - if ( (siglen= bitcoin_sign(myinfo->ctx,"BTCD",sig,txhash2,myinfo->persistent_priv,1)) > 0 ) + if ( 0 && bits256_nonz(myinfo->persistent_priv) != 0 && (siglen= bitcoin_sign(myinfo->ctx,"BTCD",sig,txhash2,myinfo->persistent_priv,1)) > 0 ) { init_hexbytes_noT(strbuf,sig,siglen); jaddstr(vals,"sig",strbuf); diff --git a/gecko/gecko.c b/gecko/gecko.c index fac7df1c8..861fcf460 100755 --- a/gecko/gecko.c +++ b/gecko/gecko.c @@ -287,9 +287,9 @@ cJSON *gecko_genesisissue(char *symbol,char *chainname,char *chainstr,cJSON *val struct iguana_info *basilisk_geckochain(struct supernet_info *myinfo,char *symbol,char *chainname,cJSON *valsobj) { - int32_t datalen,hdrsize,len=0; struct iguana_info *virt=0; char *hexstr; uint8_t hexbuf[1024],*ptr,*serialized; struct iguana_peer *addr; struct iguana_txblock txdata; + int32_t datalen,hdrsize,len=0; struct iguana_info *virt=0; char *hexstr; uint8_t hexbuf[8192],*ptr,*serialized; struct iguana_peer *addr; struct iguana_txblock txdata; portable_mutex_lock(&myinfo->gecko_mutex); - printf("symbol.%s chain.%s (%s)\n",symbol,chainname,jprint(valsobj,0)); + printf("basilisk_geckochain symbol.%s chain.%s (%s)\n",symbol,chainname,jprint(valsobj,0)); if ( iguana_coinfind(symbol) == 0 && (hexstr= jstr(valsobj,"genesisblock")) != 0 && (virt= iguana_coinadd(symbol,chainname,valsobj)) != 0 ) { safecopy(virt->name,chainname,sizeof(virt->name)); diff --git a/gecko/gecko_blocks.c b/gecko/gecko_blocks.c index 500a0e844..c6649cb42 100755 --- a/gecko/gecko_blocks.c +++ b/gecko/gecko_blocks.c @@ -288,6 +288,7 @@ int32_t basilisk_blocksubmit(struct supernet_info *myinfo,struct iguana_info *bt if ( jobj(retjson,"error") == 0 ) { valsobj = cJSON_CreateObject(); + jaddnum(valsobj,"timeout",1000); jaddnum(valsobj,"fanout",-1); jaddstr(valsobj,"symbol",virt->symbol); if ( (str2= basilisk_standardservice("BLK",myinfo,hash2,valsobj,blockstr,1)) != 0 ) diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index 632fef536..fb32c36a7 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -606,11 +606,6 @@ ZERO_ARGS(bitcoinrpc,getdifficulty) char buf[512]; if ( coin != 0 ) { - /* { - "proof-of-work": 15432589.66327462, - "proof-of-stake": 0.00112314, - "search-interval": 0 - }*/ sprintf(buf,"{\"result\":\"success\",\"proof-of-work\":\"%.8f\",\"search-interval\": 0}",PoW_from_compact(coin->blocks.hwmchain.RO.bits,coin->chain->unitval)); return(clonestr(buf)); } else return(clonestr("{\"error\":\"getdifficulty needs coin\"}")); diff --git a/iguana/main.c b/iguana/main.c index 5e8975941..0ae15f94b 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1154,7 +1154,7 @@ void iguana_appletests(struct supernet_info *myinfo) bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); getchar();**/ - 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 ) + if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"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); 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 )