From 1d26b2b9c6f0525a46f76deb39b4dbd28fd42828 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 13 Mar 2016 19:23:35 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 8 ++++++-- iguana/iguana_bundles.c | 3 +-- iguana/iguana_recv.c | 33 ++++++++++++++++++++++++--------- 3 files changed, 31 insertions(+), 13 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index c143fc8db..71ff2a838 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -38,8 +38,8 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t #define IGUANA_TAILPERCENTAGE 1.0 #define IGUANA_MAXPENDHDRS 1 #define _IGUANA_MAXPENDING 8 -#define IGUANA_MINPENDBUNDLES 200 -#define IGUANA_MAXPENDBUNDLES 128 +#define IGUANA_MINPENDBUNDLES 128 +#define IGUANA_MAXPENDBUNDLES 64 #define IGUANA_BUNDLELOOP 10000 #define IGUANA_RPCPORT 7778 #define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16) @@ -413,6 +413,7 @@ struct iguana_peers }; struct iguana_bloom16 { uint8_t hash2bits[65536 / 8]; }; +struct iguana_bloominds { uint16_t inds[8]; }; struct iguana_bundle { @@ -789,6 +790,9 @@ int32_t iguana_utxogen(struct iguana_info *coin,struct iguana_bundle *bp); int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp); int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp); +struct iguana_bloominds iguana_calcbloom(bits256 hash2); +int32_t iguana_bloomfind(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit); +struct iguana_bloominds iguana_bloomset(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit); extern queue_t bundlesQ,validateQ; extern char GLOBALTMPDIR[]; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 5bb8d49be..5794b6d45 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -17,7 +17,6 @@ static uint16_t iguana_primes[] = { 65353, 65357, 65371, 65381, 65393, 65407, 65413, 65419, 65423, 65437, 65447, 65449, 65479, 65497, 65519, 65521 }; -struct iguana_bloominds { uint16_t inds[8]; }; struct iguana_bloominds iguana_calcbloom(bits256 hash2) { @@ -380,7 +379,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp,int { if ( block == iguana_blockfind(coin,bp->hashes[bundlei]) ) { - if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,bp->hashes[bundlei],zero,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) + if ( (checki= iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,bp->hashes[bundlei],bundlei>0?bp->hashes[bundlei-1]:zero,1)) != bundlei || bundlei < 0 || bundlei >= coin->chain->bundlesize ) { printf("iguana_bundlecalcs.(%s) illegal hdrsi.%d bundlei.%d checki.%d\n",fname,hdrsi,bundlei,checki); continue; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 17d1e8825..a531ad011 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -453,6 +453,9 @@ int32_t iguana_bundlekick(struct iguana_info *coin,struct iguana_bundle *bp,int3 int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) { int32_t i,range,starti,numhashes,issued,valid,max,counter = 0; struct iguana_block *block; double endmillis,width; struct iguana_bundle *prevbp; uint32_t starttime; + if ( (range= coin->peers.numranked) > coin->MAXBUNDLES ) + range = coin->MAXBUNDLES; + starti = coin->current == 0 ? 0 : coin->current->hdrsi; coin->numbundlesQ--; for (i=numhashes=0; in; i++) numhashes += bits256_nonz(bp->hashes[i]); @@ -474,8 +477,11 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int printf("SPECULATIVE issue.%d bp.[%d]\n",counter,bp->hdrsi); bp->lastspeculative = (uint32_t)time(NULL); } - iguana_bundleQ(coin,bp,bp->n*5); - return(0); + if ( bp->hdrsi != starti ) + { + iguana_bundleQ(coin,bp,bp->n*5); + return(0); + } } if ( bp->emitfinish != 0 ) { @@ -509,9 +515,6 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int return(0); } //printf("BUNDLEITERS.%d\n",bp->hdrsi); - if ( (range= coin->peers.numranked) > coin->MAXBUNDLES ) - range = coin->MAXBUNDLES; - starti = coin->current == 0 ? 0 : coin->current->hdrsi; if ( bp->hdrsi < starti + range ) { for (i=0; in; i++) @@ -554,7 +557,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int endmillis = OS_milliseconds() + timelimit + (rand() % 1000); if ( bp->numsaved < bp->n ) width = 100 + max*100;//sqrt(sqrt(bp->n * (1+bp->numsaved+issued)) * (10+coin->bundlescount-bp->hdrsi)); - if ( 0 && bp->hdrsi == starti ) + if ( 1 && bp->hdrsi == starti ) printf("ITERATE.%d max.%d bundle.%d h.%d n.%d r.%d s.%d F.%d I.%d T.%d %f %u next %f counter.%d\n",bp->rank,max,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,issued,timelimit,endmillis-OS_milliseconds(),(uint32_t)time(NULL),width,counter); if ( bp->emitfinish == 0 ) { @@ -813,11 +816,14 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana { struct iguana_bundle *bp=0; int32_t bundlei = -2; struct iguana_block *block; bp = iguana_bundleset(coin,&block,&bundlei,origblock); - if ( bp != 0 && bundlei > 0 && bits256_nonz(origblock->RO.prev_block) > 0 && bits256_cmp(origblock->RO.prev_block,bp->hashes[bundlei-1]) != 0 ) + /*if ( bp != 0 && bundlei > 0 && bits256_nonz(origblock->RO.prev_block) > 0 && bits256_cmp(origblock->RO.prev_block,bp->hashes[bundlei-1]) != 0 ) { printf("backfill [%d:%d]\n",bp->hdrsi,bundlei-1); bp->hashes[bundlei-1] = origblock->RO.prev_block; - } + struct iguana_bloominds bit = iguana_calcbloom(origblock->RO.prev_block); + if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) + iguana_bloomset(coin,&bp->bloom,0,bit); + }*/ char str[65]; if ( 0 && bundlei >= 0 ) fprintf(stderr,"blockRECV %s [%d:%d] block.%08x | h.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,bp!=0?bp->numhashes:-1); @@ -1270,7 +1276,10 @@ int32_t iguana_reqblocks(struct iguana_info *coin) if ( iguana_blockfind(coin,bp->speculative[bundlei]) == 0 ) { bp->hashes[bundlei] = bp->speculative[bundlei]; - //printf("speculative next %d\n",coin->blocks.hwmchain.height+1); + struct iguana_bloominds bit = iguana_calcbloom(bp->speculative[bundlei]); + if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) + iguana_bloomset(coin,&bp->bloom,0,bit); + printf("speculative next %d\n",coin->blocks.hwmchain.height+1); iguana_blockQ(coin,0,-1,bp->speculative[bundlei],0); } } @@ -1295,8 +1304,14 @@ int32_t iguana_reqblocks(struct iguana_info *coin) if ( next == 0 && hdrsi < coin->bundlescount && (bp= coin->bundles[hdrsi]) != 0 && (next= bp->blocks[bundlei]) != 0 ) { if ( bits256_nonz(next->RO.prev_block) == 0 ) + { + printf(" next has null prev [%d:%d]\n",bp->hdrsi,bundlei); + iguana_blockQ(coin,bp,bundlei,next->RO.hash2,0); next = 0; + } } + else if ( bits256_nonz(bp->hashes[bundlei]) != 0 ) + iguana_blockQ(coin,bp,bundlei,bp->hashes[bundlei],0); if ( next != 0 ) { //printf("have next %d\n",coin->blocks.hwmchain.height);