From 0f9491109a51fb35f9f53e4f55cf9bd3ce5e242d Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 19 Apr 2016 18:40:04 -0500 Subject: [PATCH] test --- iguana/iguana777.c | 8 ++++---- iguana/iguana777.h | 2 +- iguana/iguana_unspents.c | 19 +++++++++++++------ 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 8b4a441e0..a08225147 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -430,7 +430,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert while ( (n= iguana_utxofinished(coin)) < max ) { //printf("helperid.%d utxofinished.%d vs %d\n",helperid,n,max); - sleep(3); + sleep(IGUANA_NUMHELPERS+3); } if ( helperid < incr ) { @@ -440,7 +440,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert while ( (n= iguana_convertfinished(coin)) < max ) { printf("helperid.%d convertfinished.%d vs max %d bundlescount.%d\n",helperid,n,max,coin->bundlescount); - sleep(3); + sleep(IGUANA_NUMHELPERS+3); } if ( helperid == 0 ) { @@ -473,7 +473,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert while ( iguana_validated(coin) < max || iguana_utxofinished(coin) < max || iguana_balancefinished(coin) < max ) { printf("helperid.%d waiting for spendvectorsaved.%u v.%d u.%d b.%d vs max.%d\n",helperid,coin->spendvectorsaved,iguana_validated(coin),iguana_utxofinished(coin),iguana_balancefinished(coin),max); - sleep(3); + sleep(IGUANA_NUMHELPERS+3); } if ( helperid == 0 ) { @@ -483,7 +483,7 @@ int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid,int32_t convert else { while ( coin->spendvectorsaved <= 1 ) - sleep(3); + sleep(IGUANA_NUMHELPERS+3); } printf("helper.%d done\n",helperid); return(num); diff --git a/iguana/iguana777.h b/iguana/iguana777.h index d4c3b1768..533e505d7 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -452,7 +452,7 @@ struct iguana_bundle struct iguana_block *blocks[IGUANA_MAXBUNDLESIZE]; uint8_t *speculativecache[IGUANA_MAXBUNDLESIZE],haveblock[IGUANA_MAXBUNDLESIZE/3+1]; uint32_t issued[IGUANA_MAXBUNDLESIZE]; - bits256 prevbundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative; + bits256 prevbundlehash2,hashes[IGUANA_MAXBUNDLESIZE+1],nextbundlehash2,allhash,*speculative,validatehash; struct iguana_ramchain ramchain; uint8_t red,green,blue; struct iguana_spendvector *tmpspends; int32_t numtmpspends; }; diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index e29978e13..622f6d75d 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -2009,17 +2009,18 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp, { static int32_t totalerrs,totalvalidated; FILE *fp; char fname[1024]; uint8_t *blockspace; uint32_t now = (uint32_t)time(NULL); - int32_t i,max,len,errs = 0; int64_t total = 0; + int32_t i,max,len,errs = 0; struct sha256_vstate vstate; bits256 validatehash; int64_t total = 0; //printf("validate.[%d]\n",bp->hdrsi); if ( bp->validated <= 1 || forceflag != 0 ) { + vupdate_sha256(validatehash.bytes,&vstate,0,0); sprintf(fname,"%s/%s/validated/%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); //printf("validatefname.(%s)\n",fname); if ( (fp= fopen(fname,"rb")) != 0 ) { if ( forceflag == 0 ) { - if ( fread(&bp->validated,1,sizeof(bp->validated),fp) != sizeof(bp->validated) ||fread(&total,1,sizeof(total),fp) != sizeof(total) ) + if ( fread(&bp->validated,1,sizeof(bp->validated),fp) != sizeof(bp->validated) ||fread(&total,1,sizeof(total),fp) != sizeof(total) || fread(&validatehash,1,sizeof(validatehash),fp) != sizeof(validatehash) ) { printf("error reading.(%s)\n",fname); total = bp->validated = 0; @@ -2027,7 +2028,7 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp, } else OS_removefile(fname,1); fclose(fp); } - if ( forceflag != 0 || (total == 0 && bp->validated <= 1) ) + if ( forceflag != 0 || bp->validated <= 1 ) { max = sizeof(coin->blockspace); blockspace = calloc(1,max); @@ -2038,21 +2039,27 @@ int32_t iguana_bundlevalidate(struct iguana_info *coin,struct iguana_bundle *bp, errs++; iguana_blockunmark(coin,bp->blocks[i],bp,i,1); totalerrs++; - } else total += len, totalvalidated++; + } + else + { + vupdate_sha256(validatehash.bytes,&vstate,bp->hashes[i].bytes,sizeof(bp->hashes[i])); + total += len, totalvalidated++; + } } free(blockspace); bp->validated = (uint32_t)time(NULL); - printf("VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d\n",bp->hdrsi,bp->bundleheight,bp->validated - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated); + printf("VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",bp->hdrsi,bp->bundleheight,bp->validated - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid); } if ( errs == 0 && fp == 0 ) { if ( (fp= fopen(fname,"wb")) != 0 ) { - if ( fwrite(&bp->validated,1,sizeof(bp->validated),fp) != sizeof(bp->validated) || fwrite(&total,1,sizeof(total),fp) != sizeof(total) ) + if ( fwrite(&bp->validated,1,sizeof(bp->validated),fp) != sizeof(bp->validated) || fwrite(&total,1,sizeof(total),fp) != sizeof(total) || fwrite(&validatehash,1,sizeof(validatehash),fp) != sizeof(validatehash) ) printf("error saving.(%s) total.%lld\n",fname,(long long)total); fclose(fp); } } + bp->validatehash = validatehash; } // else printf("skip validate.[%d] validated.%u force.%d\n",bp->hdrsi,bp->validated,forceflag); if ( errs != 0 ) {