Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
f398ccb6a9
  1. 41
      iguana/iguana_bundles.c
  2. 10
      iguana/iguana_recv.c

41
iguana/iguana_bundles.c

@ -625,22 +625,40 @@ int32_t iguana_bundleissuemissing(struct iguana_info *coin,struct iguana_bundle
int32_t iguana_blast(struct iguana_info *coin,struct iguana_peer *addr)
{
struct iguana_bundle *bp; bits256 hash2; int32_t i,range,n = 0;
if ( (bp= coin->current) != 0 && (range= (coin->bundlescount - bp->hdrsi)) > 0 )
struct iguana_bundle *bp,*lastbp; double aveduration; bits256 hash2; uint32_t now; int32_t i,m,ind,range,n = 0;
m = 0;
if ( (bp= coin->current) != 0 && (lastbp= coin->lastpending) != 0 && (range= (lastbp->hdrsi - bp->hdrsi + 1)) > 0 )
{
if ( (bp= coin->bundles[bp->hdrsi + (addr->addrind % range)]) != 0 )
ind = bp->hdrsi + (addr->addrind % range);
while ( ind < coin->bundlescount && n < IGUANA_PENDINGREQUESTS )
{
for (i=0; i<bp->n && n<IGUANA_PENDINGREQUESTS; i++)
if ( GETBIT(bp->haveblock,i) == 0 )
now = (uint32_t)time(NULL);
if ( (bp= coin->bundles[ind++]) != 0 )
{
if ( bp == coin->current )
aveduration = 1;
else
{
iguana_bundleblock(coin,&hash2,bp,i);
if ( bits256_nonz(hash2) != 0 )
if ( bp->durationscount != 0 )
aveduration = (double)bp->totaldurations / bp->durationscount;
else aveduration = IGUANA_DEFAULTLAG;
}
for (i=0; i<bp->n && n<IGUANA_PENDINGREQUESTS; i++)
if ( GETBIT(bp->haveblock,i) == 0 && now > bp->issued[i]+aveduration )
{
n++;
iguana_sendblockreqPT(coin,addr,bp,i,hash2,0);
iguana_bundleblock(coin,&hash2,bp,i);
if ( bits256_nonz(hash2) != 0 )
{
n++;
iguana_sendblockreqPT(coin,addr,bp,i,hash2,0);
}
}
if ( n > m )
{
//printf("%s blasted.%d -> [%d]\n",addr->ipaddr,n-m,bp->hdrsi);
m = n;
}
printf("blasted.%d -> [%d]\n",n,bp->hdrsi);
}
}
}
return(n);
@ -649,7 +667,7 @@ int32_t iguana_blast(struct iguana_info *coin,struct iguana_peer *addr)
int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int32_t requiredflag)
{
static bits256 zero;
int32_t i,ready,valid,checki,hdrsi; char fname[1024]; struct iguana_block *block; int32_t sum[0x100],counts[0x100]; FILE *fp; struct iguana_blockRO *B; struct iguana_bundle *nextbp; void *ptr; long filesize; struct iguana_ramchain R; bits256 prevhash2;
int32_t i,ready,valid; char fname[1024]; struct iguana_block *block; int32_t sum[0x100],counts[0x100]; struct iguana_blockRO *B; struct iguana_bundle *nextbp; void *ptr; long filesize; struct iguana_ramchain R; bits256 prevhash2;
memset(sum,0,sizeof(sum));
memset(counts,0,sizeof(counts));
if ( 0 && bp->queued == 0 )
@ -708,6 +726,7 @@ int32_t iguana_bundleready(struct iguana_info *coin,struct iguana_bundle *bp,int
else
{
#ifndef __PNACL__
int32_t checki,hdrsi; FILE *fp;
fname[0] = 0;
checki = iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,block->RO.hash2,zero,1,0);
if ( hdrsi == bp->hdrsi && checki == i && (fp= fopen(fname,"rb")) != 0 )

10
iguana/iguana_recv.c

@ -335,14 +335,14 @@ void iguana_gotblockM(struct iguana_info *coin,struct iguana_peer *addr,struct i
coin->maxbandwidth = bw;
}
coin->bandwidth = bw;
if ( coin->bandwidth < 0.25*coin->maxbandwidth )
{
printf(">>SLOW.%d<< ",addr->addrind);
iguana_blast(coin,addr);
}
char str[65],str2[65],str3[65],str4[65]; printf("%s BLOCKS.%llu RECV %s ave %.1f | dup.%d %s after.%d %s %s/sec %.2f%%\n",coin->symbol,(long long)sum2,mbstr(str,sum),(double)sum/(sum2!=0?sum2:1),numDuplicates,mbstr(str2,sizeDuplicates),numAfteremit,mbstr(str3,sizeAfteremit),mbstr(str4,bw),coin->maxbandwidth!=0.?100.*coin->bandwidth/coin->maxbandwidth:0.);
last = now;
}
if ( coin->bandwidth < 0.25*coin->maxbandwidth )
{
printf(">>SLOW.%d<< ",addr->addrind);
iguana_blast(coin,addr);
}
}
copyflag = 0;//(coin->enableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0);
bp = 0, bundlei = -2;

Loading…
Cancel
Save