Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
ec884bb7d1
  1. 2
      iguana/iguana_bundles.c
  2. 2
      iguana/iguana_peers.c
  3. 23
      iguana/iguana_recv.c

2
iguana/iguana_bundles.c

@ -439,7 +439,7 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp)
bp->emitfinish = 1;
iguana_emitQ(coin,bp);
}
else bp->metric = (2*bp->n - bp->numsaved - bp->numrecv) * (bp->hdrsi + 1);//sqrt((sqrt(fabs(bp->estsize - bp->datasize)) * (bp->n - bp->numsaved)) * (bp->hdrsi + 1));
else bp->metric = (2*bp->n - bp->numsaved - bp->numrecv);// * (bp->hdrsi + 1);//sqrt((sqrt(fabs(bp->estsize - bp->datasize)) * (bp->n - bp->numsaved)) * (bp->hdrsi + 1));
}
//printf("%f ",bp->metric);
return(bp->estsize);

2
iguana/iguana_peers.c

@ -1000,7 +1000,7 @@ void iguana_dedicatedloop(struct iguana_info *coin,struct iguana_peer *addr)
usleep(100000);
}
else if ( addr->rank != 1 )
usleep(coin->polltimeout*100 + (rand() % (coin->polltimeout*100)));
usleep(coin->polltimeout*100 + 0*(rand() % (coin->polltimeout*100)));
else usleep(100 + coin->polltimeout*1000);
} else run >>= 2;
}

23
iguana/iguana_recv.c

@ -683,8 +683,10 @@ 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;
int32_t i,r,diff,j,k,n,m; double metric,bestmetric = -1.; struct iguana_bundle *bp,*bestbp = 0;
int32_t i,r,diff,j,k,n,m,z; double metric,bestmetric = -1.; struct iguana_bundle *bp,*bestbp = 0;
int32_t limit,refbundlei,height=-1,incr,bundlei,datalen,flag = 0; double val;
if ( addr->msgcounts.verack == 0 )
return(0);
now = (uint32_t)time(NULL);
if ( iguana_needhdrs(coin) != 0 && addr->pendhdrs < IGUANA_MAXPENDHDRS )
{
@ -697,13 +699,26 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
if ( bits256_nonz(hash2) > 0 )
{
bp = 0, bundlei = -2;
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) == 0 || (bp->numhashes < bp->n && bp->bundleheight+coin->chain->bundlesize < coin->longestchain) )
bp = iguana_bundlefind(coin,&bp,&bundlei,hash2);
z = 0;
if ( bp != 0 )
{
if ( bp->bundleheight+coin->chain->bundlesize < coin->longestchain )
{
m = (coin->longestchain - bp->bundleheight);
if ( bp->numhashes < m )
z = 1;
}
else if ( bp->numhashes < bp->n )
z = 1;
}
if ( bp == 0 || z != 0 )
{
//printf("%s request hdr.(%s) numhashes.%d\n",addr!=0?addr->ipaddr:"local",hashstr,bp->numhashes);
iguana_send(coin,addr,serialized,datalen);
addr->pendhdrs++;
flag++;
} // else printf("skip hdrreq.%d numhashes.%d\n",bp->bundleheight,bp->numhashes);
} else printf("skip hdrreq.%d numhashes.%d\n",bp->bundleheight,bp->numhashes);
}
free_queueitem(hashstr);
return(flag);
@ -712,8 +727,6 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
hashstr = 0;
}
}
if ( addr->msgcounts.verack == 0 )
return(0);
if ( (limit= addr->recvblocks) > coin->MAXPENDING )
limit = coin->MAXPENDING;
if ( limit < 1 )

Loading…
Cancel
Save