From d083888243761669ee5d1d15458073dad05b2ace Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 20 Apr 2016 22:32:54 -0500 Subject: [PATCH] test --- iguana/iguana777.c | 11 ++++++++++- iguana/iguana777.h | 1 + iguana/iguana_unspents.c | 27 ++++++--------------------- 3 files changed, 17 insertions(+), 22 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index e8487ba66..350c7d0b1 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -410,7 +410,7 @@ int32_t iguana_helperB(struct iguana_info *coin,int32_t helperid,struct iguana_b int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convertflag) { - int32_t hdrsi,n,max,incr,num = 0; struct iguana_bundle *bp; + int32_t hdrsi,n,i,max,incr,num = 0; struct iguana_bundle *bp; if ( coin->spendvectorsaved > 1 ) { printf("skip utxogen as spendvectorsaved.%u\n",coin->spendvectorsaved); @@ -449,6 +449,9 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert if ( coin->origbalanceswritten <= 1 ) hdrsi = 0; else hdrsi = coin->origbalanceswritten; + for (i=0; ibundles[i]) != 0 ) + iguana_volatilesalloc(coin,&bp->ramchain,i < hdrsi); for (; hdrsibundles[hdrsi]->ramchain,3); @@ -463,6 +466,12 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert coin->balanceswritten = max; coin->balanceflush = coin->balanceswritten; } + for (i=0; ibundles[i]) != 0 ) + { + iguana_volatilespurge(coin,&bp->ramchain); + iguana_volatilesmap(coin,&bp->ramchain); + } } else printf("error saving spendvectors\n"); } //printf("helper.%d check validates\n",helperid); diff --git a/iguana/iguana777.h b/iguana/iguana777.h index cfb119a06..fe7b2827e 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -886,6 +886,7 @@ bits256 iguana_merkle(struct iguana_info *coin,bits256 *tree,int32_t txn_count); int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int32_t requiredflag); int32_t iguana_blast(struct iguana_info *coin,struct iguana_peer *addr); int32_t iguana_validated(struct iguana_info *coin); +void iguana_volatilesalloc(struct iguana_info *coin,struct iguana_ramchain *ramchain,int32_t copyflag); extern int32_t HDRnet,netBLOCKS; diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 39e2dac69..359f9592b 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -304,11 +304,11 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc struct iguana_account *A2; struct iguana_ramchaindata *rdata; struct iguana_utxo *utxo; if ( (rdata= spentchain->H.data) != 0 ) { - if ( spentchain->allocatedA == 0 || spentchain->allocatedU == 0 ) + /*if ( spentchain->allocatedA == 0 || spentchain->allocatedU == 0 ) { iguana_volatilesalloc(coin,spentchain,1); fprintf(stderr,"volatilesalloc.[%d] ",spent_hdrsi); - } + }*/ if ( incremental == 0 ) { if ( spentchain->Uextras != 0 && (A2= spentchain->A) != 0 ) @@ -1217,11 +1217,6 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig emit = startemit; if ( coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight ) fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit); - if ( starti == 0 && endi == bp->n-1 && ramchain->A != 0 && ramchain->Uextras != 0 ) - { - iguana_volatilespurge(coin,ramchain); - iguana_volatilesalloc(coin,ramchain,0); - } for (i=starti; i<=endi; i++) { now = (uint32_t)time(NULL); @@ -1344,7 +1339,6 @@ int32_t iguana_volatilesinit(struct iguana_info *coin) struct sha256_vstate vstate,bstate; int32_t i,from_ro,numpkinds,numunspents; struct iguana_bundle *bp; struct iguana_block *block; uint32_t crc,filecrc; FILE *fp; char crcfname[512],str[65],str2[65],buf[2048]; from_ro = 1; - //printf("start volatilesinit\n"); for (i=0; ibalanceswritten; i++) { if ( (bp= coin->bundles[i]) == 0 ) @@ -1357,7 +1351,6 @@ int32_t iguana_volatilesinit(struct iguana_info *coin) if ( bp->ramchain.from_ro == 0 || bp->ramchain.from_roX == 0 || bp->ramchain.from_roA == 0 || bp->ramchain.from_roU == 0 ) from_ro = 0; } - //printf("volatiles i.%d\n",i); if ( i < coin->balanceswritten ) { printf("TRUNCATE balances written.%d -> %d\n",coin->balanceswritten,i); @@ -1726,10 +1719,6 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s } else { - /*if ( vec->fromheight >= coin->current->bundleheight ) - { - printf("inside [%d] RT.%d spends vec.([%d] u%d p%d) tmp.%d\n",spentbp->hdrsi,vec->fromheight,vec->hdrsi,vec->unspentind,vec->pkind,vec->tmpflag); - }*/ if ( _iguana_spendvectorconv(vec,&spentU[vec->unspentind],numpkinds,vec->hdrsi,vec->unspentind) != 0 ) converted++; else @@ -1738,10 +1727,6 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s return(-1); } } - /*if ( vec->fromheight >= coin->current->bundleheight ) - { - printf("outside [%d] RT.%d spends vec.([%d] u%d p%d) tmp.%d\n",spentbp->hdrsi,vec->fromheight,vec->hdrsi,vec->unspentind,vec->pkind,vec->tmpflag); - }*/ } } } @@ -1827,7 +1812,7 @@ void *iguana_ramchainfile(struct iguana_info *coin,struct iguana_ramchain *dest, void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_bundle *bp) { - uint32_t i,hdrsi,changed = 0; struct iguana_ramchaindata *rdata; struct iguana_ramchain *dest = &coin->RTramchain; struct iguana_blockRO *B; struct iguana_bundle *tmpbp; + uint32_t i,changed = 0; struct iguana_ramchaindata *rdata; struct iguana_ramchain *dest = &coin->RTramchain; struct iguana_blockRO *B; if ( (rdata= dest->H.data) != 0 ) { i = 0; @@ -1859,7 +1844,7 @@ void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_b dest->H.txidind = dest->H.unspentind = dest->H.spendind = dest->pkind = dest->H.data->firsti; dest->externalind = dest->H.stacksize = 0; dest->H.scriptoffset = 1; - for (hdrsi=0; hdrsi<=bp->hdrsi; hdrsi++) + /*for (hdrsi=0; hdrsi<=bp->hdrsi; hdrsi++) { if ( (tmpbp= coin->bundles[hdrsi]) != 0 ) { @@ -1867,7 +1852,7 @@ void iguana_RTramchainalloc(char *fname,struct iguana_info *coin,struct iguana_b iguana_volatilesmap(coin,&tmpbp->ramchain); iguana_volatilesalloc(coin,&tmpbp->ramchain,hdrsi < bp->hdrsi); } - } + }*/ } } @@ -1934,7 +1919,7 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp) num += iguana_convert(coin,IGUANA_NUMHELPERS,coin->bundles[hdrsi],1,orignumemit); printf("spendvectors converted.%d to %d\n",num,coin->RTheight); bp->converted = (uint32_t)time(NULL); - if ( iguana_balancegen(coin,0,bp,coin->RTstarti,coin->RTheight > 0 ? coin->RTheight-1 : bp->n-1,orignumemit) < 0 ) + if ( iguana_balancegen(coin,1,bp,coin->RTstarti,coin->RTheight > 0 ? coin->RTheight-1 : bp->n-1,orignumemit) < 0 ) coin->RTdatabad = 1; //printf("iguana_balancegen [%d] (%d to %d)\n",bp->hdrsi,coin->RTstarti,(coin->RTheight-1)%bp->n); coin->RTstarti = (coin->RTheight % bp->n);