From 1340bac101cb6105fa782e293b19e57d816e9ca9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 24 Mar 2016 18:19:30 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 22 +++++++++++++--------- iguana/iguana777.h | 2 +- iguana/iguana_bundles.c | 7 ++++--- iguana/iguana_ramchain.c | 10 +++++----- iguana/iguana_unspents.c | 6 ++++-- iguana/main.c | 1 + 6 files changed, 28 insertions(+), 20 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index c8b663c46..dc75ef4ca 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -289,15 +289,19 @@ void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t ti void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp) { struct iguana_helper *ptr; - ptr = mycalloc('i',1,sizeof(*ptr)); - ptr->allocsize = sizeof(*ptr); - ptr->coin = coin; - ptr->bp = bp, ptr->hdrsi = bp->hdrsi; - ptr->type = 'V'; - ptr->starttime = (uint32_t)time(NULL); - ptr->timelimit = 0; - //printf("VALIDATE Q %s bundle.%d[%d] utxofinish.%u balancefinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->utxofinish,bp->balancefinish); - queue_enqueue("validateQ",&validateQ,&ptr->DL,0); + if ( bp->validated == 0 ) + { + ptr = mycalloc('i',1,sizeof(*ptr)); + ptr->allocsize = sizeof(*ptr); + ptr->coin = coin; + ptr->bp = bp, ptr->hdrsi = bp->hdrsi; + ptr->type = 'V'; + ptr->starttime = (uint32_t)time(NULL); + ptr->timelimit = 0; + bp->validated = 1; + //printf("VALIDATE Q %s bundle.%d[%d] utxofinish.%u balancefinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->utxofinish,bp->balancefinish); + queue_enqueue("validateQ",&validateQ,&ptr->DL,0); + } } void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index e2200ce6b..18007859f 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -483,7 +483,7 @@ struct iguana_info uint8_t blockspace[IGUANA_MAXPACKETSIZE + 8192]; struct OS_memspace blockMEM; struct iguana_blocks blocks; bits256 APIblockhash,APItxid; char *APIblockstr; struct iguana_waccount *wallet; - struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; + struct iguana_hhutxo *utxotable; struct iguana_hhaccount *accountstable; char lastdispstr[2048]; }; struct vin_signer { bits256 privkey; char coinaddr[64]; uint8_t siglen,sig[80],rmd160[20],pubkey[66]; }; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 2bfd7f3a7..cea2461d7 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -1042,11 +1042,12 @@ void iguana_bundlestats(struct iguana_info *coin,char *str) coin->spaceused = spaceused; coin->numverified = numv; char str4[65],str5[65]; - sprintf(str,"%s u.%d b.%d v.%d/%d (%d/%d 1st.%d) to %d N[%d] Q.%d h.%d r.%d c.%s s.%d d.%d E.%d:%d est.%d %s %d:%02d:%02d %03.3f peers.%d/%d Q.(%d %d) L.%d [%d:%d] M.%d %s",coin->symbol,numutxo,numbalances,numv,coin->pendbalances,firstgap!=0?firstgap->numsaved:-1,firstgap!=0?firstgap->numhashes:-1,firstgap!=0?firstgap->hdrsi:-1,coin->lastpending!=0?coin->lastpending->hdrsi:0,count,coin->numbundlesQ,numhashes,coin->blocksrecv,mbstr(str4,spaceused),numsaved,done,numemit,coin->numreqsent,coin->MAXBUNDLES,mbstr(str2,estsize),(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,difft.millis,p,coin->MAXPEERS,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),coin->longestchain,coin->blocks.hwmchain.height/coin->chain->bundlesize,coin->blocks.hwmchain.height%coin->chain->bundlesize,coin->blocks.hwmchain.height,bits256_str(str5,coin->blocks.hwmchain.RO.hash2)); + sprintf(str,"%s u.%d b.%d v.%d/%d (%d/%d 1st.%d) to %d N[%d] Q.%d h.%d r.%d c.%s s.%d d.%d E.%d:%d est.%d %s peers.%d/%d Q.(%d %d) L.%d [%d:%d] M.%d %s",coin->symbol,numutxo,numbalances,numv,coin->pendbalances,firstgap!=0?firstgap->numsaved:-1,firstgap!=0?firstgap->numhashes:-1,firstgap!=0?firstgap->hdrsi:-1,coin->lastpending!=0?coin->lastpending->hdrsi:0,count,coin->numbundlesQ,numhashes,coin->blocksrecv,mbstr(str4,spaceused),numsaved,done,numemit,coin->numreqsent,coin->MAXBUNDLES,mbstr(str2,estsize),p,coin->MAXPEERS,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ),coin->longestchain,coin->blocks.hwmchain.height/coin->chain->bundlesize,coin->blocks.hwmchain.height%coin->chain->bundlesize,coin->blocks.hwmchain.height,bits256_str(str5,coin->blocks.hwmchain.RO.hash2)); //sprintf(str+strlen(str),"%s.%-2d %s time %.2f files.%d Q.%d %d\n",coin->symbol,flag,str,(double)(time(NULL)-coin->starttime)/60.,coin->peers.numfiles,queue_size(&coin->priorityQ),queue_size(&coin->blocksQ)); - if ( time(NULL) > coin->lastdisp+10 ) + if ( time(NULL) > coin->lastdisp+3 && strcmp(str,coin->lastdispstr) != 0 ) { - printf("%s\n",str); + printf("%s %d:%02d:%02d %03.3f\n",str,(int32_t)difft.x/3600,(int32_t)(difft.x/60)%60,(int32_t)difft.x%60,difft.millis); + strcpy(coin->lastdispstr,str); if ( (rand() % 100) == 0 ) myallocated(0,0); coin->lastdisp = (uint32_t)time(NULL); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index f84669269..6596a218f 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2097,7 +2097,7 @@ void *iguana_bundlefile(struct iguana_info *coin,long *filesizep,struct iguana_b } if ( (ptr= OS_mapfile(fname,filesizep,0)) == 0 ) { - printf("error mapping.(%s) bundlei.%d\n",fname,bundlei); + //printf("error mapping.(%s) bundlei.%d\n",fname,bundlei); return(0); } return(ptr); @@ -2320,12 +2320,13 @@ int64_t iguana_ramchainopen(struct iguana_info *coin,struct iguana_ramchain *ram _iguana_ramchain_setptrs(RAMCHAIN_PTRS,ramchain->H.data); iguana_ramchain_extras(coin,ramchain,hashmem,0); } - return(rdata->allocsize); + return(ramchain->H.data->allocsize); } int32_t iguana_mapchaininit(struct iguana_info *coin,struct iguana_ramchain *mapchain,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block,void *ptr,long filesize) { int32_t firsti = 1; RAMCHAIN_DECLARE; + memset(mapchain,0,sizeof(*mapchain)); mapchain->fileptr = ptr; mapchain->filesize = filesize; mapchain->H.data = (void *)(long)((long)ptr + block->fpos); @@ -2338,8 +2339,7 @@ int32_t iguana_mapchaininit(struct iguana_info *coin,struct iguana_ramchain *map _iguana_ramchain_setptrs(MAPCHAIN_PTRS,mapchain->H.data); if ( block->fpos+mapchain->H.data->allocsize > filesize || iguana_ramchain_size(MAPCHAIN_ARG,1,mapchain->H.data->scriptspace) != mapchain->H.data->allocsize ) { - printf("iguana_bundlesaveHT.%d ipbits.%x size mismatch %ld vs %ld vs filesize.%ld fpos.%ld bundlei.%d expanded.%d soff.%d\n",bp->bundleheight,block->fpipbits,(long)iguana_ramchain_size(MAPCHAIN_ARG,1,mapchain->H.data->scriptspace),(long)mapchain->H.data->allocsize,(long)filesize,(long)block->fpos,bundlei,mapchain->expanded,mapchain->H.data->scriptspace); - //getchar(); + printf("iguana_mapchaininit.%d ipbits.%x size mismatch %ld vs %ld vs filesize.%ld fpos.%ld bundlei.%d expanded.%d soff.%d\n",bp->bundleheight,block->fpipbits,(long)iguana_ramchain_size(MAPCHAIN_ARG,1,mapchain->H.data->scriptspace),(long)mapchain->H.data->allocsize,(long)filesize,(long)block->fpos,bundlei,mapchain->expanded,mapchain->H.data->scriptspace); return(-1); } else if ( memcmp(bp->hashes[bundlei].bytes,mapchain->H.data->firsthash2.bytes,sizeof(bits256)) != 0 ) @@ -2380,7 +2380,7 @@ int32_t iguana_bundlesaveHT(struct iguana_info *coin,struct OS_memspace *mem,str bp_n = (endi - starti + 1); scriptspace = 1; sigspace = pubkeyspace = 0; - for (bundlei=starti,numtxids=numunspents=numspends=scriptspace=0; bundlei<=endi; bundlei++) + for (bundlei=starti,numtxids=numunspents=numspends=0; bundlei<=endi; bundlei++) { if ( (block= bp->blocks[bundlei]) == 0 || bits256_nonz(block->RO.hash2) == 0 || block != iguana_blockfind(coin,block->RO.hash2) || memcmp(block->RO.hash2.bytes,bp->hashes[bundlei].bytes,sizeof(bits256)) != 0 ) { diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 718afb0d9..34b41e6af 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -819,6 +819,8 @@ void iguana_RTramchainalloc(struct iguana_info *coin,struct iguana_bundle *bp) mult = (strcmp("BTC",coin->symbol) == 0) ? 2048 : 4; if ( coin->RTmem.ptr == 0 ) iguana_meminit(&coin->RTmem,coin->symbol,0,IGUANA_MAXPACKETSIZE*mult + 65536*3,0); + if ( coin->RThashmem.ptr == 0 ) + iguana_meminit(&coin->RThashmem,coin->symbol,0,IGUANA_MAXPACKETSIZE*mult + 65536*3,0); iguana_ramchainopen(coin,dest,&coin->RTmem,&coin->RThashmem,bp->bundleheight,bp->hashes[0]); dest->H.txidind = dest->H.unspentind = dest->H.spendind = dest->pkind = dest->H.data->firsti; dest->externalind = dest->H.stacksize = 0; @@ -834,7 +836,7 @@ int32_t iguana_realtime_update(struct iguana_info *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 ) { iguana_RTramchainalloc(coin,bp); - if ( (rdata= coin->RTramchain.H.data) != 0 && coin->RTheight < coin->blocks.hwmchain.height) + while ( (rdata= coin->RTramchain.H.data) != 0 && coin->RTheight <= coin->blocks.hwmchain.height) { dest = &coin->RTramchain; B = (void *)(long)((long)rdata + rdata->Boffset); @@ -860,7 +862,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin) } return(-1); } - printf("added RTheight.%d hwm.%d longest.%d\n",coin->RTheight,coin->blocks.hwmchain.height,coin->longestchain); + char str[65]; printf("RTheight.%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld %s\n",coin->RTheight,coin->blocks.hwmchain.height,coin->longestchain,dest->H.txidind,dest->H.unspentind,dest->H.spendind,dest->pkind,dest->externalind,(long)dest->H.data->allocsize,mbstr(str,dest->H.data->allocsize)); coin->RTheight++; coin->RTramchain.H.data->numblocks = bundlei + 1; } else printf("error mapchaininit\n"); diff --git a/iguana/main.c b/iguana/main.c index 9fd74ed40..2d37d571d 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -358,6 +358,7 @@ void mainloop(struct supernet_info *myinfo) iguana_realtime_update(coin); if ( (ptr= queue_dequeue(&balancesQ,0)) != 0 ) { + flag++; if ( ptr->coin != 0 && (bp= ptr->bp) != 0 ) iguana_balancecalc(ptr->coin,bp,bp->bundleheight,bp->bundleheight+bp->n-1); myfree(ptr,ptr->allocsize);