From f8817df4e2d69a686b67a9d49b5ce4feb37ef708 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Mar 2016 20:50:12 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 16 ++++++--- iguana/iguana777.h | 1 + iguana/iguana_bundles.c | 59 ++++++++++++++++++++---------- iguana/iguana_peers.c | 2 +- iguana/iguana_recv.c | 77 ++++++++++++++++++++++++---------------- iguana/iguana_unspents.c | 10 +++--- 6 files changed, 106 insertions(+), 59 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 0e563e5ef..aa33ad6f4 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -340,6 +340,7 @@ int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *m } else if ( ptr->type == 'B' ) { + printf("helper bundleiters\n"); iguana_bundleiters(coin,mem,memB,bp,ptr->timelimit); } else if ( ptr->type == 'E' ) @@ -358,7 +359,7 @@ int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *m void iguana_helper(void *arg) { - FILE *fp = 0; cJSON *argjson=0; int32_t type,helperid=rand(),flag,idle=0; + FILE *fp = 0; cJSON *argjson=0; int32_t type,helperid=rand(),flag,allcurrent,idle=0; struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; struct iguana_bundle *bp; if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 ) helperid = juint(argjson,"helperid"); @@ -375,6 +376,7 @@ void iguana_helper(void *arg) { //iguana_jsonQ(); cant do this here flag = 0; + allcurrent = 1; if ( ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) ) { if ( ptr->bp != 0 && (coin= ptr->coin) != 0 ) @@ -387,7 +389,7 @@ void iguana_helper(void *arg) } myfree(ptr,ptr->allocsize); } - if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) + else if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) { idle = 0; if ( (bp= ptr->bp) != 0 && (coin= ptr->coin) != 0 ) @@ -396,6 +398,8 @@ void iguana_helper(void *arg) if ( coin->started != 0 && time(NULL) >= bp->nexttime ) flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit); else iguana_bundleQ(ptr->coin,bp,1000); + if ( coin->current != 0 && coin->current->hdrsi != coin->bundlescount-1 ) + allcurrent = 0; } else printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit); myfree(ptr,ptr->allocsize); flag++; @@ -412,8 +416,10 @@ void iguana_helper(void *arg) } } if ( flag == 0 ) - usleep(1000000); - else usleep(100000); + usleep(100000); + else if ( allcurrent != 0 ) + usleep(25000); + else usleep(2500); } } @@ -452,7 +458,7 @@ void iguana_coinloop(void *arg) now = (uint32_t)time(NULL); if ( coin->active != 0 ) { - if ( coin->isRT == 0 && now > coin->startutc+200 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 ) + if ( coin->isRT == 0 && now > coin->startutc+77 && coin->numsaved >= (coin->longestchain/coin->chain->bundlesize)*coin->chain->bundlesize && coin->blocks.hwmchain.height >= coin->longestchain-30 ) { fprintf(stderr,">>>>>>> %s isRT blockrecv.%d vs longest.%d\n",coin->symbol,coin->blocksrecv,coin->longestchain); coin->isRT = 1; diff --git a/iguana/iguana777.h b/iguana/iguana777.h index e617ce50f..d6d74ab19 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -816,6 +816,7 @@ void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block int32_t iguana_ramchain_iterate(struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp); void *iguana_bundlefile(struct iguana_info *coin,char *fname,long *filesizep,struct iguana_bundle *bp,int32_t bundlei); 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); +void iguana_autoextend(struct iguana_info *coin,struct iguana_bundle *bp); extern int32_t HDRnet,netBLOCKS; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 89d53f1b2..d0424be6b 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -390,7 +390,7 @@ void iguana_bundlepurge(struct iguana_info *coin,struct iguana_bundle *bp) int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t max,int32_t timelimit) { - int32_t i,j,k,len,starti,lag,doneval,nonz,total=0,maxval,numpeers,laggard,flag=0,finished,peercounts[IGUANA_MAXPEERS],donecounts[IGUANA_MAXPEERS],priority,counter = 0; + int32_t i,j,k,len,forceflag,saved,starti,lag,doneval,nonz,total=0,maxval,numpeers,laggard,flag=0,finished,peercounts[IGUANA_MAXPEERS],donecounts[IGUANA_MAXPEERS],priority,counter = 0; struct iguana_peer *addr; uint32_t now; struct iguana_block *block; bits256 hashes[50]; uint8_t serialized[sizeof(hashes) + 256]; if ( bp == 0 ) @@ -430,8 +430,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int if ( block->fpipbits == 0 ) { hashes[k++] = bp->hashes[i]; - bp->issued[i] = now; - block->issued = now; + bp->issued[i] = block->issued = now; block->peerid = j + 1; block->numrequests++; } @@ -509,7 +508,8 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int counter++; block->peerid = 0; iguana_blockQ("kick",coin,bp,j,block->RO.hash2,bp == coin->current); - bp->issued[i] = block->issued = now; + if ( bp == coin->current ) + bp->issued[i] = block->issued = now; } } printf("slow peer.%d dead.%u (%s) reissued.%d [%d]\n",i,addr->dead,addr->ipaddr,flag,bp->hdrsi); @@ -531,22 +531,29 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int if ( now > block->issued+lag ) { counter++; + saved = block->issued; + if ( bp == coin->current ) + forceflag = (now > block->issued + lag); + else forceflag = (now > block->issued + 3*lag); if ( priority != 0 ) { //printf("[%d:%d] ",bp->hdrsi,i); - iguana_blockQ("kicka",coin,bp,i,block->RO.hash2,bp == coin->current && now > block->issued+lag); - if ( bp == coin->current && now > block->issued+lag*3 && (addr= coin->peers.ranked[rand() % numpeers]) != 0 ) + iguana_blockQ("kicka",coin,bp,i,block->RO.hash2,forceflag); + if ( forceflag != 0 && (addr= coin->peers.ranked[rand() % numpeers]) != 0 ) iguana_sendblockreqPT(coin,addr,bp,i,block->RO.hash2,0); - } else iguana_blockQ("kickb",coin,bp,i,block->RO.hash2,now > block->issued+lag*3); + } else iguana_blockQ("kickb",coin,bp,i,block->RO.hash2,0); + if ( forceflag != 0 ) + bp->issued[i] = block->issued = now; + else bp->issued[i] = block->issued = saved; flag++; } //else printf("%d ",now - block->issued); } } if ( flag != 0 && priority != 0 && laggard != 0 && coin->current == bp ) printf("[%d] reissued.%d currentflag.%d ht.%d s.%d finished.%d most.%d laggards.%d maxunfinished.%d\n",bp->hdrsi,flag,bp->currentflag,bp->bundleheight,bp->numsaved,finished,doneval,laggard,maxval); - } - //if ( bp == coin->current ) - // return(counter); + } + if ( bp == coin->current ) + return(counter); } for (i=0; in; i++) { @@ -622,7 +629,7 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32 if ( coin->enableCACHE != 0 && bp->speculative == 0 && bp->numhashes < bp->n ) { char str[64]; - if ( bp == coin->current ) + if ( 0 && bp == coin->current ) printf("hdr ITERATE bundle.%d vs %d: h.%d n.%d r.%d s.%d finished.%d speculative.%p\n",bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,bp->speculative); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); } @@ -726,9 +733,15 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp) } else if ( bp == coin->current ) { - char str[65]; printf("missing [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei])); - if ( now > bp->issued[bundlei]+10 ) - iguana_blockQ("missing",coin,bp,bundlei,bp->hashes[bundlei],0); + char str[65]; printf("missing prev_block [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei])); + if ( block != 0 ) + { + block->RO.recvlen = 0; + block->fpipbits = 0; + block->fpos = -1; + } + //else if ( now > bp->issued[bundlei]+1 ) + iguana_blockQ("missing",coin,bp,bundlei,bp->hashes[bundlei],1); } } /*else @@ -766,13 +779,13 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp) int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp) { struct iguana_bundle *prevbp; int32_t i,retval; -#ifndef IGUANA_SERIALIZE_SPENDVECTORGEN +//#ifdef IGUANA_SERIALIZE_SPENDVECTORGEN if ( coin->MAXMEM <= 4*(1024L * 1024 * 1024) ) -#endif { if ( (prevbp= coin->current) != 0 && prevbp->hdrsi < (coin->longestchain / coin->chain->bundlesize)-0*coin->MAXBUNDLES ) return(0); } +//#endif for (i=0; ihdrsi; i++) if ( (prevbp= coin->bundles[i]) == 0 || prevbp->emitfinish < coin->startutc ) break; @@ -821,8 +834,16 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru lastbp = coin->lastpending; starti = currentbp == 0 ? 0 : currentbp->hdrsi; lasti = lastbp == 0 ? coin->bundlescount-1 : lastbp->hdrsi; - iguana_bundlecalcs(coin,bp); - //printf("ITER now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); + if ( bp != coin->current || bp->dirty != 0 ) + { + iguana_bundlecalcs(coin,bp); + bp->dirty = 0; + } + if ( bp->hdrsi == coin->bundlescount-1 ) + { + iguana_autoextend(coin,bp); + //printf("ITER now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); + } bp->nexttime = (uint32_t)(time(NULL) + 1);//(bp->hdrsi - starti) + 1); if ( bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize ) iguana_bundlehdr(coin,bp,starti); @@ -870,6 +891,8 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru { max = bp->n; counter = iguana_bundleissue(coin,bp,max,timelimit); + if ( bp == coin->current && coin->isRT == 0 ) + bp->nexttime--; if ( bp->hdrsi == starti && counter > 0 ) printf("ITER now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); } diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 70c487efd..36de9963c 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -1097,7 +1097,7 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr) } } } - else if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 ) + else if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 10) == 0 ) { //printf("isRT and low rank.%d ",addr->rank); addr->dead = 1; diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 865b3e076..eaa619e78 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -44,7 +44,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, if ( addr->msgcounts.verack == 0 ) { printf("iguana_sendblockreq (%s) hasn't verack'ed yet\n",addr->ipaddr); - return(-1); + //return(-1); } lastreq2 = lastreq; lastreq = hash2; @@ -196,10 +196,14 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i copyflag = coin->enableCACHE; bp = 0, bundlei = -2; bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2); - if ( bp != 0 && bp->emitfinish != 0 ) + if ( bp != 0 ) { - //printf("got [%d:%d] with emitfinish.%u\n",bp->hdrsi,bundlei,bp->emitfinish); - return; + if ( bp->emitfinish != 0 ) + { + //printf("got [%d:%d] with emitfinish.%u\n",bp->hdrsi,bundlei,bp->emitfinish); + return; + } + bp->dirty++; } if ( copyflag != 0 && recvlen != 0 && (bp == 0 || (bp->blocks[bundlei] != 0 && bp->blocks[bundlei]->fpipbits == 0)) ) { @@ -547,6 +551,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct iguana_info *coin,struct ig bp = 0, bundlei = -1; if ( (bp= iguana_bundleset(coin,&block,&bundlei,&blocks[i])) != 0 ) { + bp->dirty++; //printf("{%d:%d} ",bp->hdrsi,bundlei); if ( i == 0 ) firstbp = bp; @@ -574,9 +579,26 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct iguana_info *coin,struct ig return(req); } +void iguana_autoextend(struct iguana_info *coin,struct iguana_bundle *bp) +{ + char hashstr[65],str[65],str2[65]; struct iguana_bundle *newbp; int32_t bundlei; static bits256 zero; + if ( bp->hdrsi == coin->bundlescount-1 && bits256_nonz(bp->nextbundlehash2) != 0 ) + { + init_hexbytes_noT(hashstr,bp->nextbundlehash2.bytes,sizeof(bits256)); + queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); + newbp = iguana_bundlecreate(coin,&bundlei,bp->bundleheight+coin->chain->bundlesize,bp->nextbundlehash2,zero,1); + if ( newbp != 0 ) + { + printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,bp->nextbundlehash2),newbp->bundleheight); + if ( newbp->queued == 0 ) + iguana_bundleQ(coin,newbp,1000); + } + } +} + struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct iguana_bundlereq *req,bits256 *blockhashes,int32_t num) { - int32_t bundlei,i,len; struct iguana_bundle *bp,*newbp; bits256 allhash,zero; char hashstr[65]; uint8_t serialized[512]; struct iguana_peer *addr; struct iguana_block *block; + int32_t bundlei,i,len; struct iguana_bundle *bp; bits256 allhash,zero; uint8_t serialized[512]; struct iguana_peer *addr; struct iguana_block *block; memset(zero.bytes,0,sizeof(zero)); bp = 0, bundlei = -2; if ( num < 2 ) @@ -589,33 +611,22 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei); if ( bp != 0 ) { + bp->dirty++; bp->hdrtime = (uint32_t)time(NULL); blockhashes[0] = bp->hashes[0]; iguana_blockQ("recvhash0",coin,bp,0,blockhashes[0],0); if ( num >= coin->chain->bundlesize ) { - iguana_blockQ("recvhash1",coin,0,-1,blockhashes[coin->chain->bundlesize],0); - //printf("call allhashes\n"); - if ( bp->hdrsi == coin->bundlescount-1 ) + if ( bits256_nonz(bp->nextbundlehash2) == 0 && num > coin->chain->bundlesize ) { - init_hexbytes_noT(hashstr,blockhashes[coin->chain->bundlesize].bytes,sizeof(bits256)); - queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(hashstr),1); - newbp = iguana_bundlecreate(coin,&bundlei,bp->bundleheight+coin->chain->bundlesize,blockhashes[coin->chain->bundlesize],zero,1); - if ( newbp != 0 ) - { - char str2[65]; - printf("EXTEND last bundle %s/%s ht.%d\n",bits256_str(str,newbp->hashes[0]),bits256_str(str2,blockhashes[coin->chain->bundlesize]),newbp->bundleheight); - if ( newbp->queued == 0 ) - iguana_bundleQ(coin,newbp,1000); - } + bp->nextbundlehash2 = blockhashes[coin->chain->bundlesize]; + iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,0); } - else if ( iguana_allhashcmp(coin,bp,blockhashes,num) > 0 ) + //printf("call allhashes\n"); + if ( bp->hdrsi == coin->bundlescount-1 ) + iguana_autoextend(coin,bp); + if ( iguana_allhashcmp(coin,bp,blockhashes,num) > 0 ) return(req); - else if ( bp == coin->current ) - { - //for (i=0; in; i++) - // iguana_blockQ("reissue",coin,bp,i,bp->hashes[i],0); - } //printf("done allhashes\n"); } if ( bp != 0 && (bp->speculative == 0 || num > bp->numspec) && bp->emitfinish == 0 ) @@ -646,7 +657,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct bp->hdrtime = (uint32_t)time(NULL); iguana_blockQ("recvhash2",coin,bp,1,blockhashes[1],0); iguana_blockQ("recvhash3",coin,bp,0,blockhashes[0],0); - iguana_blockQ("recvhash4",coin,bp,coin->chain->bundlesize-1,blockhashes[coin->chain->bundlesize-1],0); + //iguana_blockQ("recvhash4",coin,bp,coin->chain->bundlesize-1,blockhashes[coin->chain->bundlesize-1],0); //printf("matched bundle.%d\n",bp->bundleheight); return(req); } else printf("unexpected mismatch??\n"); @@ -749,6 +760,8 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana } } } + if ( bp != 0 ) + bp->dirty++; if ( 0 )//&& bp != 0 && bp->hdrsi == coin->bundlescount-1 ) { int32_t i; static int32_t numrecv; @@ -761,7 +774,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana } fprintf(stderr,"%s [%d:%d] block.%x | s.%d r.%d copy.%d\n",bits256_str(str,origblock->RO.hash2),bp!=0?bp->hdrsi:-1,bundlei,block->fpipbits,numsaved,numrecv,req->copyflag); } - if ( 0 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && coin->enableCACHE != 0 ) + if ( 1 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && coin->enableCACHE != 0 ) { //printf("reissue hdrs request for [%d]\n",bp->hdrsi); queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); @@ -975,7 +988,7 @@ int32_t iguana_reqblocks(struct iguana_info *coin) if ( coin->blocks.hwmchain.height >= coin->longestchain-1 ) threshold = 1000; else threshold = 300; - if ( strcmp(coin->symbol,"BTC") != 0 ) + if ( strcmp(coin->symbol,"BTC") == 0 ) threshold *= 10; if ( coin->blocks.hwmchain.height < coin->longestchain && ((strcmp(coin->symbol,"BTC") != 0 && coin->backstop != coin->blocks.hwmchain.height+1) || lag > threshold) ) { @@ -1006,8 +1019,8 @@ int32_t iguana_reqblocks(struct iguana_info *coin) iguana_blockQ("mainchain",coin,0,-1,hash2,lag > threshold); flag++; char str[65]; - if ( 1 && (rand() % 1000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) - printf("%s %s MAINCHAIN.%d threshold %.3f %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,coin->backstopmillis,lag); + if ( 1 && (rand() % 10000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) + printf("%s %s MAIN.%d t %.3flag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,lag); } else if ( bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) { @@ -1105,8 +1118,10 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) { if ( (bp= coin->bundles[i]) != 0 && (bp->hdrsi == coin->longestchain/coin->chain->bundlesize || i == coin->bundlescount-1 || bp->numhashes < bp->n) ) { - lag = 30; - if ( bp->bundleheight < coin->longestchain && time(NULL) > bp->issuetime+lag ) + if ( bp == coin->current ) + lag = 3; + else lag = 30; + if ( time(NULL) > bp->issuetime+lag ) { //printf("LAG.%ld hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",time(NULL)-bp->hdrtime,i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); if ( bp->issuetime == 0 ) diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index f6f6ee99d..89183730d 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -102,6 +102,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc } else // do the equivalent of historical, ie mark as spent, linked list, balance { + printf("RT "); if ( iguana_utxoupdate(coin,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,fromheight) == 0 ) return(0); } @@ -388,13 +389,12 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) printf("unexpected spendbp: height.%d bp.[%d] U%d <- S%d.[%d] [ext.%d %s prev.%d]\n",bp->bundleheight+i,spentbp->hdrsi,spent_unspentind,spendind,bp->hdrsi,s->external,bits256_str(str,prevhash),s->prevout); errs++; } - if ( now > spentbp->lastprefetch+30 )//|| (spentbp->dirty % 10000) == 0 ) + if ( now > spentbp->lastprefetch+30 ) { //printf("prefetch[%d] from.[%d] lag.%d\n",spentbp->hdrsi,bp->hdrsi,now - spentbp->lastprefetch); iguana_ramchain_prefetch(coin,&spentbp->ramchain); spentbp->lastprefetch = now; } - spentbp->dirty++; spentU = (void *)(long)((long)spentbp->ramchain.H.data + spentbp->ramchain.H.data->Uoffset); u = &spentU[spent_unspentind]; if ( (spent_pkind= u->pkind) != 0 && spent_pkind < spentbp->ramchain.H.data->numpkinds ) @@ -600,6 +600,7 @@ int32_t iguana_RTutxo(struct iguana_info *coin,struct iguana_bundle *bp,struct i height = bp->bundleheight + bundlei; for (j=0; jhdrsi,bundlei,B[bundlei].txn_count); if ( txidind != T[txidind].txidind || spendind != T[txidind].firstvin ) { printf("RTutxogen: txidind %u != %u nextT[txidind].firsttxidind || spendind %u != %u nextT[txidind].firstvin\n",txidind,T[txidind].txidind,spendind,T[txidind].firstvin); @@ -632,13 +633,13 @@ int32_t iguana_RTutxo(struct iguana_info *coin,struct iguana_bundle *bp,struct i return(-1); } } - else return(0); // coinbase always already spent + else continue; // coinbase always already spent if ( spentbp != 0 && spentbp->ramchain.H.data != 0 && spent_unspentind != 0 && spent_unspentind < spentbp->ramchain.H.data->numunspents ) { spentU = (void *)(long)((long)spentbp->ramchain.H.data + spentbp->ramchain.H.data->Uoffset); u = &spentU[spent_unspentind]; return(iguana_volatileupdate(coin,1,spentbp == bp ? RTramchain : &spentbp->ramchain,spentbp->hdrsi,spent_unspentind,u->pkind,u->value,spendind,height)); - } + } else printf("RTutxo error spentbp.%p u.%u\n",spentbp,spent_unspentind); } } return(-1); @@ -915,6 +916,7 @@ int32_t iguana_realtime_update(struct iguana_info *coin) flag++; if ( iguana_RTutxo(coin,bp,dest,bundlei) < 0 ) return(-1); + //printf(">>>> RT.%d hwm.%d L.%d T.%d U.%d S.%d P.%d X.%d -> size.%ld\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); coin->RTheight++; coin->RTramchain.H.data->numblocks = bundlei + 1; } else printf("error mapchaininit\n");