diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 7fb4afd16..9004491d2 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -787,7 +787,7 @@ int32_t iguana_vinscriptparse(struct iguana_info *coin,struct vin_info *vp,uint3 void iguana_parsebuf(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_msghdr *H,uint8_t *buf,int32_t len); int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp); 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 incremental); +int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight); 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); diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index bb1f1740e..49389096c 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -976,6 +976,8 @@ int32_t iguana_reqblocks(struct iguana_info *coin) if ( coin->blocks.hwmchain.height >= coin->longestchain-1 ) threshold = 1000; else threshold = 300; + if ( strcmp(coin->symbol,"BTC") != 0 ) + threshold *= 10; if ( coin->blocks.hwmchain.height < coin->longestchain && ((strcmp(coin->symbol,"BTC") != 0 && coin->backstop != coin->blocks.hwmchain.height+1) || lag > threshold) ) { coin->backstop = coin->blocks.hwmchain.height+1; @@ -1005,7 +1007,7 @@ int32_t iguana_reqblocks(struct iguana_info *coin) iguana_blockQ("mainchain",coin,0,-1,hash2,lag > 100 * threshold); flag++; char str[65]; - if ( 1 && (rand() % 1000) == 0 || bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) + if ( 1 && (rand() % 1000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) printf("%s %s MAINCHAIN.%d threshold %.3f %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,coin->backstopmillis,lag); } else if ( bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 08416627b..b72d8a5bc 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -332,7 +332,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,struct iguana_bundle *bp) { if ( (spentbp= iguana_spent(coin,&prevhash,&unspentind,ramchain,bp->hdrsi,s)) != 0 ) { - if ( now > spentbp->lastprefetch+30 || (spentbp->dirty % 100000) == 0 ) + if ( now > spentbp->lastprefetch+20 || (spentbp->dirty % 50000) == 0 ) { //printf("u current.%d prefetch.[%d] lag.%u\n",spentbp == bp,spentbp->hdrsi,now - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); @@ -407,15 +407,18 @@ int32_t iguana_utxogen(struct iguana_info *coin,struct iguana_bundle *bp) return(-errs); } -int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int32_t incremental) +int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight) { - uint32_t unspentind,pkind,txidind; struct iguana_account *A2; + uint32_t unspentind,pkind,txidind,numtxid,now=0,h,refheight; struct iguana_account *A2; struct iguana_unspent *u,*spentU; struct iguana_spend *S,*s; struct iguana_ramchain *ramchain; - struct iguana_bundle *spentbp; struct iguana_txid *T,*nextT; uint32_t numtxid,now=0,h,refheight; - int32_t flag,hdrsi,spendind,n,errs=0,emit=0; struct iguana_utxo *utxo,*Uextras; + struct iguana_bundle *spentbp; struct iguana_txid *T,*nextT; + int32_t flag,hdrsi,spendind,n,errs=0,incremental,emit=0; struct iguana_utxo *utxo,*Uextras; ramchain = &bp->ramchain; Uextras = 0; A2 = 0; + if ( startheight == bp->bundleheight && endheight == bp->bundleheight+bp->n-1 ) + incremental = 0; + else incremental = 1; if ( ramchain->H.data == 0 || (n= ramchain->H.data->numspends) < 1 ) return(0); S = (void *)(long)((long)ramchain->H.data + ramchain->H.data->Soffset); @@ -436,6 +439,10 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3 //printf("height.%d firstvin.%d\n",height,nextT[numtxid].firstvin); numtxid++; } + if ( refheight < startheight ) + continue; + if ( refheight > endheight ) + break; s = &S[spendind]; u = 0; unspentind = 0; @@ -488,7 +495,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp,int3 now = (uint32_t)time(NULL); if ( spentbp != 0 && unspentind > 0 && unspentind < spentbp->ramchain.H.data->numunspents ) { - if ( now > spentbp->lastprefetch+30 || (spentbp->dirty % 100000) == 0 ) + if ( now > spentbp->lastprefetch+20 || (spentbp->dirty % 50000) == 0 ) { //printf("current.%d prefetch.[%d] lag.%u\n",spentbp == bp,spentbp->hdrsi,now - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); @@ -817,7 +824,7 @@ int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int starttime = (uint32_t)time(NULL); for (j=0; j<=bp->hdrsi; j++) iguana_allocvolatile(coin,&coin->bundles[j]->ramchain); - if ( iguana_balancegen(coin,bp,incremental) < 0 ) + if ( iguana_balancegen(coin,bp,bp->bundleheight,bp->bundleheight+bp->n-1) < 0 ) { printf("GENERATE BALANCES ERROR ht.%d\n",bp->bundleheight); exit(-1);