From cf7ec2d66a94aecd6d9fb2b695299537d32b871d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Mar 2016 23:34:11 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 1 + iguana/iguana_bundles.c | 64 +++++++++++++++++++++++++++++++++++------ iguana/main.c | 4 +-- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 6f6cb8282..19b94dff9 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -797,6 +797,7 @@ void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_coinflush(struct iguana_info *coin,int32_t forceflag); int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti,int32_t max); void iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp); +int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe); extern int32_t HDRnet,netBLOCKS; extern queue_t bundlesQ,validateQ,emitQ,balancesQ; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 473ad0312..cfc80e2e6 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -366,12 +366,14 @@ void iguana_bundlepurge(struct iguana_info *coin,struct iguana_bundle *bp) int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t max,int32_t timelimit) { - int32_t i,j,k,len,numpeers,peercounts[IGUANA_MAXPEERS],counter = 0; struct iguana_peer *addr; uint32_t now; - struct iguana_block *block; bits256 hashes[32]; uint8_t serialized[sizeof(hashes) + 256]; + int32_t i,j,k,r,len,minval,maxval,numpeers,peercounts[IGUANA_MAXPEERS],donecounts[IGUANA_MAXPEERS],counter = 0; + struct iguana_peer *addr; uint32_t now; struct iguana_block *block,*oldest; + bits256 hashes[32]; uint8_t serialized[sizeof(hashes) + 256]; if ( bp == 0 ) return(0); now = (uint32_t)time(NULL); memset(peercounts,0,sizeof(peercounts)); + memset(donecounts,0,sizeof(donecounts)); if ( bp == coin->current ) { if ( bp->numhashes >= bp->n && (numpeers= coin->peers.numranked) > 8 ) @@ -381,7 +383,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int if ( (addr= coin->peers.ranked[j]) != 0 ) { now = (uint32_t)time(NULL); - for (i=j,k=0; in; i+=numpeers) + for (i=j,k=minval=maxval=0; in; i+=numpeers) { if ( bits256_nonz(bp->hashes[i]) != 0 ) { @@ -389,7 +391,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int { if ( block->peerid == 0 ) { - printf("<%d> ",i); + //printf("<%d> ",i); hashes[k++] = bp->hashes[i]; block->issued = now; block->peerid = j + 1; @@ -399,13 +401,16 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int { if ( block->fpipbits == 0 ) { + peercounts[block->peerid - 1]++; + if ( peercounts[block->peerid - 1] > maxval ) + maxval = peercounts[block->peerid - 1]; } else if ( block->fpipbits != 0 && block->fpos >= 0 ) { - //bp->currentflag++; - peercounts[block->peerid]++; + donecounts[block->peerid - 1]++; + if ( donecounts[block->peerid - 1] > minval ) + minval = donecounts[block->peerid - 1]; } - } } } @@ -425,7 +430,48 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int } } } - //printf("currentflag.%d\n",bp->currentflag); + printf("minval.%d maxval.%d\n",minval,maxval); + if ( minval != maxval ) + { + r = rand() % numpeers; + oldest = 0; + for (i=0; in; i+=numpeers) + if ( (block= bp->blocks[i]) != 0 && (oldest == 0 || block->issued < oldest->issued) ) + { + oldest = block; + } + } + } + if ( oldest != 0 ) + { + printf("reissue oldest.%d\n",block->bundlei); + for (i=0; ipeers.ranked[j]) != 0 ) + { + for (i=j; in; i+=numpeers) + { + if ( (block= bp->blocks[i]) != 0 ) + { + printf("send to addr[%d]\n",j); + iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0); + break; + } + } + break; + } + } + } + } + for (i=0; icurrentflag); return(counter); } /*if ( 0 && time(NULL) > bp->lastspeculative+60 ) @@ -648,7 +694,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int } retval = 1; } - else if ( bp->hdrsi <= starti+range ) + else if ( bp->hdrsi > starti && bp->hdrsi <= starti+range ) { max = sqrt(bp->n) - (bp->n/coin->MAXBUNDLES)*(bp->hdrsi - starti); if ( max > 100 ) diff --git a/iguana/main.c b/iguana/main.c index 2be4e0dbd..416aae96a 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -354,9 +354,9 @@ void mainloop(struct supernet_info *myinfo) } else*/ pangea_queues(SuperNET_MYINFO(0)); - usleep(10000); + usleep(1000000); } - else usleep(1000); + else usleep(100000); } }