From a02e289af07fa92d11a0160ee0b20ae382e0f3f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Jan 2016 15:06:54 -0300 Subject: [PATCH] test --- iguana/iguana_bundles.c | 9 +++++++-- iguana/iguana_recv.c | 13 +++++++++---- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 9180029f4..101c09645 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -562,7 +562,12 @@ void iguana_bundlestats(struct iguana_info *coin,char *str) void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) { - int32_t i,n; uint32_t now; struct iguana_block *block; double endmillis = OS_milliseconds() + timelimit; + int32_t i,n,pend; uint32_t now; struct iguana_block *block; double endmillis; + for (i=pend=0; ipeers.active[i].pendblocks; + if ( pend >= coin->MAXPENDING*coin->MAXPEERS ) + return; + endmillis = OS_milliseconds() + timelimit; printf("ITERATE bundle.%d n.%d r.%d s.%d finished.%d\n",bp->bundleheight,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish); memset(bp->issued,0,sizeof(bp->issued)); while ( bp->emitfinish == 0 && OS_milliseconds() < endmillis ) @@ -575,7 +580,7 @@ void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_ if ( block->queued == 0 && block->fpipbits == 0 && bp->issued[i] == 0 ) { //printf("(%d:%d) ",bp->hdrsi,i); - iguana_blockQ(coin,bp,i,block->RO.hash2,0); + iguana_blockQ(coin,bp,i,block->RO.hash2,bp->numsaved > bp->n-10); bp->issued[i] = now; } else if ( block->fpipbits != 0 ) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 07f0bc555..9f756a7c4 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -310,7 +310,7 @@ uint32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bit } //printf("ALLHASHES FOUND! %d requested.%d\n",bp->bundleheight,n); bp->queued = (uint32_t)time(NULL); - iguana_bundleQ(coin,bp,1000); + iguana_bundleQ(coin,bp,5000); return(bp->queued); } } @@ -685,8 +685,7 @@ 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 m,z; struct iguana_bundle *bp; - int32_t limit,height=-1,bundlei,datalen,flag = 0; + struct iguana_bundle *bp; struct iguana_peer *ptr; int32_t i,m,z,pend,limit,height=-1,bundlei,datalen,flag = 0; if ( addr->msgcounts.verack == 0 ) return(0); now = (uint32_t)time(NULL); @@ -740,7 +739,13 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) if ( addr->rank != 1 && req == 0 && addr->pendblocks < limit ) { priority = 0; - req = queue_dequeue(&coin->blocksQ,0); + for (i=m=pend=0; ipeers.numranked; i++) + { + if ( (ptr= coin->peers.ranked[i]) != 0 && ptr->msgcounts.verack > 0 ) + pend += ptr->pendblocks, m++; + } + if ( pend < _IGUANA_MAXPENDING*m ) + req = queue_dequeue(&coin->blocksQ,0); } else priority = 1; if ( req != 0 ) {