diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 96c4001a9..0ee952e5a 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 3 -#define IGUANA_MINPENDBUNDLES 64 -#define IGUANA_MAXPENDBUNDLES 64 +#define IGUANA_MINPENDBUNDLES 8 +#define IGUANA_MAXPENDBUNDLES 32 #define IGUANA_BUNDLELOOP 77 #define IGUANA_RPCPORT 7778 #define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 9ca59c3ef..b64b8183d 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -723,7 +723,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru lasti = lastbp == 0 ? coin->bundlescount-1 : lastbp->hdrsi; coin->numbundlesQ--; iguana_bundlecalcs(coin,bp); - printf("ITERATE.%d bundle.%d h.%d n.%d r.%d s.%d F.%d T.%d counter.%d\n",bp->rank,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter); + //printf("ITERATE.%d bundle.%d h.%d n.%d r.%d s.%d F.%d T.%d counter.%d\n",bp->rank,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter); if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) iguana_bundlehdr(coin,bp,starti); else if ( bp->emitfinish != 0 ) diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 38a53ae7b..7deaf1675 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1790,14 +1790,14 @@ long iguana_ramchain_data(struct iguana_info *coin,struct iguana_peer *addr,stru struct iguana_bundle *bp = 0; struct iguana_block *block; uint32_t scriptspace,stackspace; totalrecv += recvlen; if ( bits256_nonz(origtxdata->block.RO.merkle_root) == 0 ) - return(-1); - for (i=0; idirty)/sizeof(*addr->dirty); i++) { memset(&origtxdata->block.RO.prev_block,0,sizeof(bits256)); origtxdata->block.RO.recvlen = 0; origtxdata->block.issued = 0; - addr->dirty[i] = 0; + return(-1); } + for (i=0; idirty)/sizeof(*addr->dirty); i++) + addr->dirty[i] = 0; msize = (int32_t)sizeof(bits256) * (txn_count+1) * 2; if ( msize <= addr->TXDATA.totalsize ) { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index a4b64689a..e53879bea 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -189,8 +189,8 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i { printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->block.RO.hash2)); return; - } //else printf("validated.%s\n",bits256_str(str,origtxdata->block.RO.hash2)); - copyflag = 1 * (strcmp(coin->symbol,"BTC") != 0); + } //else printf("validated prev.%s\n",bits256_str(str,origtxdata->block.RO.prev_block)); + copyflag = 0 * (strcmp(coin->symbol,"BTC") != 0); bp = 0, bundlei = -2; if ( copyflag != 0 && recvlen != 0 && ((bp= iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2)) == 0 || (bp->blocks[bundlei] != 0 && bp->blocks[bundlei]->fpipbits == 0)) ) { @@ -203,17 +203,6 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i copyflag = 0; req = iguana_bundlereq(coin,addr,'B',0); } - if ( bp == 0 ) - { - bp = 0, bundlei = -2; - bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.prev_block); - if ( bp != 0 && bundlei < bp->n-1 ) - { - bundlei++; - bp->hashes[bundlei] = origtxdata->block.RO.hash2; - } - else bp = 0, bundlei = -2; - } if ( bp != 0 && bundlei >= 0 && bp->blocks[bundlei] != 0 )//&& bits256_cmp(bp->blocks[bundlei]->RO.prev_block,origtxdata->block.RO.prev_block) != 0 ) { if ( bp->blocks[bundlei]->fpos >= 0 && bp->blocks[bundlei]->fpipbits != 0 && bp->blocks[bundlei]->txvalid != 0 ) @@ -263,8 +252,8 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i }*/ } } - //printf("recvlen.%d\n",req->recvlen); req->block = txdata->block; + //printf("recvlen.%d prev.(%s)\n",req->recvlen,bits256_str(str,txdata->block.RO.prev_block)); req->block.RO.txn_count = req->numtx = txdata->block.RO.txn_count; coin->recvcount++; coin->recvtime = (uint32_t)time(NULL); @@ -666,10 +655,31 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundlereq *req,struct iguana_block *origblock,int32_t numtx,int32_t datalen,int32_t recvlen,int32_t *newhwmp) { - struct iguana_bundle *bp=0; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; - bp = iguana_bundleset(coin,&block,&bundlei,origblock); - char str[65]; - //if ( 1 && bp != 0 && bp->hdrsi == coin->bundlescount-1 ) + struct iguana_bundle *bp=0; int32_t i,numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; char str[65]; + if ( (bp= iguana_bundleset(coin,&block,&bundlei,origblock)) == 0 ) + { + for (i=coin->bundlescount-1; i>=0; i--) + { + //if ( coin->bundles[i] != 0 ) + // printf("compare vs %s\n",bits256_str(str,coin->bundles[i]->hashes[0])); + if ( coin->bundles[i] != 0 && bits256_cmp(origblock->RO.prev_block,coin->bundles[i]->hashes[0]) == 0 ) + { + bp = coin->bundles[i]; + bundlei = 1; + iguana_bundlehash2add(coin,&block,bp,bundlei,origblock->RO.hash2); + printf("[%d] bundlehashadd set.%d block.%p\n",i,bundlei,block); + if ( block != 0 ) + { + bp->blocks[bundlei] = block; + block->bundlei = bundlei; + block->hdrsi = bp->hdrsi; + } + break; + } + } + printf("i.%d ref prev.(%s)\n",i,bits256_str(str,origblock->RO.prev_block)); + } + if ( 0 && bp != 0 && bp->hdrsi == coin->bundlescount-1 ) { int32_t i; static int32_t numrecv; numrecv++; diff --git a/iguana/main.c b/iguana/main.c index 51af47534..15a933d3e 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -344,7 +344,7 @@ void mainloop(struct supernet_info *myinfo) { if ( bp->utxofinish != 0 && bp->balancefinish <= 1 && (bp->hdrsi == 0 || (prevbp != 0 && prevbp->utxofinish != 0)) ) { - printf("hdrsi.%d start balances.%d\n",bp->hdrsi,bp->bundleheight); + //printf("hdrsi.%d start balances.%d\n",bp->hdrsi,bp->bundleheight); iguana_balancecalc(ptr->coin,bp); bp->queued = 0; }