diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 76b3f34db..7028aee34 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -347,7 +347,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp) int32_t spendind,n,errs=0,emit=0; uint32_t unspentind,pkind,txidind; 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; int32_t hdrsi; - uint32_t numtxid,now,h,refheight; struct iguana_utxo *utxo; + uint32_t numtxid,now,h,refheight; struct iguana_utxo *utxo,*Uextras; ramchain = &bp->ramchain; //printf("BALANCEGEN.%d\n",bp->bundleheight); if ( ramchain->H.data == 0 || (n= ramchain->H.data->numspends) < 1 ) @@ -420,15 +420,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp) now = (uint32_t)time(NULL); if ( spentbp != 0 && unspentind > 0 && unspentind < spentbp->ramchain.H.data->numunspents ) { - if ( spentbp->ramchain.Uextras == 0 ) - { - spentbp->ramchain.Uextras = calloc(sizeof(*spentbp->ramchain.Uextras),spentbp->ramchain.H.data->numunspents + 16); - } - if ( spentbp->ramchain.A == 0 ) - { - spentbp->ramchain.A = calloc(sizeof(*spentbp->ramchain.A),spentbp->ramchain.H.data->numpkinds + 16); - } - if ( spentbp->ramchain.Uextras == 0 || (A2= spentbp->ramchain.A) == 0 ) + if ( (Uextras= spentbp->ramchain.Uextras) == 0 || (A2= spentbp->ramchain.A) == 0 ) { printf("null ptrs %p %p\n",spentbp->ramchain.Uextras,spentbp->ramchain.A); errs++; @@ -439,7 +431,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,struct iguana_bundle *bp) u = &spentU[unspentind]; if ( (pkind= u->pkind) != 0 && pkind < spentbp->ramchain.H.data->numpkinds ) { - utxo = &spentbp->ramchain.Uextras[unspentind]; + utxo = &Uextras[unspentind]; if ( utxo->spentflag == 0 ) { utxo->prevspendind = A2[pkind].lastind; diff --git a/iguana/main.c b/iguana/main.c index 333231bfe..8b0137dc7 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -342,6 +342,19 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t pu { for (hdrsi=0; hdrsibundles[hdrsi]) == 0 || bp->ramchain.H.data == 0 ) + { + printf("balance flush null bp[%d]??\n",hdrsi); + exit(-1); + } + if ( bp->ramchain.Uextras == 0 ) + { + bp->ramchain.Uextras = calloc(sizeof(*bp->ramchain.Uextras),bp->ramchain.H.data->numunspents + 16); + } + if ( bp->ramchain.A == 0 ) + { + bp->ramchain.A = calloc(sizeof(*bp->ramchain.A),bp->ramchain.H.data->numpkinds + 16); + } Aptr = 0; Uptr = 0; numunspents = 0; @@ -368,7 +381,7 @@ int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t pu { bp->dirty = 0; err = 0; - printf("saved (%s) and (%s)\n",fname,fname2); + printf("[%d] of %d saved (%s) and (%s)\n",hdrsi,numhdrsi,fname,fname2); } } }