diff --git a/deprecated/obsolete.h b/deprecated/obsolete.h index 53bb4dbe8..549331d32 100755 --- a/deprecated/obsolete.h +++ b/deprecated/obsolete.h @@ -15490,6 +15490,202 @@ len = 0; } } }*/ + //printf("helper.%d\n",helperid); + /*if ( ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) ) + { + printf("unexpected emitQ or helperQ\n"); + exit(-1); + if ( ptr->bp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 ) + { + idle = 0; + coin->helperdepth++; + iguana_helpertask(fp,&MEM,MEMB,ptr); + coin->helperdepth--; + flag++; + } + myfree(ptr,ptr->allocsize); + }*/ + if ( 0 && (ptr= queue_dequeue(&spendvectorsQ,0)) != 0 ) + { + //printf("spendvectorsQ size.%d\n",queue_size(&spendvectorsQ)); + coin = ptr->coin; + if ( (bp= ptr->bp) != 0 && coin != 0 ) + { + if ( coin->polltimeout < polltimeout ) + polltimeout = coin->polltimeout; + //printf("call spendvectors.%d\n",bp->hdrsi); + if ( coin->PREFETCHLAG > 0 ) + { + iguana_ramchain_prefetch(coin,&bp->ramchain,0); + if ( 0 && bp->hdrsi > 0 ) + iguana_prefetch(coin,bp,bp->hdrsi-1,1); + } + if ( (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,0)) >= 0 ) + { + flag++; + if ( retval > 0 ) + { + printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL)-bp->startutxo); + } // else printf("null retval from iguana_spendvectors.[%d]\n",bp->hdrsi); + bp->utxofinish = (uint32_t)time(NULL); + iguana_balancesQ(coin,bp); + } else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); + } + else if ( coin->active != 0 ) + printf("helper missing param? %p %p\n",coin,bp); + myfree(ptr,ptr->allocsize); + } + void iguana_spendvectorsQ(struct iguana_info *coin,struct iguana_bundle *bp) + { + struct iguana_helper *ptr; + bp->queued = (uint32_t)time(NULL); + ptr = mycalloc('i',1,sizeof(*ptr)); + ptr->allocsize = sizeof(*ptr); + ptr->coin = coin; + ptr->bp = bp, ptr->hdrsi = bp->hdrsi; + ptr->type = 's'; + ptr->starttime = (uint32_t)time(NULL); + queue_enqueue("spendvectorsQ",&spendvectorsQ,&ptr->DL,0); + } + + void iguana_convertQ(struct iguana_info *coin,struct iguana_bundle *bp) + { + struct iguana_helper *ptr; + bp->queued = (uint32_t)time(NULL); + ptr = mycalloc('i',1,sizeof(*ptr)); + ptr->allocsize = sizeof(*ptr); + ptr->coin = coin; + ptr->bp = bp, ptr->hdrsi = bp->hdrsi; + ptr->type = 's'; + ptr->starttime = (uint32_t)time(NULL); + queue_enqueue("convertQ",&convertQ,&ptr->DL,0); + } + + void iguana_balancesQ(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 = 'B'; + ptr->starttime = (uint32_t)time(NULL); + ptr->timelimit = 0; + if ( bp->balancefinish == 0 ) + bp->balancefinish = 1; + coin->pendbalances++; + //printf("BALANCES Q[%d] %s bundle.%d[%d] balances.%u balancefinish.%u\n",coin->pendbalances,coin->symbol,ptr->hdrsi,bp->n,bp->utxofinish,bp->balancefinish); + queue_enqueue("balancesQ",&balancesQ,&ptr->DL,0); + } + + /*int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_helper *ptr) + { + struct iguana_info *coin; struct iguana_peer *addr; struct iguana_bundle *bp,*nextbp; + addr = ptr->addr; + if ( (coin= ptr->coin) != 0 ) + { + if ( (bp= ptr->bp) != 0 ) + { + if ( 0 && ptr->type == 'M' ) + { + if ( (nextbp= ptr->nextbp) != 0 ) + { + bp->mergefinish = nextbp->mergefinish = (uint32_t)time(NULL); + if ( iguana_bundlemergeHT(coin,mem,memB,bp,nextbp,ptr->starttime) < 0 ) + bp->mergefinish = nextbp->mergefinish = 0; + } + } + else if ( ptr->type == 'B' ) + { + printf("helper bundleiters\n"); + iguana_bundleiters(coin,mem,memB,bp,ptr->timelimit); + } + else if ( ptr->type == 'E' ) + { + coin->emitbusy++; + if ( iguana_bundlesaveHT(coin,mem,memB,bp,ptr->starttime) == 0 ) + { + //fprintf(stderr,"emitQ coin.%p bp.[%d]\n",ptr->coin,bp->bundleheight); + bp->emitfinish = (uint32_t)time(NULL) + 1; + coin->numemitted++; + } else bp->emitfinish = 0; + coin->emitbusy--; + } + } else printf("no bundle in helperrequest\n"); + } else printf("no coin in helperrequest\n"); + return(0); + }*/ + + void iguana_mergeQ(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_bundle *nextbp) + { + 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->nextbp = nextbp; + ptr->type = 'M'; + ptr->starttime = (uint32_t)time(NULL); + //printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); + queue_enqueue("helperQ",&helperQ,&ptr->DL,0); + } + if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize ) + { + n = bp->hdrsi; + for (j=0; jbundles[j]) == 0 || bp->emitfinish <= 1 ) + break; + } + if ( j == n ) + { + for (j=0; jbundles[j]) == 0 || (bp->startutxo == 0 && bp->utxofinish == 0) ) + break; + } + if ( j != n ) + { + for (j=0; jbundles[j]) != 0 ) + { + //printf("bundleQ.[%d]\n",j); + bp->balancefinish = bp->startutxo = 0; + bp->utxofinish = 1; + iguana_bundleQ(coin,bp,1000); + } + } + } //else printf("skip A j.%d vs n.%d\n",j,n); + } //else printf("skip j.%d vs n.%d\n",j,n); + } //else printf("skip hdrsi.%d vs %d\n",coin->current->hdrsi,coin->longestchain/coin->chain->bundlesize); + n = queue_size(&balancesQ); + for (iter=0; iterbp; + if ( ptr->coin != coin || bp == 0 || time(NULL) < bp->nexttime ) + { + if ( 0 && bp != 0 ) + printf("skip.%d lag.%ld\n",bp->hdrsi,bp->nexttime-time(NULL)); + //bp->nexttime = (uint32_t)time(NULL); + queue_enqueue("balanceQ",&balancesQ,&ptr->DL,0); + continue; + } + flag++; + if ( coin != 0 ) + { + iguana_balancecalc(coin,bp,bp->bundleheight,bp->bundleheight+bp->n-1); + if ( coin->active == 0 ) + { + printf("detected autopurge after account filecreation. restarting.%s\n",coin->symbol); + coin->active = 1; + } + } + myfree(ptr,ptr->allocsize); + } + } #endif #endif diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 6a8526420..acc0b488a 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -261,20 +261,6 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp) queue_enqueue("emitQ",&emitQ,&ptr->DL,0); } -void iguana_mergeQ(struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_bundle *nextbp) -{ - 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->nextbp = nextbp; - ptr->type = 'M'; - ptr->starttime = (uint32_t)time(NULL); - //printf("%s EMIT.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); - queue_enqueue("helperQ",&helperQ,&ptr->DL,0); -} - void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) { struct iguana_helper *ptr; @@ -292,32 +278,6 @@ void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t ti queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0); } -void iguana_spendvectorsQ(struct iguana_info *coin,struct iguana_bundle *bp) -{ - struct iguana_helper *ptr; - bp->queued = (uint32_t)time(NULL); - ptr = mycalloc('i',1,sizeof(*ptr)); - ptr->allocsize = sizeof(*ptr); - ptr->coin = coin; - ptr->bp = bp, ptr->hdrsi = bp->hdrsi; - ptr->type = 's'; - ptr->starttime = (uint32_t)time(NULL); - queue_enqueue("spendvectorsQ",&spendvectorsQ,&ptr->DL,0); -} - -void iguana_convertQ(struct iguana_info *coin,struct iguana_bundle *bp) -{ - struct iguana_helper *ptr; - bp->queued = (uint32_t)time(NULL); - ptr = mycalloc('i',1,sizeof(*ptr)); - ptr->allocsize = sizeof(*ptr); - ptr->coin = coin; - ptr->bp = bp, ptr->hdrsi = bp->hdrsi; - ptr->type = 's'; - ptr->starttime = (uint32_t)time(NULL); - queue_enqueue("convertQ",&convertQ,&ptr->DL,0); -} - void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp) { struct iguana_helper *ptr; @@ -336,64 +296,101 @@ void iguana_validateQ(struct iguana_info *coin,struct iguana_bundle *bp) } } -void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp) +int32_t iguana_emitfinished(struct iguana_info *coin) { - 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 = 'B'; - ptr->starttime = (uint32_t)time(NULL); - ptr->timelimit = 0; - if ( bp->balancefinish == 0 ) - bp->balancefinish = 1; - coin->pendbalances++; - //printf("BALANCES Q[%d] %s bundle.%d[%d] balances.%u balancefinish.%u\n",coin->pendbalances,coin->symbol,ptr->hdrsi,bp->n,bp->utxofinish,bp->balancefinish); - queue_enqueue("balancesQ",&balancesQ,&ptr->DL,0); + struct iguana_bundle *bp; int32_t i,n = 0; + for (i=0; ibundlescount-1; i++) + { + if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish > 1 ) + n++; + } + return(n); +} + +int32_t iguana_utxofinished(struct iguana_info *coin) +{ + struct iguana_bundle *bp; int32_t i,n = 0; + for (i=0; ibundlescount-1; i++) + { + if ( (bp= coin->bundles[i]) != 0 && bp->utxofinish > 1 ) + n++; + } + return(n); } -/*int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_helper *ptr) +int32_t iguana_convertfinished(struct iguana_info *coin) { - struct iguana_info *coin; struct iguana_peer *addr; struct iguana_bundle *bp,*nextbp; - addr = ptr->addr; - if ( (coin= ptr->coin) != 0 ) + struct iguana_bundle *bp; int32_t i,n = 0; + for (i=0; ibundlescount-1; i++) { - if ( (bp= ptr->bp) != 0 ) + if ( (bp= coin->bundles[i]) != 0 && bp->converted > 1 ) + n++; + } + return(n); +} + +int32_t iguana_balancefinished(struct iguana_info *coin) +{ + struct iguana_bundle *bp; int32_t i,n = 0; + for (i=0; ibundlescount-1; i++) + { + if ( (bp= coin->bundles[i]) != 0 && bp->balancefinish > 1 ) + n++; + } + return(n); +} + +int32_t iguana_utxogen(struct iguana_info *coin,int32_t helperid) +{ + int32_t hdrsi,retval,n,num = 0; struct iguana_bundle *bp; + for (hdrsi=helperid; hdrsibundlescount-1; hdrsi+=IGUANA_NUMHELPERS) + { + if ( (bp= coin->bundles[hdrsi]) == 0 ) + return(-1); + if ( coin->PREFETCHLAG > 0 ) + iguana_ramchain_prefetch(coin,&bp->ramchain,0); + if ( (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,0)) >= 0 ) { - if ( 0 && ptr->type == 'M' ) - { - if ( (nextbp= ptr->nextbp) != 0 ) - { - bp->mergefinish = nextbp->mergefinish = (uint32_t)time(NULL); - if ( iguana_bundlemergeHT(coin,mem,memB,bp,nextbp,ptr->starttime) < 0 ) - bp->mergefinish = nextbp->mergefinish = 0; - } - } - else if ( ptr->type == 'B' ) - { - printf("helper bundleiters\n"); - iguana_bundleiters(coin,mem,memB,bp,ptr->timelimit); - } - else if ( ptr->type == 'E' ) + if ( retval > 0 ) { - coin->emitbusy++; - if ( iguana_bundlesaveHT(coin,mem,memB,bp,ptr->starttime) == 0 ) - { - //fprintf(stderr,"emitQ coin.%p bp.[%d]\n",ptr->coin,bp->bundleheight); - bp->emitfinish = (uint32_t)time(NULL) + 1; - coin->numemitted++; - } else bp->emitfinish = 0; - coin->emitbusy--; - } - } else printf("no bundle in helperrequest\n"); - } else printf("no coin in helperrequest\n"); - return(0); -}*/ + printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL) - bp->startutxo); + num++; + } // else printf("null retval from iguana_spendvectors.[%d]\n",bp->hdrsi); + bp->utxofinish = (uint32_t)time(NULL); + //iguana_balancesQ(coin,bp); + } else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); + } + while ( (n= iguana_utxofinished(coin)) < coin->bundlescount-1 ) + { + printf("helperid.%d utxofinished.%d vs %d\n",helperid,n,coin->bundlescount-1); + sleep(3); + } + for (hdrsi=helperid; hdrsibundlescount-1; hdrsi+=IGUANA_NUMHELPERS) + { + if ( (bp= coin->bundles[hdrsi]) == 0 ) + return(-1); + iguana_convert(coin,bp,0); + } + if ( helperid == 0 ) + { + while ( (n= iguana_convertfinished(coin)) < coin->bundlescount-1 ) + { + printf("helperid.%d convertfinished.%d vs %d\n",helperid,n,coin->bundlescount-1); + sleep(3); + } + if ( iguana_spendvectorsaves(coin) == 0 ) + { + for (hdrsi=0; hdrsibundlescount-1; hdrsi++) + iguana_balancenormal(coin,bp,0,bp->n-1); + } else printf("error saving spendvectors\n"); + coin->spendvectorsaved = (uint32_t)time(NULL); + } + return(num); +} void iguana_helper(void *arg) { - cJSON *argjson=0; int32_t iter,n,retval,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0; + cJSON *argjson=0; int32_t iter,i,n,polltimeout,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"); @@ -411,22 +408,22 @@ void iguana_helper(void *arg) flag = 0; allcurrent = 2; polltimeout = 100; - //printf("helper.%d\n",helperid); - /*if ( ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) ) + for (i=0; ibp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 ) + if ( (coin= Coins[i]) != 0 ) { - idle = 0; - coin->helperdepth++; - iguana_helpertask(fp,&MEM,MEMB,ptr); - coin->helperdepth--; - flag++; + if ( coin->spendvectorsaved == 1 ) + { + iguana_utxogen(coin,helperid); + while ( coin->spendvectorsaved == 1 ) + { + printf("helperid.%d waiting for spendvectorsaved.%u\n",helperid,coin->spendvectorsaved); + sleep(3); + } + } } - myfree(ptr,ptr->allocsize); - }*/ - if ( (type & (1 << 0)) != 0 ) + } + //if ( (type & (1 << 0)) != 0 ) { n = queue_size(&bundlesQ); for (iter=0; itercoin; - if ( (bp= ptr->bp) != 0 && coin != 0 ) - { - if ( coin->polltimeout < polltimeout ) - polltimeout = coin->polltimeout; - //printf("call spendvectors.%d\n",bp->hdrsi); - if ( coin->PREFETCHLAG > 0 ) - { - iguana_ramchain_prefetch(coin,&bp->ramchain,0); - if ( 0 && bp->hdrsi > 0 ) - iguana_prefetch(coin,bp,bp->hdrsi-1,1); - } - if ( (retval= iguana_spendvectors(coin,bp,&bp->ramchain,0,bp->n,0)) >= 0 ) - { - flag++; - if ( retval > 0 ) - { - printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL)-bp->startutxo); - } // else printf("null retval from iguana_spendvectors.[%d]\n",bp->hdrsi); - bp->utxofinish = (uint32_t)time(NULL); - iguana_balancesQ(coin,bp); - } else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); - } - else if ( coin->active != 0 ) - printf("helper missing param? %p %p\n",coin,bp); - myfree(ptr,ptr->allocsize); - } - n = queue_size(&convertQ); - for (iter=0; itercoin; - if ( (bp= ptr->bp) != 0 && coin != 0 && coin->active != 0 ) - iguana_convert(coin,bp,0);//,&bp->ramchain); - myfree(ptr,ptr->allocsize); - } n = queue_size(&validateQ); for (iter=0; iterallocsize); flag++; } - } - if ( queue_size(&spendvectorsQ) != 0 || queue_size(&convertQ) != 0 || queue_size(&bundlesQ) > 1 ) + }*/ + if ( queue_size(&bundlesQ) > 1 ) allcurrent = 0; if ( flag != 0 ) usleep(polltimeout * 100 + 1); diff --git a/iguana/iguana777.h b/iguana/iguana777.h index a556b5b05..588eb3f72 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -812,7 +812,7 @@ struct iguana_bloominds iguana_calcbloom(bits256 hash2); int32_t iguana_bloomfind(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit); struct iguana_bloominds iguana_bloomset(struct iguana_info *coin,struct iguana_bloom16 *bloom,int32_t incr,struct iguana_bloominds bit); int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramchain,struct iguana_bundle *bp); -void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp); +//void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp); int32_t iguana_balanceflush(struct iguana_info *coin,int32_t refhdrsi,int32_t purgedist); int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti,int32_t max); int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight); @@ -837,7 +837,7 @@ int32_t iguana_setmaxbundles(struct iguana_info *coin); void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp); uint32_t iguana_sparseaddtx(uint8_t *bits,int32_t width,uint32_t tablesize,bits256 txid,struct iguana_txid *T,uint32_t txidind,struct iguana_ramchain *ramchain); void iguana_launchpeer(struct iguana_info *coin,char *ipaddr); -void iguana_spendvectorsQ(struct iguana_info *coin,struct iguana_bundle *bp); +//void iguana_spendvectorsQ(struct iguana_info *coin,struct iguana_bundle *bp); int8_t iguana_blockstatus(struct iguana_info *coin,struct iguana_block *block); int32_t iguana_peerslotinit(struct iguana_info *coin,struct iguana_peer *addr,int32_t slotid,uint64_t ipbits); void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile); @@ -848,7 +848,7 @@ int32_t bitcoin_pubkeylen(const uint8_t *pubkey); struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p,struct iguana_bundle *bp,int32_t i); void *iguana_ramchainfile(struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *R,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block); int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block); -void iguana_convertQ(struct iguana_info *coin,struct iguana_bundle *bp); +//void iguana_convertQ(struct iguana_info *coin,struct iguana_bundle *bp); void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp,int32_t RTflag);//,struct iguana_ramchain *ramchain); int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle *bp,int32_t priority,double mult); //int32_t iguana_blocksmissing(struct iguana_info *coin,int32_t *nonzp,uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1],bits256 hashes[],double mult,struct iguana_bundle *bp,int32_t capacity); @@ -856,10 +856,16 @@ FILE *myfopen(char *fname,char *mode); int32_t myfclose(FILE *fp); void iguana_prefetch(struct iguana_info *coin,struct iguana_bundle *bp,int32_t width,int32_t flags); int32_t iguana_walkchain(struct iguana_info *coin); +int32_t iguana_balancenormal(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight); +int32_t iguana_spendvectorsaves(struct iguana_info *coin); +int32_t iguana_convertfinished(struct iguana_info *coin); +int32_t iguana_emitfinished(struct iguana_info *coin); +int32_t iguana_utxofinished(struct iguana_info *coin); +int32_t iguana_balancefinished(struct iguana_info *coin); extern int32_t HDRnet,netBLOCKS; -extern queue_t bundlesQ,validateQ,emitQ,balancesQ,TerminateQ,spendvectorsQ,convertQ; +extern queue_t bundlesQ,validateQ,emitQ,TerminateQ; extern char GLOBALTMPDIR[]; #include "../includes/iguana_api.h" diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index ad37b0665..e43918bff 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -731,7 +731,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp,int return(bp->estsize); } -int32_t iguana_bundlefinish(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; #ifdef IGUANA_SERIALIZE_SPENDVECTORGEN @@ -759,7 +759,7 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp) } //else printf("%u notready.%d postfinish.%d startutxo.%u prevbp.%d %u current.%d\n",(uint32_t)time(NULL),bp->hdrsi,i,bp->startutxo,prevbp!=0?prevbp->hdrsi:-1,prevbp!=0?prevbp->emitfinish:0,coin->current!=0?coin->current->hdrsi:-1); return(0); -} +}*/ int32_t iguana_bundlefinalize(struct iguana_info *coin,struct iguana_bundle *bp,struct OS_memspace *mem,struct OS_memspace *memB) { @@ -824,7 +824,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru bp->nexttime = (uint32_t)time(NULL);//cbrt(bp->hdrsi - starti)/10; if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) ) iguana_bundlehdr(coin,bp,starti); - else if ( bp->emitfinish != 0 ) + /*else if ( bp->emitfinish != 0 ) { if ( bp->utxofinish > 1 ) { @@ -844,8 +844,8 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru return(0); } //else printf("finish incomplete.%d\n",bp->hdrsi); } - } - else if ( bp->numsaved >= bp->n )//&& (bp->isRT == 0 || coin->RTheight > bp->bundleheight+bp->n+coin->minconfirms) ) + }*/ + else if ( bp->emitfinish == 0 && bp->numsaved >= bp->n ) { if ( iguana_bundlefinalize(coin,bp,mem,memB) >= 0 ) return(0); @@ -860,9 +860,6 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru // bp->nexttime--; if ( bp->isRT == 0 && bp == coin->current && counter > 0 ) printf("ITER.rt%d now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->isRT,(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->hdrsi == starti && bp->isRT == 0 ) - { - } } else bp->nexttime += 3; //printf("done hdrs.%d\n",bp->hdrsi); iguana_bundleQ(coin,bp,1000); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 3e85a4521..f0178202b 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -2578,6 +2578,7 @@ int32_t iguana_bundlemergeHT(struct iguana_info *coin,struct OS_memspace *mem,st return(retval); } +#ifdef later void iguana_ramchainmerge(struct iguana_info *coin) // jl777: verify prev/next hash2 { struct iguana_bundle *bp,*nextbp,*A,*B; int64_t total = 0; int32_t n,flag = 0; @@ -2619,3 +2620,4 @@ void iguana_ramchainmerge(struct iguana_info *coin) // jl777: verify prev/next h printf("bundles.%d\n",n); } } +#endif diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index b40cf3309..08861b3f3 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -1517,7 +1517,7 @@ int32_t iguana_processrecv(struct iguana_info *coin) // single threaded //printf("call iguana_realtime_update i.%d\n",i); } flag += (i > 0); - coin->RTramchain_busy = (coin->RTgenesis == 0 || queue_size(&balancesQ) != 0); + coin->RTramchain_busy = (coin->RTgenesis == 0); iguana_jsonQ(); if ( hwmheight != coin->blocks.hwmchain.height ) flag = 1; diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 180cd226c..554d0f124 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -493,7 +493,7 @@ struct iguana_bundle *iguana_externalspent(struct iguana_info *coin,bits256 *pre //printf("%s height.%d firstvout.%d prev.%d ->U%d\n",bits256_str(str,prev_hash),height,TX.firstvout,prev_vout,unspentind); now = (uint32_t)time(NULL); duration = (OS_milliseconds() - startmillis); - if ( ((uint64_t)coin->txidfind_num % 5000000) == 2000000 ) + if ( 0 && ((uint64_t)coin->txidfind_num % 5000000) == 2000000 ) printf("%p iguana_txidfind.[%.0f] ave %.2f micros, total %.2f seconds | duration %.3f millis\n",spentbp->ramchain.txbits,coin->txidfind_num,(coin->txidfind_totalmillis*1000.)/coin->txidfind_num,coin->txidfind_totalmillis/1000.,duration); coin->txidfind_totalmillis += duration; coin->txidfind_num += 1.; @@ -868,7 +868,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp,st } for (k=0; khdrsi,i,(uint32_t)time(NULL)-starttime,spendind); u = 0; s = &S[spendind]; @@ -1694,19 +1694,11 @@ void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp,int32_t RT } total += converted; printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)total,(long long)total_tmpspends,(int32_t)depth); - if ( RTflag == 0 && m == n-1 ) - { - if ( iguana_spendvectorsaves(coin) == 0 ) - { - for (i=0; ibundles[i]); - } - } } depth--; } -int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight) +/*int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight) { int32_t retval=-1,i,n,flag = 0; if ( bp->balancefinish > 1 ) @@ -1757,7 +1749,8 @@ int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int } } return(flag); -} +}*/ + void iguana_RTramchainfree(struct iguana_info *coin) { printf("free RTramchain\n"); diff --git a/iguana/main.c b/iguana/main.c index a7fdc52a7..7c8030ba0 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -61,7 +61,7 @@ struct iguana_info *Coins[IGUANA_MAXCOINS]; char Userhome[512],GLOBALTMPDIR[512] = "tmp"; int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel; uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100; -queue_t helperQ,jsonQ,finishedQ,bundlesQ,validateQ,emitQ,balancesQ,TerminateQ,spendvectorsQ,convertQ; +queue_t helperQ,jsonQ,finishedQ,bundlesQ,validateQ,emitQ,TerminateQ; struct supernet_info MYINFO,**MYINFOS; static int32_t initflag; int32_t HDRnet,netBLOCKS; @@ -369,7 +369,7 @@ mksquashfs DB/BTC BTC.squash1M -b 1048576 void mainloop(struct supernet_info *myinfo) { - int32_t i,j,n,iter,flag,isRT,numpeers; struct iguana_info *coin; struct iguana_helper *ptr; struct iguana_bundle *bp; + int32_t i,flag,isRT,numpeers; struct iguana_info *coin; struct iguana_bundle *bp; sleep(3); printf("mainloop\n"); while ( 1 ) @@ -388,61 +388,13 @@ void mainloop(struct supernet_info *myinfo) { isRT *= coin->isRT; numpeers += coin->peers.numranked; - if ( (bp= coin->current) != 0 && bp->hdrsi == coin->longestchain/coin->chain->bundlesize ) + if ( coin->spendvectorsaved == 0 ) { - n = bp->hdrsi; - for (j=0; j= coin->bundlescount-1 ) { - if ( (bp= coin->bundles[j]) == 0 || bp->emitfinish <= 1 ) - break; - } - if ( j == n ) - { - for (j=0; jbundles[j]) == 0 || (bp->startutxo == 0 && bp->utxofinish == 0) ) - break; - } - if ( j != n ) - { - for (j=0; jbundles[j]) != 0 ) - { - //printf("bundleQ.[%d]\n",j); - bp->balancefinish = bp->startutxo = 0; - bp->utxofinish = 1; - iguana_bundleQ(coin,bp,1000); - } - } - } //else printf("skip A j.%d vs n.%d\n",j,n); - } //else printf("skip j.%d vs n.%d\n",j,n); - } //else printf("skip hdrsi.%d vs %d\n",coin->current->hdrsi,coin->longestchain/coin->chain->bundlesize); - n = queue_size(&balancesQ); - for (iter=0; iterbp; - if ( ptr->coin != coin || bp == 0 || time(NULL) < bp->nexttime ) - { - if ( 0 && bp != 0 ) - printf("skip.%d lag.%ld\n",bp->hdrsi,bp->nexttime-time(NULL)); - //bp->nexttime = (uint32_t)time(NULL); - queue_enqueue("balanceQ",&balancesQ,&ptr->DL,0); - continue; - } - flag++; - if ( coin != 0 ) - { - iguana_balancecalc(coin,bp,bp->bundleheight,bp->bundleheight+bp->n-1); - if ( coin->active == 0 ) - { - printf("detected autopurge after account filecreation. restarting.%s\n",coin->symbol); - coin->active = 1; - } - } - myfree(ptr,ptr->allocsize); + if ( iguana_utxofinished(coin) < coin->bundlescount-1 || iguana_balancefinished(coin) < coin->bundlescount-1 ) + coin->spendvectorsaved = 1; + else coin->spendvectorsaved = (uint32_t)time(NULL); } } if ( (bp= coin->current) != 0 && coin->stucktime != 0 && coin->isRT == 0 && coin->RTheight == 0 && (time(NULL) - coin->stucktime) > coin->MAXSTUCKTIME ) @@ -1180,7 +1132,6 @@ void iguana_main(void *arg) iguana_initQ(&finishedQ,"finishedQ"); iguana_initQ(&bundlesQ,"bundlesQ"); iguana_initQ(&validateQ,"validateQ"); - iguana_initQ(&balancesQ,"balancesQ"); myinfo->rpcport = IGUANA_RPCPORT; strcpy(myinfo->rpcsymbol,"BTCD"); if ( arg != 0 )