From f5c6bd82b8b93ef53bdcdf80dc2291ed8bcb3fcf Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 1 Apr 2016 17:30:33 -0600 Subject: [PATCH] test --- deprecated/obsolete.h | 26 ++++++++++++++++++++++++++ iguana/iguana777.h | 1 + iguana/iguana_bundles.c | 34 ++++------------------------------ iguana/iguana_unspents.c | 14 +++++++------- 4 files changed, 38 insertions(+), 37 deletions(-) diff --git a/deprecated/obsolete.h b/deprecated/obsolete.h index 9f7e9c740..4a4038b6c 100755 --- a/deprecated/obsolete.h +++ b/deprecated/obsolete.h @@ -15139,5 +15139,31 @@ len = 0; threshold = (bp->avetime + coin->avetime) * .5; else threshold = coin->avetime; threshold *= 100. * sqrt(threshold) * .000777;*/ + /*for (i=n=0; in; i++) + { + if ( lag < coin->MAXSTUCKTIME ) + { + if ( bits256_nonz(bp->hashes[i]) != 0 ) + iguana_blockQ("stuck",coin,bp,i,bp->hashes[i],0); + } + if ( (block= bp->blocks[i]) != 0 && block->fpipbits == 0 && bp->speculativecache[i] == 0 ) + { + printf("s.[%d:%d] ",bp->hdrsi,i); + iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,0); + iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1); + if ( coin->peers.numranked > 8 && (addr= coin->peers.ranked[n % 8]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack != 0 ) + { + if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&block->RO.hash2,1)) > 0 ) + { + printf("%s, ",addr->ipaddr); + iguana_send(coin,addr,serialized,len); + } + } + block->issued = (uint32_t)time(NULL); + n++; + } + } + if ( n > 0 ) + printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag);*/ #endif diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 1717e3aaa..2dfbdb6e0 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -496,6 +496,7 @@ struct iguana_info struct iguana_blocks blocks; bits256 APIblockhash,APItxid; char *APIblockstr; struct iguana_waccount *wallet; struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048]; + double txidfind_totalmillis,txidfind_num; }; struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; }; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 9e34cfccb..76659d30b 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -742,7 +742,7 @@ int32_t iguana_bundlefinalize(struct iguana_info *coin,struct iguana_bundle *bp, int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_bundle *bp,int32_t timelimit,int32_t lag) { - int32_t range,starti,lasti,avail,n,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp; uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; struct iguana_blockreq *breq; + int32_t range,starti,lasti,tmp,tmp2,n,retval=0,max,counter = 0; struct iguana_bundle *currentbp,*lastbp; uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; struct iguana_blockreq *breq; //serialized[512], if ( coin->started == 0 || coin->active == 0 ) { @@ -809,41 +809,15 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru if ( (lag/coin->MAXSTUCKTIME) > coin->stuckiters ) { coin->stuckiters = (int32_t)(lag/coin->MAXSTUCKTIME); - if ( 0 && lag > coin->MAXSTUCKTIME ) + if ( lag > 2*coin->MAXSTUCKTIME ) { while ( (breq= queue_dequeue(&coin->blocksQ,0)) != 0 ) myfree(breq,sizeof(*breq)); while ( (breq= queue_dequeue(&coin->priorityQ,0)) != 0 ) myfree(breq,sizeof(*breq)); } - n = iguana_blocksmissing(coin,&avail,missings,0,bp,bp->n,3); - printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag); - /*for (i=n=0; in; i++) - { - if ( lag < coin->MAXSTUCKTIME ) - { - if ( bits256_nonz(bp->hashes[i]) != 0 ) - iguana_blockQ("stuck",coin,bp,i,bp->hashes[i],0); - } - if ( (block= bp->blocks[i]) != 0 && block->fpipbits == 0 && bp->speculativecache[i] == 0 ) - { - printf("s.[%d:%d] ",bp->hdrsi,i); - iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,0); - iguana_blockQ("stuck",coin,bp,i,block->RO.hash2,1); - if ( coin->peers.numranked > 8 && (addr= coin->peers.ranked[n % 8]) != 0 && addr->usock >= 0 && addr->dead == 0 && addr->msgcounts.verack != 0 ) - { - if ( (len= iguana_getdata(coin,serialized,MSG_BLOCK,&block->RO.hash2,1)) > 0 ) - { - printf("%s, ",addr->ipaddr); - iguana_send(coin,addr,serialized,len); - } - } - block->issued = (uint32_t)time(NULL); - n++; - } - } - if ( n > 0 ) - printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag);*/ + if ( (n= iguana_bundlerequests(coin,missings,&tmp,&tmp2,bp,30,3)) > 0 ) + printf("issued %d priority requests [%d] to unstick stuckiters.%d lag.%d\n",n,bp->hdrsi,coin->stuckiters,lag); } } } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 05fdf5b33..4bdd90efb 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -444,23 +444,23 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre *unspentindp = unspentind; if ( unspentind == 0 ) { - double duration,startmillis = OS_milliseconds(); static double totalmillis; static int32_t num; + double duration,startmillis = OS_milliseconds(); if ( (tp= iguana_txidfind(coin,&height,&TX,prev_hash,spent_hdrsi-1)) != 0 ) { *unspentindp = unspentind = TX.firstvout + ((prev_vout > 0) ? prev_vout : 0); hdrsi = height / coin->chain->bundlesize; //printf("%s height.%d firstvout.%d prev.%d ->U%d\n",bits256_str(str,prev_hash),height,TX.firstvout,prev_vout,unspentind); duration = (OS_milliseconds() - startmillis); - totalmillis += duration; - num++; - if ( coin->PREFETCHLAG != 0 && duration > (coin->PREFETCHLAG * totalmillis)/num ) + coin->txidfind_totalmillis += duration; + coin->txidfind_num += 1.; + if ( coin->PREFETCHLAG != 0 && duration > (coin->PREFETCHLAG * coin->txidfind_totalmillis)/coin->txidfind_num ) { - printf("slow txidfind %.2f vs %.2f prefetch[%d] from.[%d] lag.%ld\n",duration,totalmillis/num,spentbp->hdrsi,ramchain->H.data->height/coin->chain->bundlesize,time(NULL) - spentbp->lastprefetch); + printf("slow txidfind %.2f vs %.2f prefetch[%d] from.[%d] lag.%ld\n",duration,coin->txidfind_totalmillis/coin->txidfind_num,spentbp->hdrsi,ramchain->H.data->height/coin->chain->bundlesize,time(NULL) - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); spentbp->lastprefetch = (uint32_t)time(NULL); } - if ( (num % 1000000) == 0 ) - printf("iguana_txidfind.[%d] ave %.2f micros, total %.2f seconds\n",num,(totalmillis*1000.)/num,totalmillis/1000.); + if ( ((uint64_t)coin->txidfind_num % 1000000) == 0 ) + printf("iguana_txidfind.[%.0f] ave %.2f micros, total %.2f seconds\n",coin->txidfind_num,(coin->txidfind_totalmillis*1000.)/coin->txidfind_num,coin->txidfind_totalmillis/1000.); } else {