diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 29db994b8..030563a47 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -283,7 +283,7 @@ struct iguana_block { struct iguana_blockRO RO; double PoW; // NOT consensus safe, for estimation purposes only - int32_t height,fpos; uint32_t fpipbits,issued,numrequests:24,peerid:8; + int32_t height,fpos; uint32_t fpipbits,issued,lag:20,peerid:12; uint16_t hdrsi:15,mainchain:1,bundlei:11,valid:1,queued:1,txvalid:1,newtx:1,processed:1; UT_hash_handle hh; struct iguana_bundlereq *req; } __attribute__((packed)); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index abb765663..b4dd32819 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -540,7 +540,7 @@ int32_t iguana_nextnonz(uint8_t *missings,int32_t i,int32_t max) int32_t iguana_bundlerequests(struct iguana_info *coin,uint8_t missings[IGUANA_MAXBUNDLESIZE/8+1],int32_t *missingp,int32_t *capacityp,struct iguana_bundle *bp,int32_t lag,int32_t priority) { uint8_t numpeers; int32_t i,j,avail,nonz=0,c,n,m=0,max,capacity,numsent; bits256 hashes[500],hash2; - struct iguana_block *block; struct iguana_peer *peers[256],*addr,*lagaddr; uint32_t now = (uint32_t)time(NULL); + struct iguana_block *block; struct iguana_peer *peers[256],*addr; uint32_t now = (uint32_t)time(NULL); max = (int32_t)(sizeof(hashes) / sizeof(*hashes)); *missingp = *capacityp = 0; if ( (numpeers= iguana_recentpeers(coin,&capacity,peers)) > 0 ) @@ -568,18 +568,10 @@ int32_t iguana_bundlerequests(struct iguana_info *coin,uint8_t missings[IGUANA_M if ( (block= iguana_bundleblock(coin,&hash2,bp,nonz)) != 0 ) { hash2 = block->RO.hash2; - lagaddr = &coin->peers.active[block->peerid]; - if ( block->issued != 0 && block->peerid != 0 ) - { - if ( (now - block->issued) > 60 ) - lagaddr->laggard++; - printf("addr.%s laggard.%d lag.%d\n",lagaddr->ipaddr,lagaddr->laggard,block->issued - now); - if ( lagaddr->laggard > 10 && coin->peers.numranked > 64 ) - lagaddr->dead = (uint32_t)time(NULL); - } if ( addr->addrind < 0x100 ) block->peerid = addr->addrind; else block->peerid = 0; + block->issued = now; } bp->issued[nonz] = now; //char str[65]; printf("issue.[%d:%d] %s %u\n",bp->hdrsi,nonz,bits256_str(str,hash2),now); @@ -723,8 +715,8 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp,int numhashes++; if ( block != 0 && bits256_cmp(block->RO.hash2,bp->hashes[bundlei]) == 0 ) { - if ( bp->minrequests == 0 || (block->numrequests > 0 && block->numrequests < bp->minrequests) ) - bp->minrequests = block->numrequests; + //if ( bp->minrequests == 0 || (block->numrequests > 0 && block->numrequests < bp->minrequests) ) + // bp->minrequests = block->numrequests; if ( block->fpipbits != 0 && block->fpos >= 0 ) numsaved++; if ( block->RO.recvlen != 0 ) diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index bedcfe4fd..07b38650d 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -59,7 +59,7 @@ int32_t iguana_speculativesearch(struct iguana_info *coin,struct iguana_block ** int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,struct iguana_bundle *bp,int32_t bundlei,bits256 hash2,int32_t iamthreadsafe) { static bits256 lastreq,lastreq2; - int32_t len,j; struct iguana_bundle *checkbp; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block; + int32_t len,j; struct iguana_bundle *checkbp; uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block=0; char hexstr[65]; init_hexbytes_noT(hexstr,hash2.bytes,sizeof(hash2)); if ( addr == 0 || memcmp(lastreq.bytes,hash2.bytes,sizeof(hash2)) == 0 || memcmp(lastreq2.bytes,hash2.bytes,sizeof(hash2)) == 0 ) { @@ -99,6 +99,8 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, coin->numreqsent++; addr->pendblocks++; addr->pendtime = (uint32_t)time(NULL); + if ( block != 0 ) + block->issued = addr->pendtime; if ( 0 && coin->current == bp ) printf("REQ.%s bundlei.%d hdrsi.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1); } else printf("MSG_BLOCK null datalen.%d\n",len); @@ -325,13 +327,8 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i bp = iguana_bundlefind(coin,&bp,&bundlei,origtxdata->block.RO.hash2); if ( bp != 0 && bundlei >= 0 && bundlei < bp->n ) { - block = bp->blocks[bundlei]; - if ( block != 0 ) - { - if ( block->peerid != 0 && block->issued != 0 && time(NULL)-block->issued < 60 ) - addr->laggard--; - block->peerid = 0; - } + if ( (block= bp->blocks[bundlei]) != 0 && block->lag == 0 && block->issued != 0 ) + block->lag = (uint32_t)time(NULL) - block->issued; if ( bp->emitfinish != 0 ) { numAfteremit++; @@ -342,7 +339,7 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i return; } bp->dirty++; - if ( bundlei >= 0 && (block= bp->blocks[bundlei]) != 0 ) + if ( bundlei >= 0 && block != 0 ) { if ( iguana_blockstatus(coin,block) != 0 && block->txvalid != 0 ) { @@ -951,6 +948,8 @@ struct iguana_bundlereq *iguana_recvblock(struct iguana_info *coin,struct iguana { if ( block != origblock ) iguana_blockcopy(coin,block,origblock); + if ( block->lag != 0 && block->issued != 0 ) + block->lag = (uint32_t)time(NULL) - block->issued; if ( req->copyflag != 0 ) { if ( block->queued == 0 && bp != 0 ) @@ -1305,7 +1304,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle } else coin->backlog >>= 1; if ( block != 0 ) { - block->numrequests++; + //block->numrequests++; block->issued = now; } queue_enqueue(str,Q,&req->DL,0); @@ -1355,7 +1354,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) iguana_send(coin,addr,serialized,datalen); addr->pendhdrs++; flag++; - } else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued); + } //else printf("skip hdrreq.%s m.%d z.%d bp.%p longest.%d queued.%d\n",hashstr,m,z,bp,bp->coin->longestchain,bp->queued); } free_queueitem(hashstr); return(flag); @@ -1408,8 +1407,8 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } else { - if ( block != 0 ) - block->numrequests++; + //if ( block != 0 ) + // block->numrequests++; iguana_sendblockreqPT(coin,addr,bp,req->bundlei,hash2,0); } flag++;