Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
0297a8085d
  1. 33
      iguana/iguana_bundles.c
  2. 6
      iguana/iguana_recv.c

33
iguana/iguana_bundles.c

@ -390,7 +390,7 @@ void iguana_bundlepurgefiles(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,peerid,doneflag,len,forceflag,saved,starti,lag,doneval,nonz,total=0,maxval,numpeers,laggard,flag=0,finished,peercounts[IGUANA_MAXPEERS],donecounts[IGUANA_MAXPEERS],priority,counter = 0;
int32_t i,j,k,peerid,doneflag,len,forceflag,saved,starti,lag,doneval,nonz,total=0,maxval,numpeers,laggard=0,flag=0,finished=0,peercounts[IGUANA_MAXPEERS],donecounts[IGUANA_MAXPEERS],priority,counter = 0;
struct iguana_peer *addr; uint32_t now; struct iguana_block *block;
bits256 hashes[50],hash2; uint8_t serialized[sizeof(hashes) + 256];
if ( bp == 0 )
@ -498,7 +498,7 @@ int32_t iguana_bundleissue(struct iguana_info *coin,struct iguana_bundle *bp,int
}
}
//printf("doneval.%d maxval.%d\n",doneval,maxval);
if ( priority != 0 )
if ( 0 && priority != 0 )
{
double threshold;
for (i=nonz=0; i<numpeers; i++)
@ -673,7 +673,7 @@ int32_t iguana_bundlehdr(struct iguana_info *coin,struct iguana_bundle *bp,int32
{
if ( time(NULL) > bp->issued[1]+10 )
{
iguana_blockQ("getnexthdr",coin,0,-1,bp->speculative[1],1);
iguana_blockQ("getnexthdr",coin,bp,-1,bp->speculative[1],1);
bp->issued[1] = (uint32_t)time(NULL);
}
}
@ -1128,7 +1128,7 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
block->bundlei = j;
block->hdrsi = bp->hdrsi;
bp->blocks[j] = block;
printf("bundlehashadd set.%d recvlen.%d\n",j,recvlen);
//printf("bundlehashadd set.%d recvlen.%d\n",j,recvlen);
iguana_bundlehash2add(coin,0,bp,j,bp->speculative[j]);
recvlen = *(int32_t *)bp->speculativecache[j];
memset(&H,0,sizeof(H));
@ -1146,9 +1146,9 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
}
continue;
}
fprintf(stderr,"-[%d:%d].%d ",bp->hdrsi,j,now-bp->issued[j]);
if ( now > bp->issued[j]+30 || (rand() % 10) == 0 )
{
fprintf(stderr,"-[%d:%d].%d ",bp->hdrsi,j,now-bp->issued[j]);
struct iguana_peer *addr; int32_t r;
if ( (rand() % 10) == 0 && (r= coin->peers.numranked) != 0 && (addr= coin->peers.ranked[rand() % r]) != 0 && addr->dead == 0 && addr->usock >= 0 )
iguana_sendblockreqPT(coin,addr,bp,j,hash2,0), printf("%s ",addr->ipaddr);
@ -1164,16 +1164,29 @@ void iguana_bundlestats(struct iguana_info *coin,char *str)
hash2 = bp->hashes[0];
for (i=1; i<bp->n; i++)
{
if ( bits256_nonz(bp->speculative[i]) != 0 )
/*if ( bits256_nonz(bp->speculative[i]) != 0 )
block = iguana_blockfind(coin,bp->speculative[i]);
else if ( bits256_nonz(bp->hashes[i]) != 0 )
block = iguana_blockfind(coin,bp->hashes[i]);
if ( block == 0 || bits256_cmp(block->RO.prev_block,hash2) != 0 )
block = iguana_blockfind(coin,bp->hashes[i]);*/
if ( (block= bp->blocks[i]) == 0 || bits256_cmp(block->RO.prev_block,hash2) != 0 )
{
printf("error with speculative prev at i.%d\n",i);
char str[65],str2[65];
printf("error with speculative prev at i.%d block.%p %s vs %s\n",i,block,bits256_str(str,bp->hashes[i]),bits256_str(str2,hash2));
if ( block != 0 )
{
checki = iguana_peerfname(coin,&hdrsi,GLOBALTMPDIR,fname,0,bp->hashes[i],zero,1,0);
if ( fname[0] != 0 )
OS_removefile(fname,0);
printf(">>>>>>> block contents error at ht.%d (%s)\n",bp->bundleheight+i,fname);
//char str[65]; patch.(%s) and reissue %s checki.%d vs %d\n",block->fpipbits,bp->bundleheight+i,bits256_str(str,block->RO.prev_block),fname,checki,i);
block->fpipbits = 0;
block->fpos = -1;
block->queued = 0;
block->RO.recvlen = 0;
}
break;
}
hash2 = block->RO.prev_block;
hash2 = block->RO.hash2;
}
if ( i == bp->n )
iguana_bundlefinalize(coin,bp,&coin->MEM,coin->MEMB);

6
iguana/iguana_recv.c

@ -55,7 +55,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr,
coin->numreqsent++;
addr->pendblocks++;
addr->pendtime = (uint32_t)time(NULL);
if ( 0 && coin->current == bp )
//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);
return(len);
@ -177,7 +177,7 @@ int32_t iguana_speculativefind(struct iguana_info *coin,struct iguana_bundle *bp
for (j=numcached=0; j<bp->n; j++)
if ( bp->speculativecache[j] != 0 )
numcached++;
printf("cache %s [%d:%d] h.%d s.%d c.%d -> %d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,i,bp->numhashes,bp->numsaved,bp->numcached,numcached);
//printf("cache %s [%d:%d] h.%d s.%d c.%d -> %d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,i,bp->numhashes,bp->numsaved,bp->numcached,numcached);
return(i);
}
}
@ -1303,7 +1303,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle
req->height = height;
req->bundlei = bundlei;
char str2[65];
//printf("%s %s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",coin->symbol,argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers.numranked,queue_size(Q));
printf("%s %s %s [%d:%d] %d %s %d numranked.%d qsize.%d\n",coin->symbol,argstr,str,bp!=0?bp->hdrsi:-1,bundlei,req->height,bits256_str(str2,hash2),coin->blocks.recvblocks,coin->peers.numranked,queue_size(Q));
if ( Q == &coin->blocksQ )
{
if ( (n= queue_size(Q)) > 100000 )

Loading…
Cancel
Save