From b105924d29ad7eb587ca369c142518367b7d8507 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Jan 2016 17:03:16 -0300 Subject: [PATCH] test --- iguana/iguana_bundles.c | 12 +++++++----- iguana/iguana_recv.c | 15 ++++----------- iguana/main.c | 2 +- 3 files changed, 12 insertions(+), 17 deletions(-) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 5984898c7..c51f2837e 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -581,8 +581,8 @@ void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_ { if ( block->fpipbits == 0 && (block->queued == 0 || bp->issued[i] == 0 || now > bp->issued[i]+1) ) { - if ( bp->bundleheight == 20000 ) - printf("(%d:%d) ",bp->hdrsi,i); + //if ( bp->bundleheight == 20000 ) + // printf("(%d:%d) ",bp->hdrsi,i); iguana_blockQ(coin,bp,i,block->RO.hash2,bp->numsaved > bp->n-10); bp->issued[i] = now; counter++; @@ -594,7 +594,8 @@ void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_ } usleep(10000); } - printf("ITERATE bundle.%d n.%d r.%d s.%d finished.%d\n",bp->bundleheight,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish); + if ( counter > 0 ) + printf("ITERATE bundle.%d n.%d r.%d s.%d finished.%d issued.%d\n",bp->bundleheight,bp->n,bp->numrecv,bp->numsaved,bp->emitfinish,counter); if ( bp->emitfinish == 0 ) { if ( bp->numsaved >= bp->n ) @@ -602,8 +603,9 @@ void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_ printf(">>>>>>>>>>>>>>>>>>>>>>> EMIT bundle.%d\n",bp->bundleheight); bp->emitfinish = 1; iguana_emitQ(coin,bp); + coin->numbundlesQ--; return; } - iguana_bundleQ(coin,bp,counter == 0 ? 5000 : 1000); - } + iguana_bundleQ(coin,bp,counter == 0 ? bp->n*5 : bp->n*2); + } else coin->numbundlesQ--; } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 493a17935..3d374967c 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -309,7 +309,7 @@ uint32_t iguana_allhashcmp(struct iguana_info *coin,struct iguana_bundle *bp,bit // iguana_blockQ(coin,bp,i,block->RO.hash2,1), n++; } //printf("ALLHASHES FOUND! %d requested.%d\n",bp->bundleheight,n); - iguana_bundleQ(coin,bp,500 + (rand() % 500)); + iguana_bundleQ(coin,bp,bp->n*2 + (rand() % 500)); return(bp->queued); } } @@ -657,20 +657,13 @@ int32_t iguana_blockQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t if ( block->fpipbits != 0 || block->queued != 0 ) return(0); block->numrequests++; - /*if ( block->rawdata != 0 && block->RO.recvlen != 0 ) - { - printf("free cached copy recvlen.%d need to process it here\n",block->RO.recvlen); - myfree(block->rawdata,block->RO.recvlen); - block->rawdata = 0; - block->RO.recvlen = 0; - }*/ } if ( priority != 0 ) str = "priorityQ", Q = &coin->priorityQ; else str = "blocksQ", Q = &coin->blocksQ; if ( Q != 0 ) { - req = mycalloc('r',1,sizeof(*req)); + req = mycalloc('y',1,sizeof(*req)); req->hash2 = hash2; req->bp = bp; req->bundlei = bundlei; @@ -695,7 +688,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) { uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; char *hashstr=0; bits256 hash2; uint32_t now; struct iguana_block *block; struct iguana_blockreq *req=0; - struct iguana_bundle *bp; struct iguana_peer *ptr; int32_t i,m,z,pend,limit,height=-1,bundlei,datalen,flag = 0; + struct iguana_bundle *bp; struct iguana_peer *ptr; int32_t priority,i,m,z,pend,limit,height=-1,bundlei,datalen,flag = 0; if ( addr->msgcounts.verack == 0 ) return(0); now = (uint32_t)time(NULL); @@ -745,7 +738,6 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) //if ( addr->pendblocks >= limit ) // printf("%s %d overlimit.%d\n",addr->ipaddr,addr->pendblocks,limit); req = queue_dequeue(&coin->priorityQ,0); - int32_t priority; if ( addr->rank != 1 && req == 0 && addr->pendblocks < limit ) { priority = 0; @@ -832,6 +824,7 @@ int32_t iguana_processrecv(struct iguana_info *coin) // single threaded { coin->backstopmillis = OS_milliseconds(); iguana_blockQ(coin,bp,bundlei,iguana_blockhash(coin,coin->backstop),0); + flag++; if ( (rand() % 100) == 0 ) printf("MAINCHAIN.%d threshold %.3f %.3f lag %.3f\n",coin->blocks.hwmchain.height+1,threshold,coin->backstopmillis,lag); } diff --git a/iguana/main.c b/iguana/main.c index 1422df795..0fca33b62 100644 --- a/iguana/main.c +++ b/iguana/main.c @@ -37,7 +37,7 @@ static int32_t initflag; #ifdef __linux__ int32_t IGUANA_NUMHELPERS = 16; #else -int32_t IGUANA_NUMHELPERS = 16; +int32_t IGUANA_NUMHELPERS = 4; #endif char *hash_parser(struct supernet_info *myinfo,char *hashname,cJSON *json,char *remoteaddr)