From 186bdcc9c1d6dea124da172a1814878b694060fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 17 Apr 2016 18:13:24 -0500 Subject: [PATCH] test --- iguana/iguana777.c | 2 ++ iguana/iguana_ramchain.c | 6 +++--- iguana/iguana_unspents.c | 28 ++++++++++++++++++++++------ 3 files changed, 27 insertions(+), 9 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index b1398ae2a..d41757a82 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -360,6 +360,8 @@ int32_t iguana_validated(struct iguana_info *coin) int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convertflag) { int32_t hdrsi,retval,n,max,incr,num = 0; struct iguana_bundle *bp; + if ( coin->spendvectorsaved > 1 ) + return(0); incr = IGUANA_NUMHELPERS; if ( 0 && coin->PREFETCHLAG > 0 ) { diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 9a99d5051..1cffb7e9c 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1033,8 +1033,8 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits } }*/ #ifdef __PNACL__ - //static portable_mutex_t mutex; - //portable_mutex_lock(&mutex); + static portable_mutex_t mutex; + portable_mutex_lock(&mutex); #endif if ( (fp= fopen(fname,"wb")) == 0 ) printf("iguana_ramchain_save: couldnt create.(%s) errno.%d\n",fname,errno); @@ -1057,7 +1057,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits fclose(fp); } #ifdef __PNACL__ - //portable_mutex_unlock(&mutex); + portable_mutex_unlock(&mutex); #endif return(fpos); } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index f303379ac..0694bb6d1 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -219,7 +219,13 @@ int32_t iguana_volatilesmap(struct iguana_info *coin,struct iguana_ramchain *ram err = 0; } else printf("ramchain map error2 balanceswritten %d vs %d hashes %x %x\n",coin->balanceswritten,numhdrsi,coin->balancehash.uints[0],balancehash.uints[0]); } else printf("ramchain map error3 %s\n",fname); - } else printf("ramchain map error balanceswritten %d vs %d hashes %x %x\n",coin->balanceswritten,numhdrsi,coin->balancehash.uints[0],balancehash.uints[0]); + } + else + { + printf("ramchain map error balanceswritten %d vs %d hashes %x %x\n",coin->balanceswritten,numhdrsi,coin->balancehash.uints[0],balancehash.uints[0]); + err++; + OS_removefile(fname,0); + } } if ( err == 0 ) break; @@ -1304,7 +1310,7 @@ int32_t iguana_volatilesinit(struct iguana_info *coin) crc = calc_crc32(crc,(void *)Aptr,(int32_t)(sizeof(*Aptr) * numpkinds)); crc = calc_crc32(crc,(void *)Uptr,(int32_t)(sizeof(*Uptr) * numunspents)); crc = calc_crc32(crc,(void *)bp->hashes,(int32_t)(sizeof(bp->hashes[0]) * bp->n)); - } else printf("missing hdrs.[%d] data.%p num.(%u %d) %p %p\n",i,bp->ramchain.H.data,numpkinds,numunspents,Aptr,Uptr); + } //else printf("missing hdrs.[%d] data.%p num.(%u %d) %p %p\n",i,bp->ramchain.H.data,numpkinds,numunspents,Aptr,Uptr); } } else crc = filecrc; printf("millis %.0f from_ro.%d written.%d crc.%08x/%08x balancehash.(%s) vs (%s)\n",OS_milliseconds(),from_ro,coin->balanceswritten,crc,filecrc,bits256_str(str,balancehash),bits256_str(str2,coin->balancehash)); @@ -1783,6 +1789,14 @@ void iguana_RTspendvectors(struct iguana_info *coin,struct iguana_bundle *bp) int32_t lasti,hdrsi,orignumemit; struct iguana_ramchain R; struct iguana_ramchaindata RDATA; if ( bp->hdrsi <= 0 ) return; + for (hdrsi=0; hdrsihdrsi; hdrsi++) + { + if ( coin->bundles[hdrsi] != 0 ) + { + iguana_volatilespurge(coin,&coin->bundles[hdrsi]->ramchain); + iguana_volatilesalloc(coin,&coin->bundles[hdrsi]->ramchain); + } + } bp->ramchain = coin->RTramchain; iguana_rdataset(&R,&RDATA,&coin->RTramchain); if ( (lasti= (coin->RTheight - ((coin->RTheight/bp->n)*bp->n))) >= bp->n-1 ) @@ -1813,8 +1827,6 @@ int32_t iguana_realtime_update(struct iguana_info *coin) double startmillis0; static double totalmillis0; static int32_t num0; struct iguana_bundle *bp; struct iguana_ramchaindata *rdata; int32_t bundlei,i,n,flag=0; bits256 hash2; struct iguana_peer *addr; struct iguana_block *block=0; struct iguana_blockRO *B; struct iguana_ramchain *dest=0,blockR; - if ( coin->RTdatabad != 0 ) - iguana_RTramchainfree(coin); if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize && bp->hdrsi == coin->balanceswritten && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n && ((coin->RTheight <= coin->blocks.hwmchain.height && time(NULL) > bp->lastRT) || time(NULL) > bp->lastRT+10) ) { if ( (block= bp->blocks[0]) == 0 || block->txvalid == 0 || block->mainchain == 0 ) @@ -1914,14 +1926,18 @@ int32_t iguana_realtime_update(struct iguana_info *coin) else { printf("RTgenesis failed to verify n.%d vs %d\n",n,coin->RTheight); - iguana_RTramchainfree(coin); - return(-1); + //iguana_RTramchainfree(coin); + //return(-1); + coin->RTdatabad = 1; } } if ( dest != 0 && flag != 0 ) printf("<<<< flag.%d RT.%d:%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\n",flag,coin->RTheight,n,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,dest->H.data!=0?(long)dest->H.data->allocsize:-1); if ( coin->RTdatabad != 0 ) + { iguana_RTramchainfree(coin); + iguana_RTramchainalloc("RTbundle",coin,bp); + } return(flag); }