From ebf3fb6e90d183beae9bbd045f36ca7a64eac887 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 3 Apr 2016 22:34:04 -0500 Subject: [PATCH] test --- iguana/iguana777.c | 75 ++++++++++++++++++++++------------------ iguana/iguana_bundles.c | 11 +++--- iguana/iguana_unspents.c | 15 +++++--- iguana/main.c | 2 +- 4 files changed, 58 insertions(+), 45 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 9dcff0235..68f91dad5 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -459,48 +459,55 @@ void iguana_helper(void *arg) myfree(ptr,ptr->allocsize); } else break; } - if ( (ptr= queue_dequeue(&convertQ,0)) != 0 ) - { - coin = ptr->coin; - if ( (bp= ptr->bp) != 0 && coin != 0 ) - iguana_convert(coin,bp); - myfree(ptr,ptr->allocsize); - } } - if ( (type & (1 << 1)) != 0 && (ptr= queue_dequeue(&spendvectorsQ,0)) != 0 ) + if ( (type & (1 << 1)) != 0 ) { - //printf("spendvectorsQ size.%d\n",queue_size(&spendvectorsQ)); - coin = ptr->coin; - if ( (bp= ptr->bp) != 0 && coin != 0 ) + if ( (ptr= queue_dequeue(&spendvectorsQ,0)) != 0 ) { - if ( coin->polltimeout < polltimeout ) - polltimeout = coin->polltimeout; - //printf("call spendvectors.%d\n",bp->hdrsi); - if ( (retval= iguana_spendvectors(coin,bp)) >= 0 ) + //printf("spendvectorsQ size.%d\n",queue_size(&spendvectorsQ)); + coin = ptr->coin; + if ( (bp= ptr->bp) != 0 && coin != 0 ) { - flag++; - if ( retval > 0 ) + if ( coin->polltimeout < polltimeout ) + polltimeout = coin->polltimeout; + //printf("call spendvectors.%d\n",bp->hdrsi); + if ( (retval= iguana_spendvectors(coin,bp)) >= 0 ) { - printf("GENERATED UTXO.%d for ht.%d duration %d seconds\n",bp->hdrsi,bp->bundleheight,(uint32_t)time(NULL)-bp->startutxo); - bp->utxofinish = (uint32_t)time(NULL); - bp->balancefinish = 0; - } - if ( bp->balancefinish == 0 ) - 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); - 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); + 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); + bp->utxofinish = (uint32_t)time(NULL); + bp->balancefinish = 0; + } + if ( bp->balancefinish == 0 ) + iguana_balancesQ(coin,bp); + } else printf("UTXO gen.[%d] utxo error\n",bp->hdrsi); + } else if ( coin->active != 0 ) - printf("helper validate missing param? %p %p\n",ptr->coin,ptr->bp); + printf("helper missing param? %p %p\n",coin,bp); myfree(ptr,ptr->allocsize); - flag++; } + n = queue_size(&convertQ); + for (iter=0; itercoin; + if ( (bp= ptr->bp) != 0 && coin != 0 && coin->active != 0 ) + iguana_convert(coin,bp); + myfree(ptr,ptr->allocsize); + } + n = queue_size(&validateQ); + for (iter=0; iterbp != 0 && (coin= ptr->coin) != 0 && coin->active != 0 ) + flag += iguana_bundlevalidate(ptr->coin,ptr->bp); + else if ( coin->active != 0 ) + printf("helper validate missing param? %p %p\n",ptr->coin,ptr->bp); + myfree(ptr,ptr->allocsize); + flag++; + } } if ( queue_size(&spendvectorsQ) != 0 || queue_size(&bundlesQ) > 10 ) allcurrent = 0; diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 9bd5f0c52..29da39f79 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -654,7 +654,8 @@ void iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle *bp int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti) { - uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t avail,dist,counter=0; + //uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1]; int32_t avail; + int32_t dist,counter=0; if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) ) printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec); dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0); @@ -667,8 +668,8 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32 if ( bp == coin->current && bp->speculative != 0 ) { //printf("iguana_bundlehdr.[%d] %d %s\n",bp->hdrsi,bp->numspec,bits256_str(str,bp->hashes[0])); - if ( iguana_blocksmissing(coin,&avail,missings,0,bp,0,7) > 0 ) - iguana_bundleissuemissing(coin,bp,missings,3); + //if ( iguana_blocksmissing(coin,&avail,missings,0,bp,0,7) > 0 ) + // iguana_bundleissuemissing(coin,bp,missings,3); } queue_enqueue("hdrsQ",&coin->hdrsQ,queueitem(bits256_str(str,bp->hashes[0])),1); } @@ -677,8 +678,8 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32 if ( time(NULL) > (bp->issued[1] + 10 + dist) ) { //printf("request speculative[1] numspec.%d for bp.[%d] bp->speculative.%p enable.%d\n",bp->numspec,bp->hdrsi,bp->speculative,coin->enableCACHE); - iguana_blockQ("getnexthdr",coin,bp,-1,bp->speculative[1],1); - bp->issued[1] = (uint32_t)time(NULL); + //iguana_blockQ("getnexthdr",coin,bp,-1,bp->speculative[1],1); + //bp->issued[1] = (uint32_t)time(NULL); } } return(counter); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index b797cd235..b31543d76 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1358,7 +1358,8 @@ void iguana_RTramchainalloc(struct iguana_info *coin,struct iguana_bundle *bp) if ( coin->PREFETCHLAG != 0 ) { iguana_ramchain_prefetch(coin,&coin->RTramchain,0); - iguana_prefetch(coin,bp,3,0); + iguana_prefetch(coin,bp,7,0); + iguana_prefetch(coin,bp,22,1); } } } @@ -1714,6 +1715,9 @@ int32_t iguana_spendvectorsaves(struct iguana_info *coin) int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *spentbp) { struct iguana_bundle *bp; int16_t spent_hdrsi; uint32_t numpkinds; struct iguana_unspent *spentU; struct iguana_spendvector *vec; int32_t i,converted,j,n = coin->bundlescount; + if ( spentbp->converted != 0 ) + return(-1); + spentbp->converted = 1; spent_hdrsi = spentbp->hdrsi; numpkinds = spentbp->ramchain.H.data->numpkinds; iguana_ramchain_prefetch(coin,&spentbp->ramchain,0); @@ -1750,9 +1754,9 @@ int32_t iguana_spendvectorconvs(struct iguana_info *coin,struct iguana_bundle *s void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp) { - static int64_t total; + static int64_t total,depth; int32_t i,n,m,converted; int64_t total_tmpspends; double startmillis = OS_milliseconds(); - printf("start conversion.[%d]\n",bp->hdrsi); + depth++; if ( (converted= iguana_spendvectorconvs(coin,bp)) < 0 ) printf("error ram balancecalc.[%d]\n",bp->hdrsi); else @@ -1763,15 +1767,16 @@ void iguana_convert(struct iguana_info *coin,struct iguana_bundle *bp) if ( coin->bundles[i] != 0 ) { total_tmpspends += coin->bundles[i]->numtmpspends; - if ( coin->bundles[i]->converted != 0 ) + if ( coin->bundles[i]->converted > 1 ) m++; } } total += converted; - printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)total,(long long)total_tmpspends); + 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 ( m == n-1 ) iguana_spendvectorsaves(coin); } + depth--; } int32_t iguana_balancecalc(struct iguana_info *coin,struct iguana_bundle *bp,int32_t startheight,int32_t endheight) diff --git a/iguana/main.c b/iguana/main.c index c492da302..833e45094 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -46,7 +46,7 @@ cJSON *API_json; #ifdef __linux__ int32_t IGUANA_NUMHELPERS = 16; #else -int32_t IGUANA_NUMHELPERS = 4; +int32_t IGUANA_NUMHELPERS = 8; #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[]; };