diff --git a/iguana/iguana777.c b/iguana/iguana777.c index b0709e6eb..c045cb37a 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -380,7 +380,7 @@ void iguana_balancesQ(struct iguana_info *coin,struct iguana_bundle *bp) void iguana_helper(void *arg) { - cJSON *argjson=0; int32_t retval,polltimeout,type,helperid=rand(),flag,allcurrent,idle=0; + cJSON *argjson=0; int32_t iter,retval,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"); @@ -415,32 +415,37 @@ void iguana_helper(void *arg) }*/ if ( (type & (1 << 0)) != 0 ) { - if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) + for (iter=0; iter<2048; iter++) { - idle = 0; - coin = ptr->coin; - if ( (bp= ptr->bp) != 0 && coin != 0 ) + if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) { - if ( coin->polltimeout < polltimeout ) - polltimeout = coin->polltimeout; - //printf("[%d] bundleQ size.%d lag.%ld\n",bp->hdrsi,queue_size(&bundlesQ),time(NULL) - bp->nexttime); - coin->numbundlesQ--; - if ( coin->started != 0 && time(NULL) >= bp->nexttime && coin->active != 0 ) - flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit,IGUANA_DEFAULTLAG); - else + idle = 0; + coin = ptr->coin; + if ( (bp= ptr->bp) != 0 && coin != 0 ) { - //printf("skip.%d lag.%ld coin->active.%d\n",bp->hdrsi,time(NULL)-bp->nexttime,coin->active); - allcurrent = 0; - iguana_bundleQ(ptr->coin,bp,1000); + if ( coin->polltimeout < polltimeout ) + polltimeout = coin->polltimeout; + if ( coin->current != 0 && coin->current->hdrsi != coin->bundlescount-1 ) + allcurrent = 0; + //printf("[%d] bundleQ size.%d lag.%ld\n",bp->hdrsi,queue_size(&bundlesQ),time(NULL) - bp->nexttime); + coin->numbundlesQ--; + if ( coin->started != 0 && (bp->nexttime == 0 || time(NULL) >= bp->nexttime) && coin->active != 0 ) + { + flag += iguana_bundleiters(ptr->coin,&MEM,MEMB,bp,ptr->timelimit,IGUANA_DEFAULTLAG); + } + else + { + //printf("skip.[%d] nexttime.%u lag.%ld coin->active.%d\n",bp->hdrsi,bp->nexttime,time(NULL)-bp->nexttime,coin->active); + allcurrent = 0; + iguana_bundleQ(ptr->coin,bp,1000); + } } - if ( coin->current != 0 && coin->current->hdrsi != coin->bundlescount-1 ) - allcurrent = 0; - } - else //if ( coin->active != 0 ) - printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit); - myfree(ptr,ptr->allocsize); + else //if ( coin->active != 0 ) + printf("helper missing param? %p %p %u\n",ptr->coin,bp,ptr->timelimit); + myfree(ptr,ptr->allocsize); + } else break; } - else if ( (ptr= queue_dequeue(&validateQ,0)) != 0 ) + if ( (ptr= queue_dequeue(&validateQ,0)) != 0 ) { if ( ptr->bp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 ) flag += iguana_bundlevalidate(ptr->coin,ptr->bp); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 3e4c2c357..f8385bc35 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -770,7 +770,6 @@ int32_t iguana_bundlefinish(struct iguana_info *coin,struct iguana_bundle *bp) } return(1); } - bp->nexttime--; //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); } @@ -827,7 +826,7 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru if ( bp->hdrsi == coin->bundlescount-1 ) iguana_autoextend(coin,bp); //printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(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->nexttime = (uint32_t)time(NULL);//+ sqrt(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 ) @@ -850,7 +849,6 @@ int32_t iguana_bundleiters(struct iguana_info *coin,struct OS_memspace *mem,stru return(0); } //else printf("finish incomplete.%d\n",bp->hdrsi); } - bp->nexttime--; } else if ( bp->numsaved >= bp->n )//&& (bp->isRT == 0 || coin->RTheight > bp->bundleheight+bp->n+coin->minconfirms) ) { diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 4f50ce5a0..3567f43f6 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -637,7 +637,7 @@ void iguana_startconnection(void *arg) if ( addr->usock < 0 || coin->peers.shuttingdown != 0 ) { strcpy(ipaddr,addr->ipaddr); - printf("refused PEER KILLED. slot.%d for %s:%d usock.%d\n",addr->addrind,ipaddr,coin->chain->portp2p,addr->usock); + //printf("refused PEER KILLED. slot.%d for %s:%d usock.%d\n",addr->addrind,ipaddr,coin->chain->portp2p,addr->usock); iguana_iAkill(coin,addr,1); } else @@ -736,7 +736,7 @@ void *iguana_iAddriterator(struct iguana_info *coin,struct iguana_iAddr *iA) //printf("call rwIaddrInd\n"); if ( iguana_rwiAddrind(coin,1,iA,iA->hh.itemind) > 0 ) { - printf("iA.%p iguana_startconnection.(%s) status.%d pending.%d\n",iA,addr->ipaddr,iA->status,addr->pending); + //printf("iA.%p iguana_startconnection.(%s) status.%d pending.%d\n",iA,addr->ipaddr,iA->status,addr->pending); iA->status = IGUANA_PEER_CONNECTING; addr->pending = (uint32_t)time(NULL); iguana_launch(coin,"connection",iguana_startconnection,addr,IGUANA_CONNTHREAD); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 1589f17b3..0f46b8d1d 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -759,7 +759,7 @@ int32_t iguana_spendvectorsave(struct iguana_info *coin,struct iguana_bundle *bp int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) { static uint64_t total,emitted; - int32_t spendind,n,txidind,errs=0,emit=0,i,j,k; + int32_t spendind,n,txidind,errs=0,emit=0,i,j,k; double startmillis; uint32_t spent_unspentind,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata; struct iguana_bundle *spentbp; struct iguana_blockRO *B; char str[65]; bits256 prevhash; struct iguana_unspent *u,*spentU; struct iguana_txid *T; @@ -778,7 +778,8 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) } ptr = mycalloc('x',sizeof(*ptr),n); total += n; - printf("start UTXOGEN.%d max.%d ptr.%p\n",bp->bundleheight,n,ptr); + startmillis = OS_milliseconds(); + printf("start UTXOGEN.%d max.%d ptr.%p millis.%.3f\n",bp->bundleheight,n,ptr,startmillis); txidind = spendind = rdata->firsti; if ( coin->PREFETCHLAG != 0 ) { @@ -891,7 +892,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) if ( errs == 0 && emit >= 0 ) { emitted += emit; - if ( 0 && coin->balanceswritten <= 1 ) + if ( coin->balanceswritten <= 1 ) { if ( bp->tmpspends != 0 ) printf("unexpected tmpspends? [%d] numtmpspends.%d vs emit.%d\n",bp->hdrsi,bp->numtmpspends,emit); @@ -902,7 +903,7 @@ int32_t iguana_spendvectors(struct iguana_info *coin,struct iguana_bundle *bp) } if ( ptr != 0 ) myfree(ptr,sizeof(*ptr) * n); - printf("duration.%d spendvectors %d spendinds.[%d] errs.%d [%.2f%%] emitted.%d %s of %d\n",(uint32_t)time(NULL)-starttime,spendind,bp->hdrsi,errs,100.*(double)emitted/(total+1),emit,mbstr(str,sizeof(*ptr) * emit),n); + printf("duration.%d [millis %.3f] vectors %d inds.[%d] errs.%d [%.2f%%] emitted.%d %s of %d\n",(uint32_t)time(NULL)-starttime,OS_milliseconds()-startmillis,spendind,bp->hdrsi,errs,100.*(double)emitted/(total+1),emit,mbstr(str,sizeof(*ptr) * emit),n); if ( errs != 0 ) exit(-1); return(-errs); diff --git a/iguana/main.c b/iguana/main.c index 4b389d567..122afda35 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -44,9 +44,9 @@ static int32_t initflag; int32_t HDRnet,netBLOCKS; cJSON *API_json; #ifdef __linux__ -int32_t IGUANA_NUMHELPERS = 4; +int32_t IGUANA_NUMHELPERS = 16; #else -int32_t IGUANA_NUMHELPERS = 2; +int32_t IGUANA_NUMHELPERS = 4; #endif struct iguana_jsonitem { struct queueitem DL; struct supernet_info *myinfo; uint32_t fallback,expired,allocsize; char **retjsonstrp; char remoteaddr[64]; uint16_t port; char jsonstr[]; }; @@ -365,12 +365,7 @@ void mainloop(struct supernet_info *myinfo) { isRT *= coin->isRT; numpeers += coin->peers.numranked; - //printf("main active.%d started.%p\n",coin->active,coin->started); - //iguana_bundlestats(coin,str,IGUANA_DEFAULTLAG); - //printf("done main active.%d started.%p\n",coin->active,coin->started); - //iguana_reqblocks(coin); - //printf("done2 main active.%d started.%p\n",coin->active,coin->started); - if ( (ptr= queue_dequeue(&balancesQ,0)) != 0 ) + if ( queue_size(&bundlesQ) < 2 && (ptr= queue_dequeue(&balancesQ,0)) != 0 ) { bp = ptr->bp; if ( ptr->coin != coin || bp == 0 || time(NULL) < bp->nexttime )