diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index b5af971f8..06087f692 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -439,7 +439,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp) bp->emitfinish = 1; iguana_emitQ(coin,bp); } - else bp->metric = (2*bp->n - bp->numsaved - bp->numrecv) * (bp->hdrsi + 1);//sqrt((sqrt(fabs(bp->estsize - bp->datasize)) * (bp->n - bp->numsaved)) * (bp->hdrsi + 1)); + else bp->metric = (2*bp->n - bp->numsaved - bp->numrecv);// * (bp->hdrsi + 1);//sqrt((sqrt(fabs(bp->estsize - bp->datasize)) * (bp->n - bp->numsaved)) * (bp->hdrsi + 1)); } //printf("%f ",bp->metric); return(bp->estsize); diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 1c5c51277..a3edf8ac2 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -1000,7 +1000,7 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr) usleep(100000); } else if ( addr->rank != 1 ) - usleep(coin->polltimeout*100 + (rand() % (coin->polltimeout*100))); + usleep(coin->polltimeout*100 + 0*(rand() % (coin->polltimeout*100))); else usleep(100 + coin->polltimeout*1000); } else run >>= 2; } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 880ff8010..1bfb13f33 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -683,8 +683,10 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) { uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; char *hashstr=0; bits256 hash2; uint32_t now; struct iguana_block *block; struct iguana_blockreq *req=0; - int32_t i,r,diff,j,k,n,m; double metric,bestmetric = -1.; struct iguana_bundle *bp,*bestbp = 0; + int32_t i,r,diff,j,k,n,m,z; double metric,bestmetric = -1.; struct iguana_bundle *bp,*bestbp = 0; int32_t limit,refbundlei,height=-1,incr,bundlei,datalen,flag = 0; double val; + if ( addr->msgcounts.verack == 0 ) + return(0); now = (uint32_t)time(NULL); if ( iguana_needhdrs(coin) != 0 && addr->pendhdrs < IGUANA_MAXPENDHDRS ) { @@ -697,13 +699,26 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) if ( bits256_nonz(hash2) > 0 ) { bp = 0, bundlei = -2; - if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) == 0 || (bp->numhashes < bp->n && bp->bundleheight+coin->chain->bundlesize < coin->longestchain) ) + bp = iguana_bundlefind(coin,&bp,&bundlei,hash2); + z = 0; + if ( bp != 0 ) + { + if ( bp->bundleheight+coin->chain->bundlesize < coin->longestchain ) + { + m = (coin->longestchain - bp->bundleheight); + if ( bp->numhashes < m ) + z = 1; + } + else if ( bp->numhashes < bp->n ) + z = 1; + } + if ( bp == 0 || z != 0 ) { //printf("%s request hdr.(%s) numhashes.%d\n",addr!=0?addr->ipaddr:"local",hashstr,bp->numhashes); iguana_send(coin,addr,serialized,datalen); addr->pendhdrs++; flag++; - } // else printf("skip hdrreq.%d numhashes.%d\n",bp->bundleheight,bp->numhashes); + } else printf("skip hdrreq.%d numhashes.%d\n",bp->bundleheight,bp->numhashes); } free_queueitem(hashstr); return(flag); @@ -712,8 +727,6 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) hashstr = 0; } } - if ( addr->msgcounts.verack == 0 ) - return(0); if ( (limit= addr->recvblocks) > coin->MAXPENDING ) limit = coin->MAXPENDING; if ( limit < 1 )