From 2a0acbeecb65d82d03564ceff58c1a469ff5f381 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Mar 2016 02:43:03 -0300 Subject: [PATCH] test --- iguana/iguana777.c | 8 ++++---- iguana/iguana777.h | 4 ++-- iguana/iguana_bundles.c | 2 +- iguana/iguana_recv.c | 24 +++++++++++++++--------- iguana/main.c | 2 +- 5 files changed, 23 insertions(+), 17 deletions(-) diff --git a/iguana/iguana777.c b/iguana/iguana777.c index 866b1232c..8a040784f 100755 --- a/iguana/iguana777.c +++ b/iguana/iguana777.c @@ -370,14 +370,14 @@ void iguana_helper(void *arg) { FILE *fp = 0; char fname[512],name[64],*helpername = 0; cJSON *argjson=0; int32_t type,flag,idle=0; struct iguana_helper *ptr; struct iguana_info *coin; struct OS_memspace MEM,*MEMB; - type = rand(); if ( arg != 0 && (argjson= cJSON_Parse(arg)) != 0 ) helpername = jstr(argjson,"name"); if ( helpername == 0 ) { - sprintf(name,"helper.%d",rand()); + sprintf(name,"%d",rand()); helpername = name; } + type = (name[0] % 2); sprintf(fname,"%s/%s",GLOBALTMPDIR,helpername); OS_compatible_path(fname); fp = fopen(fname,"wb"); @@ -389,7 +389,7 @@ void iguana_helper(void *arg) { //iguana_jsonQ(); flag = 0; - if ( (type % 2) == 0 && ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) ) + if ( type == 0 && ((ptr= queue_dequeue(&emitQ,0)) != 0 || (ptr= queue_dequeue(&helperQ,0)) != 0) ) { if ( ptr->bp != 0 && (coin= ptr->coin) != 0 ) { @@ -401,7 +401,7 @@ void iguana_helper(void *arg) } myfree(ptr,ptr->allocsize); } - else if ( (type % 2) == 1 && (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) + else if ( type == 1 && (ptr= queue_dequeue(&bundlesQ,0)) != 0 ) { idle = 0; if ( ptr->bp != 0 && ptr->coin != 0 ) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 3dba09a3f..96c4001a9 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -38,8 +38,8 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t #define IGUANA_TAILPERCENTAGE 1.0 #define IGUANA_MAXPENDHDRS 1 #define _IGUANA_MAXPENDING 3 -#define IGUANA_MINPENDBUNDLES 16 -#define IGUANA_MAXPENDBUNDLES 100 +#define IGUANA_MINPENDBUNDLES 64 +#define IGUANA_MAXPENDBUNDLES 64 #define IGUANA_BUNDLELOOP 77 #define IGUANA_RPCPORT 7778 #define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16) diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 798b5e345..9ca59c3ef 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -153,7 +153,7 @@ int32_t iguana_hash2set(struct iguana_info *coin,char *debugstr,struct iguana_bu bit = iguana_calcbloom(newhash2); if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) { - printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei); + //printf("bloomset (%s) -> [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei); iguana_bloomset(coin,&bp->bloom,0,bit); if ( 0 ) { diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 8c7ef9981..3fbfa5868 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -189,7 +189,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i { printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->block.RO.hash2)); return; - } //else printf("validated.%s\n",bits256_str(str,origtxdata->block.RO.hash2)); + } else printf("validated.%s\n",bits256_str(str,origtxdata->block.RO.hash2)); copyflag = 1 * (strcmp(coin->symbol,"BTC") != 0); bp = 0, bundlei = -2; if ( copyflag != 0 && recvlen != 0 && ((bp= iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2)) == 0 || (bp->blocks[bundlei] != 0 && bp->blocks[bundlei]->fpipbits == 0)) ) @@ -449,15 +449,15 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl // iguana_patch(coin,block); if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) != 0 && bundlei < coin->chain->bundlesize ) { - //fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei); + fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei); block->bundlei = bundlei; block->hdrsi = bp->hdrsi; bp->blocks[bundlei] = block; - //printf("bundlehashadd set.%d\n",bundlei); + printf("bundlehashadd set.%d\n",bundlei); iguana_bundlehash2add(coin,0,bp,bundlei,hash2); if ( bundlei > 0 ) { - //printf("bundlehashadd prev %d\n",bundlei); + printf("bundlehashadd prev %d\n",bundlei); iguana_bundlehash2add(coin,0,bp,bundlei-1,prevhash2); } else if ( bp->hdrsi > 0 && (bp= coin->bundles[bp->hdrsi-1]) != 0 ) @@ -612,7 +612,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct } else if ( num >= coin->chain->bundlesize ) { - for (i=0; ibundlescount; i++) + for (i=coin->bundlescount-1; i>=0; i--) { if ( (bp= coin->bundles[i]) != 0 && bp->emitfinish == 0 ) { @@ -628,17 +628,23 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct iguana_info *coin,struct iguana_blockQ("recvhash2",coin,bp,1,blockhashes[1],0); iguana_blockQ("recvhash3",coin,bp,0,blockhashes[0],0); iguana_blockQ("recvhash4",coin,bp,coin->chain->bundlesize-1,blockhashes[coin->chain->bundlesize-1],0); - //printf("matched bundle.%d\n",bp->bundleheight); + printf("matched bundle.%d\n",bp->bundleheight); return(req); } else printf("unexpected mismatch??\n"); } } } - //printf("no match to allhashes issue block1\n"); + printf("no match to allhashes issue block1\n"); struct iguana_block *block; if ( num == coin->chain->bundlesize+1 && (block= iguana_blockhashset(coin,-1,blockhashes[1],1)) != 0 ) + { block->blockhashes = blockhashes, req->hashes = 0; - iguana_blockQ("recvhash5",coin,0,-5,blockhashes[1],0); + printf("set block->blockhashes[%d]\n",num); + } + iguana_blockQ("recvhash5",coin,0,-1,blockhashes[1],0); + iguana_blockQ("recvhash5",coin,0,-1,blockhashes[1],1); + if ( coin->peers.ranked[0] != 0 ) + iguana_sendblockreqPT(coin,coin->peers.ranked[0],0,-1,blockhashes[1],0); } else iguana_blockQ("recvhash6",coin,0,-6,blockhashes[1],0); // should be RT block return(req); } @@ -648,7 +654,7 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana struct iguana_bundle *bp=0; int32_t numsaved=0,bundlei = -2; struct iguana_block *block,*tmpblock; bp = iguana_bundleset(coin,&block,&bundlei,origblock); char str[65]; - if ( 1 && bp != 0 && bp->hdrsi == coin->bundlescount-1 ) + //if ( 1 && bp != 0 && bp->hdrsi == coin->bundlescount-1 ) { int32_t i; static int32_t numrecv; numrecv++; diff --git a/iguana/main.c b/iguana/main.c index ebe00ab9e..51af47534 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -1142,7 +1142,7 @@ void iguana_main(void *arg) IGUANA_NUMHELPERS = 1; for (i=0; i