From 5a28d75c45c122208c9e6bee1e8cbc03adf3e0df Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 20 Sep 2016 04:12:22 -0300 Subject: [PATCH] test --- iguana/iguana_bundles.c | 3 ++- iguana/iguana_recv.c | 18 ++++++++++++------ iguana/iguana_rpc.c | 2 +- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 06ae503b4..7c4372d42 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -882,7 +882,7 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); } - if ( strcmp("BTC",coin->symbol) != 0 && (bp == coin->current || bp->hdrsi == coin->bundlescount-1) && bits256_nonz(bp->nextbundlehash2) == 0 ) + if ( time(NULL) > bp->hdrtime+dist && strcmp("BTC",coin->symbol) != 0 && (bp == coin->current || bp->hdrsi == coin->bundlescount-1) && bits256_nonz(bp->nextbundlehash2) == 0 ) { if ( bp->numhashes < bp->n && bp->numcached < bp->n ) { @@ -890,6 +890,7 @@ int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,s for (i=0; in; i++) if ( GETBIT(bp->haveblock,i) == 0 ) bp->issued[i] = 0; + bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); } iguana_bundleissuemissing(myinfo,coin,bp,3,3.); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index b7a0bfc1f..9b018cbd2 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1057,10 +1057,11 @@ void iguana_bundlespeculate(struct iguana_info *coin,struct iguana_bundle *bp,in { if ( bp == 0 ) return; - if ( strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && bundlei == 0 && bp->speculative == 0 && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) + if ( time(NULL) > bp->hdrtime+3 && strcmp("BTC",coin->symbol) != 0 && bp->numhashes < bp->n && bundlei == 0 && bp->speculative == 0 && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) { char str[65]; bits256_str(str,bp->hashes[0]); //fprintf(stderr,"Afound block -> %d %d hdr.%s\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,str); + bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(str),1); } } @@ -1448,8 +1449,11 @@ void iguana_autoextend(struct supernet_info *myinfo,struct iguana_info *coin,str newbp = iguana_bundlecreate(coin,&bundlei,bp->bundleheight+coin->chain->bundlesize,bp->nextbundlehash2,zero,1); if ( newbp != 0 ) { - if ( newbp->speculative == 0 ) + if ( time(NULL) > bp->hdrtime+3 && newbp->speculative == 0 ) + { + bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + } //char str[65],str2[65]; printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight); if ( newbp->queued == 0 ) iguana_bundleQ(myinfo,coin,newbp,1000); @@ -1712,9 +1716,10 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig } } // else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height); } - if ( 0 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current ) + if ( 0 && time(NULL) > bp->hdrtime+3 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current ) { printf("reissue hdrs request for [%d]\n",bp->hdrsi); + bp->hdrtime = (uint32_t)time(NULL); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); } if ( (block= iguana_blockhashset("recvblock",coin,-1,origblock->RO.hash2,1)) != 0 ) @@ -1978,7 +1983,7 @@ int32_t iguana_needhdrs(struct iguana_info *coin) int32_t iguana_reqhdrs(struct iguana_info *coin) { - int32_t i,lag,n = 0; struct iguana_bundle *bp; char hashstr[65]; + int32_t i,lag,n = 0; struct iguana_bundle *bp; char hashstr[65]; uint32_t now = (uint32_t)time(NULL); //if ( queue_size(&coin->hdrsQ) == 0 ) { if ( coin->active != 0 ) @@ -1992,10 +1997,11 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) else if ( coin->current == 0 || bp->hdrsi > coin->current->hdrsi+coin->MAXBUNDLES ) continue; else lag = 30; - if ( time(NULL) > bp->issuetime+lag ) + if ( now > bp->issuetime+lag && now > bp->hdrtime+3 ) { + bp->hdrtime = now; if ( 0 && bp == coin->current ) - printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(time(NULL)-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); + printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); if ( bp->issuetime == 0 ) coin->numpendings++; init_hexbytes_noT(hashstr,bp->hashes[0].bytes,sizeof(bits256)); diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index 5f348293d..02f381193 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -845,7 +845,7 @@ char *SuperNET_rpcparse(struct supernet_info *myinfo,char *retbuf,int32_t bufsiz if ( strncmp("Origin: ",&urlstr[i],strlen("Origin: ")) == 0 ) { originstr = &urlstr[i + strlen("Origin: ")]; - if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 ) + if ( strncmp("null",originstr,strlen("null")) != 0 && strncmp("http://localhost:",originstr,strlen("http://localhost:")) != 0 && strncmp("http://127.0.0.1:",originstr,strlen("http://127.0.0.1:")) != 0 && strncmp("http://easydex.supernet.org:",originstr,strlen("http://easydex.supernet.org:")) != 0 ) { printf("remote Origin REJECT.(%s)\n",urlstr); return(clonestr("{\"error\":\"remote origin not enabled\"}"));