From 1b252c7b8b48c36058ae344b57206f3d4d496b64 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 13 Jan 2016 19:11:22 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 4 ++-- iguana/iguana777.h | 2 ++ iguana/iguana_peers.c | 30 ++++++++++++++++-------------- iguana/main.c | 2 +- 4 files changed, 21 insertions(+), 17 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 4cdaadae8..7f5ee4aad 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -260,7 +260,7 @@ void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t ti ptr->timelimit = timelimit; coin->numbundlesQ++; //printf("%s bundle.%d[%d] emitfinish.%u\n",coin->symbol,ptr->hdrsi,bp->n,bp->emitfinish); - queue_enqueue("helperQ",&helperQ,&ptr->DL,0); + queue_enqueue("bundlesQ",&bundlesQ,&ptr->DL,0); } int32_t iguana_helpertask(FILE *fp,struct OS_memspace *mem,struct OS_memspace *memB,struct iguana_helper *ptr) @@ -323,7 +323,7 @@ void iguana_helper(void *arg) flag = 0; if ( (ptr= queue_dequeue(&helperQ,0)) != 0 ) { - if ( (coin= ptr->coin) != 0 && myallocated(0,-1) > coin->MAXMEM && coin->helperdepth > IGUANA_NUMHELPERS/2 && ptr->type == 'B' ) + if ( (coin= ptr->coin) != 0 && myallocated(0,-1) > coin->MAXMEM ) queue_enqueue("reQ",&helperQ,&ptr->DL,0); else { diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 5ab408325..0737f9450 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -688,6 +688,8 @@ cJSON *iguana_pubkeyjson(struct iguana_info *coin,char *pubkeystr); void iguana_bundleQ(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit); void iguana_bundleiters(struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit); +extern queue_t bundlesQ; + #include "../includes/iguana_api.h" #endif diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index 1cc659250..1f49122db 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -982,24 +982,26 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr) } } } - if ( flag == 0 ) - { - if ( run++ > 1000 ) - { - //printf("sleep\n"); - usleep(100000); - } - else if ( addr->rank != 1 ) - usleep(coin->polltimeout*100 + 0*(rand() % (coin->polltimeout*100))); - else usleep(100 + coin->polltimeout*1000); - } else run >>= 2; } if ( flag != 0 ) run = 0; - else if ( addr->supernet != 0 && time(NULL) > lastping+10 ) + else if ( flag == 0 ) + { + if ( addr->supernet != 0 && time(NULL) > lastping+10 ) + { + iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0); + lastping = (uint32_t)time(NULL); + } + } else run >>= 2; + if ( flag == 0 )//|| addr->rank >= (coin->peers.numranked>>1) ) { - iguana_send_supernet(coin,addr,"{\"agent\":\"SuperNET\",\"method\":\"getpeers\"}",0); - lastping = (uint32_t)time(NULL); + struct iguana_helper *ptr; + if ( (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) + { + if ( ptr->bp != 0 ) + iguana_bundleiters(coin,ptr->bp,ptr->timelimit); + myfree(ptr,ptr->allocsize); + } } if ( coin->isRT != 0 && addr->rank > coin->MAXPEERS && (rand() % 100) == 0 ) { diff --git a/iguana/main.c b/iguana/main.c index 7e43bc05c..49f428632 100644 --- a/iguana/main.c +++ b/iguana/main.c @@ -32,7 +32,7 @@ int32_t USE_JAY,FIRST_EXTERNAL,IGUANA_disableNXT,Debuglevel; uint32_t prices777_NXTBLOCK,MAX_DEPTH = 100; char NXTAPIURL[256],IGUANA_NXTADDR[256],IGUANA_NXTACCTSECRET[256]; uint64_t IGUANA_MY64BITS; -queue_t helperQ,jsonQ,finishedQ; +queue_t helperQ,jsonQ,finishedQ,bundlesQ; static int32_t initflag; #ifdef __linux__ int32_t IGUANA_NUMHELPERS = 16;