From 25016fb50eee11cab82b75085f26d5b7f36488c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 17 Mar 2016 22:55:12 -0300 Subject: [PATCH] test --- iguana/iguana777.h | 6 +++--- iguana/iguana_bundles.c | 39 ++++++++++++++++++++++++++++----------- 2 files changed, 31 insertions(+), 14 deletions(-) diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 6d2c628f5..6f6cb8282 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -37,10 +37,10 @@ typedef int32_t (*blockhashfunc)(uint8_t *blockhashp,uint8_t *serialized,int32_t #define IGUANA_HEADPERCENTAGE 0. #define IGUANA_TAILPERCENTAGE 1.0 #define IGUANA_MAXPENDHDRS 1 -#define _IGUANA_MAXPENDING 7 +#define _IGUANA_MAXPENDING 3 #define IGUANA_MINPENDBUNDLES 64 #define IGUANA_MAXPENDBUNDLES 64 -#define IGUANA_BUNDLELOOP 777 +#define IGUANA_BUNDLELOOP 3 #define IGUANA_RPCPORT 7778 #define IGUANA_MAXRAMCHAINSIZE ((uint64_t)1024L * 1024L * 1024L * 16) @@ -279,7 +279,7 @@ struct iguana_block struct iguana_blockRO RO; double PoW; // NOT consensus safe, for estimation purposes only int32_t height; uint32_t fpipbits,numrequests,issued; long fpos; - uint16_t hdrsi,bundlei:12,mainchain:1,valid:1,queued:1,txvalid:1,extra:8; + uint16_t hdrsi,bundlei:12,mainchain:1,valid:1,queued:1,txvalid:1,peerid:8; UT_hash_handle hh; bits256 *blockhashes; };// __attribute__((packed)); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index 50ef7dfb4..473ad0312 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -366,14 +366,15 @@ void iguana_bundlepurge(struct iguana_info *coin,struct iguana_bundle *bp) int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int32_t max,int32_t timelimit) { - int32_t i,j,k,len,numpeers,counter = 0; struct iguana_peer *addr; uint32_t now; + int32_t i,j,k,len,numpeers,peercounts[IGUANA_MAXPEERS],counter = 0; struct iguana_peer *addr; uint32_t now; struct iguana_block *block; bits256 hashes[32]; uint8_t serialized[sizeof(hashes) + 256]; if ( bp == 0 ) return(0); now = (uint32_t)time(NULL); + memset(peercounts,0,sizeof(peercounts)); if ( bp == coin->current ) { - if ( bp->numhashes >= bp->n && bp->currentflag < bp->n && (numpeers= coin->peers.numranked) > 8 ) + if ( bp->numhashes >= bp->n && (numpeers= coin->peers.numranked) > 8 ) { for (j=0; jhashes[i]) != 0 ) { - if ( (block= bp->blocks[i]) != 0 && block->fpipbits == 0 && (block->numrequests == 0 || now > block->issued+60) ) + if ( (block= bp->blocks[i]) != 0 ) { - printf("<%d> ",i); - hashes[k++] = bp->hashes[i]; - block->issued = now; - block->numrequests++; + if ( block->peerid == 0 ) + { + printf("<%d> ",i); + hashes[k++] = bp->hashes[i]; + block->issued = now; + block->peerid = j + 1; + block->numrequests++; + } + else + { + if ( block->fpipbits == 0 ) + { + } + else if ( block->fpipbits != 0 && block->fpos >= 0 ) + { + //bp->currentflag++; + peercounts[block->peerid]++; + } + + } } } bp->issued[i] = now; @@ -404,14 +421,14 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int addr->pendtime = (uint32_t)time(NULL); bp->currentflag += k; } - printf("a%d/%d ",j,k); + //printf("a%d/%d ",j,k); } } } - printf("currentflag.%d\n",bp->currentflag); + //printf("currentflag.%d\n",bp->currentflag); return(counter); } - if ( 0 && time(NULL) > bp->lastspeculative+60 ) + /*if ( 0 && time(NULL) > bp->lastspeculative+60 ) { for (i=1,counter=0; in; i++) { @@ -426,7 +443,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int if ( counter != 0 ) printf("SPECULATIVE issue.%d bp.[%d]\n",counter,bp->hdrsi); bp->lastspeculative = (uint32_t)time(NULL); - } + }*/ } // if ( bp != coin->current ) return(counter);