From 40351045cad8b9e085b53155cf6962fba80e84fc Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 3 Nov 2016 18:48:50 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 8 ++++- iguana/iguana_ramchain.c | 12 ++++--- iguana/iguana_spendvectors.c | 63 ++++++++++++++++++++---------------- 3 files changed, 49 insertions(+), 34 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index b2dc379bb..b773a49db 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -447,7 +447,9 @@ void iguana_update_balances(struct supernet_info *myinfo,struct iguana_info *coi max = coin->bundlescount; if ( coin->bundles[max-1] == coin->current || coin->bundles[max-1] == 0 || (coin->bundles[max-1] != 0 && coin->bundles[max-1]->utxofinish <= 1) ) max--; - //coin->spendvectorsaved = 0; + coin->spendvectorsaved = 0; + iguana_utxogen(myinfo,coin,0,1); + if ( iguana_balancefinished(coin) < max && iguana_spendvectorsaves(coin) == 0 ) // { if ( coin->origbalanceswritten <= 1 ) @@ -462,6 +464,7 @@ void iguana_update_balances(struct supernet_info *myinfo,struct iguana_info *coi sprintf(fname,"%s/%s/accounts/lastspends.%d",GLOBAL_DBDIR,coin->symbol,bp->bundleheight); OS_removefile(fname,0); iguana_volatilesalloc(coin,&bp->ramchain,0);//i < hdrsi); + //iguana_Xspendmap(coin,&bp->ramchain,bp); } printf("accounts files purged\n"); sleep(3); @@ -515,7 +518,10 @@ int32_t iguana_utxogen(struct supernet_info *myinfo,struct iguana_info *coin,int if ( helperid < incr ) { for (hdrsi=helperid; hdrsibundles[hdrsi]->utxofinish = 1; num += iguana_helperA(myinfo,coin,helperid,coin->bundles[hdrsi],convertflag); + } } while ( (n= iguana_utxofinished(coin)) < max ) { diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 5f783e34f..aa725df71 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -1322,6 +1322,8 @@ int32_t iguana_ramchain_extras(struct supernet_info *myinfo,struct iguana_info * int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp) { int32_t iter; bits256 sha256; char str[65],fname[1024]; void *ptr; long filesize; + if ( ramchain->Xspendinds != 0 ) + return(ramchain->numXspends); for (iter=0; iter<2; iter++) { sprintf(fname,"%s/%s%s/spends/%s.%d",GLOBAL_DBDIR,iter==0?"ro/":"",coin->symbol,bits256_str(str,bp->hashes[0]),bp->bundleheight); @@ -1342,10 +1344,10 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha printf("[%d] filesize %ld Xspendptr.%p %p num.%d\n",bp->hdrsi,filesize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends); bp->Xvalid = 1; } + printf("mapped utxo vector[%d] from (%s)\n",ramchain->numXspends,fname); return(ramchain->numXspends); //int32_t i; for (i=0; inumXspends; i++) // printf("(%d u%d) ",ramchain->Xspendinds[i].hdrsi,ramchain->Xspendinds[i].ind); - //printf("mapped utxo vector[%d] from (%s)\n",ramchain->numXspends,fname); } else { @@ -2014,7 +2016,7 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i) void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile) { void *ptr; int32_t recvlen,height = -1; uint8_t zcash = 0; - if ( bp != 0 ) + if ( 0 && bp != 0 ) printf("UNMARK.[%d:%d]\n",bp->hdrsi,i); if ( block != 0 ) { @@ -2291,7 +2293,7 @@ struct iguana_ramchain *iguana_bundleload(struct supernet_info *myinfo,struct ig if ( (mapchain= iguana_ramchain_map(myinfo,coin,fname,bp,bp->n,ramchain,0,0,bp->hashes[0],zero,0,0,extraflag,1,zcash)) != 0 ) { iguana_ramchain_link(mapchain,bp->hashes[0],bp->hdrsi,bp->bundleheight,0,bp->n,firsti,1); - //char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data); + char str[65]; printf("%s bp.%d: T.%d U.%d S.%d P%d X.%d MAPPED %s %p\n",coin->symbol,bp->hdrsi,mapchain->H.data->numtxids,mapchain->H.data->numunspents,mapchain->H.data->numspends,mapchain->H.data->numpkinds,mapchain->H.data->numexternaltxids,mbstr(str,mapchain->H.data->allocsize),mapchain->H.data); //ramcoder_test(mapchain->H.data,mapchain->H.data->allocsize); firsttxidind = 1; if ( (rdata= ramchain->H.data) != 0 ) @@ -2583,7 +2585,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi //coin->blocks.RO[bp->bundleheight+bundlei] = block->RO; iguana_blockzcopyRO(zcash,destB,bundlei,&block->RO,0); //destB[bundlei] = block->RO; - //fprintf(stderr,"(%d %d).%d ",R[bundlei].H.data->numtxids,dest->H.txidind,bundlei); + //fprintf(stderr,"T.(%d %d u%d).%d ",R[bundlei].H.data->numtxids,dest->H.txidind,R[bundlei].H.data->numunspents,bundlei); if ( (err= iguana_ramchain_iterate(myinfo,coin,dest,&R[bundlei],bp,bundlei)) != 0 ) { if ( (block= bp->blocks[bundlei]) != 0 ) @@ -2613,7 +2615,7 @@ int32_t iguana_bundlesaveHT(struct supernet_info *myinfo,struct iguana_info *coi memset(&newchain,0,sizeof(newchain)); if ( bundlei == endi+1 && iguana_ramchain_expandedsave(myinfo,coin,RAMCHAIN_DESTARG,&newchain,&HASHMEM,0,bp) == 0 ) { - //char str[65]; printf("d.%d ht.%d %s saved lag.%d elapsed.%ld\n",depth,dest->height,mbstr(str,dest->H.data->allocsize),now-starttime,time(NULL)-now); + char str[65]; printf("d.%d ht.%d %s saved\n",depth,dest->height,mbstr(str,dest->H.data->allocsize)); retval = 0; } else bp->generrs++; iguana_bundlemapfree(coin,mem,&HASHMEM,ipbits,ptrs,filesizes,num,R,starti,endi); diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 02a6380fe..418a4a678 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -56,7 +56,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp int32_t i,retval = -1; FILE *fp; char fname[1024],str[65]; long fsize; bits256 zero,sha256; if ( ptr == 0 || (bp->hdrsi != 0 && ptr == bp->ramchain.Xspendinds) ) { - //printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr); + printf("iguana_spendvectorsave.[%d] ptr.%p Xspendinds\n",bp->hdrsi,ptr); return(0); } memset(zero.bytes,0,sizeof(zero)); @@ -84,7 +84,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp printf("error mapping Xspendmap.(%s)\n",fname); else { - //printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends); + printf("created.(%s) %p[%d]\n",fname,bp->ramchain.Xspendinds,bp->ramchain.numXspends); retval = 0; } } @@ -263,7 +263,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi bp->numtmpspends = ramchain->numXspends; bp->utxofinish = (uint32_t)time(NULL); bp->balancefinish = 0; - //printf("iguana_spendvectors.[%d]: already have Xspendinds[%d]\n",bp->hdrsi,ramchain->numXspends); + printf("iguana_spendvectors.[%d]: already have Xspendinds[%d]\n",bp->hdrsi,ramchain->numXspends); return(0); } bp->startutxo = (uint32_t)time(NULL); @@ -474,7 +474,10 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig numXspends = bp->numtmpspends; if ( (Xspendinds= bp->tmpspends) == 0 ) { - //printf("iguana_balancegen.%d: no Xspendinds[%d]\n",bp->hdrsi,numXspends); + printf("iguana_balancegen.%d: no Xspendinds[%d]\n",bp->hdrsi,numXspends); + numXspends = iguana_Xspendmap(coin,ramchain,bp); + numXspends = ramchain->numXspends; + printf("Xspendinds.%p[%d]\n",Xspendinds,numXspends); //return(-1); } } @@ -483,7 +486,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig spendind = B[starti].firstvin; unspentind = B[starti].firstvout; emit = startemit; - if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) + //if ( 0 && (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); for (i=starti; i<=endi; i++) { @@ -572,7 +575,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig else //if ( Xspendinds != 0 ) { errs++; - printf("iguana_balancegen: spendind.%u external.%d error spentbp.%p with unspentind.%d pkind.%u [%d] (%d %d %d)\n",spendind,s->external,spentbp,spent_unspentind,spent_pkind,spent_hdrsi,i,j,k); + printf("iguana_balancegen: X%p[%d] spendind.%u external.%d error spentbp.%p with unspentind.%d pkind.%u [%d] (%d %d %d)\n",Xspendinds,numXspends,spendind,s->external,spentbp,spent_unspentind,spent_pkind,spent_hdrsi,i,j,k); } } } @@ -1005,7 +1008,7 @@ int32_t iguana_spendvectorsaves(struct iguana_info *coin) return(0); coin->spendvectorsaved = 1; n = coin->bundlescount - 1; - //printf("SAVE SPEND VECTORS %d of %d\n",n,coin->bundlescount); + printf("SAVE SPEND VECTORS %d of %d\n",n,coin->bundlescount); for (iter=0; iter<2; iter++) { for (i=0; isymbol); bp->validated = (uint32_t)time(NULL); + forceflag = 1; //return(bp->n); } if ( (coin->MAXPEERS > 1 && coin->VALIDATENODE == 0 && coin->FULLNODE == 0) || bp->ramchain.from_ro != 0 )//|| bp == coin->current ) @@ -1161,31 +1165,34 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c } if ( forceflag != 0 || bp->validated <= 1 ) { - max = coin->blockspacesize; - blockspace = calloc(1,max); - iguana_volatilespurge(coin,&bp->ramchain); - iguana_volatilesmap(myinfo,coin,&bp->ramchain); - for (i=0; in; i++) + if ( coin->chain->zcash == 0 ) { - char str[65]; - if ( coin->chain->fixit != 0 ) - printf("validate %s.[%d:%d] %s\n",coin->symbol,bp->hdrsi,i,bits256_str(str,bp->hashes[i])); - if ( (len= iguana_peerblockrequest(myinfo,coin,blockspace,max,0,bp->hashes[i],1)) < 0 ) - { - errs++; - //fprintf(stderr,"-%s.[%d:%d] ",coin->symbol,bp->hdrsi,i); - //printf("bundlevalidate: %s delete [%d:%d]\n",coin->symbol,bp->hdrsi,i); - iguana_blockunmark(coin,bp->blocks[i],bp,i,1); - totalerrs++; - } - else + max = coin->blockspacesize; + blockspace = calloc(1,max); + iguana_volatilespurge(coin,&bp->ramchain); + iguana_volatilesmap(myinfo,coin,&bp->ramchain); + for (i=0; in; i++) { - vupdate_sha256(validatehash.bytes,&vstate,bp->hashes[i].bytes,sizeof(bp->hashes[i])); - total += len, totalvalidated++; + char str[65]; + if ( coin->chain->fixit != 0 ) + printf("validate %s.[%d:%d] %s\n",coin->symbol,bp->hdrsi,i,bits256_str(str,bp->hashes[i])); + if ( (len= iguana_peerblockrequest(myinfo,coin,blockspace,max,0,bp->hashes[i],1)) < 0 ) + { + errs++; + //fprintf(stderr,"-%s.[%d:%d] ",coin->symbol,bp->hdrsi,i); + //printf("bundlevalidate: %s delete [%d:%d]\n",coin->symbol,bp->hdrsi,i); + iguana_blockunmark(coin,bp->blocks[i],bp,i,1); + totalerrs++; + } + else + { + vupdate_sha256(validatehash.bytes,&vstate,bp->hashes[i].bytes,sizeof(bp->hashes[i])); + total += len, totalvalidated++; + } } + free(blockspace); + printf("%s %s VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",coin->symbol,errs!=0?"NOT":"",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid); } - free(blockspace); - printf("%s %s VALIDATED.[%d] ht.%d duration.%d errs.%d total.%lld %u | total errs.%d validated.%d %llx\n",coin->symbol,errs!=0?"NOT":"",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - now,errs,(long long)total,bp->validated,totalerrs,totalvalidated,(long long)validatehash.txid); if ( errs == 0 ) bp->validated = (uint32_t)time(NULL); else bp->validated = bp->startutxo = bp->utxofinish = 0;