diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 3daef4853..76534766d 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -432,7 +432,7 @@ struct iguana_bundle { struct queueitem DL; struct iguana_info *coin; struct iguana_bundle *nextbp; struct iguana_bloom16 bloom; int64_t totaldurations,duplicatedurations; int32_t durationscount,duplicatescount; - uint32_t issuetime,hdrtime,emitfinish,mergefinish,purgetime,queued,startutxo,utxofinish,balancefinish,validated,lastspeculative,dirty,nexttime,currenttime,lastprefetch,lastRT,missingstime; + uint32_t issuetime,hdrtime,emitfinish,mergefinish,purgetime,queued,startutxo,utxofinish,balancefinish,validated,lastspeculative,dirty,nexttime,currenttime,lastprefetch,lastRT,missingstime,unsticktime; int32_t numhashes,numrecv,numsaved,numcached,generrs,currentflag,origmissings,numissued; int32_t minrequests,n,hdrsi,bundleheight,numtxids,numspends,numunspents,numspec,isRT; double avetime,threshold,metric; uint64_t datasize,estsize; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index c3cbfd167..a1febe05e 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -919,9 +919,24 @@ int32_t iguana_cacheprocess(struct iguana_info *coin,struct iguana_bundle *bp,in return(-1); } +void iguana_unstickhdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t lag) +{ + int32_t datalen,m; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr; + if ( (m= coin->peers.numranked) > 0 && bp->numhashes < bp->n && bp->hdrsi < coin->longestchain/coin->chain->bundlesize && time(NULL) > bp->unsticktime+lag ) + { + if ( (addr= coin->peers.ranked[rand() % m]) != 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 ) + { + printf("UNSTICK HDR.[%d]\n",bp->hdrsi); + iguana_send(coin,addr,serialized,datalen); + addr->pendhdrs++; + bp->unsticktime = (uint32_t)time(NULL); + } + } +} + double iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,double aveduration,int32_t lag) { - uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t tmp,m,dist=0,missing,priority,avail,n=0,max; double aveduplicates; //bits256 hash2; + uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t tmp,dist=0,missing,priority,avail,n=0,max; double aveduplicates; //bits256 hash2; missing = iguana_blocksmissing(coin,&avail,missings,0,bp,0,lag); priority = (strcmp("BTC",coin->symbol) != 0) * 2; lag = IGUANA_DEFAULTLAG; @@ -932,16 +947,7 @@ double iguana_bundlemissings(struct iguana_info *coin,struct iguana_bundle *bp,d { if ( (dist= bp->hdrsi - coin->current->hdrsi) < coin->MAXBUNDLES ) { - if ( (m= coin->peers.numranked) > 0 && bp->numcached < bp->n && bp->hdrsi < coin->longestchain/coin->chain->bundlesize ) - { - int32_t datalen; uint8_t serialized[512]; char str[65]; struct iguana_peer *addr; - if ( (addr= coin->peers.ranked[rand() % m]) != 0 && (datalen= iguana_gethdrs(coin,serialized,coin->chain->gethdrsmsg,bits256_str(str,bp->hashes[0]))) > 0 ) - { - printf("UNSTICK HDR.[%d]\n",bp->hdrsi); - iguana_send(coin,addr,serialized,datalen); - addr->pendhdrs++; - } - } + iguana_unstickhdr(coin,bp,60); if ( bp->numcached > bp->n - (coin->MAXBUNDLES - dist) ) priority += 1 + (bp == coin->current); if ( bp == coin->current || queue_size(&coin->priorityQ) < (coin->MAXBUNDLES * bp->n)/(dist*dist+1) ) @@ -1131,8 +1137,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str,int32_t lag) if ( (lag/coin->MAXSTUCKTIME) > coin->stuckiters ) { printf("UNSTICK\n"); - if ( bp->numhashes < bp->n ) - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); + iguana_unstickhdr(coin,bp,6); coin->stuckiters = (int32_t)(lag/coin->MAXSTUCKTIME); if ( coin->stuckiters > 2 ) {