Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
854e807f30
  1. 4
      iguana/iguana_blocks.c
  2. 10
      iguana/iguana_bundles.c
  3. 3
      iguana/iguana_ramchain.c
  4. 27
      iguana/iguana_recv.c
  5. 2
      iguana/main.c

4
iguana/iguana_blocks.c

@ -388,10 +388,6 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
//getchar();
}
iguana_bundlehash2add(coin,0,bp,block->height % coin->chain->bundlesize,block->RO.hash2);
/* bp->hashes[block->height % coin->chain->bundlesize] = block->RO.hash2;
if ( bp->speculative != 0 )
bp->speculative[block->height % coin->chain->bundlesize] = block->RO.hash2;
bp->blocks[block->height % coin->chain->bundlesize] = block;*/
}
if ( coin->started != 0 && (block->height % coin->chain->bundlesize) == coin->minconfirms && (block->height > coin->longestchain-coin->chain->bundlesize*2 || ((block->height / coin->chain->bundlesize) % 10) == 9) )
{

10
iguana/iguana_bundles.c

@ -434,7 +434,10 @@ struct iguana_block *iguana_bundleblock(struct iguana_info *coin,bits256 *hash2p
if ( bits256_nonz(bp->nextbundlehash2) != 0 )
{
if ( bp->hdrsi < coin->bundlescount && (nextbp= coin->bundles[bp->hdrsi+1]) != 0 )
block = nextbp->blocks[0];
{
*hash2p = nextbp->hashes[0];
return(nextbp->blocks[0]);
}
} else return(0);
}
if ( block != 0 || (block= bp->blocks[i]) != 0 )//|| bits256_nonz(bp->hashes[i]) != 0 )//&& (block= iguana_blockfind("bundleblock2",coin,bp->hashes[i])) != 0) )
@ -474,8 +477,6 @@ int32_t iguana_blocksmissing(struct iguana_info *coin,int32_t *nonzp,uint8_t mis
}
if ( bits256_nonz(hash2) != 0 )
{
if ( 0 && bp->issued[i] == 0 )
iguana_blockQ("missing",coin,bp,i,hash2,0);
if ( now > bp->issued[i]+lag )
{
if ( nonz < capacity )
@ -709,11 +710,10 @@ int64_t iguana_bundlecalcs(struct iguana_info *coin,struct iguana_bundle *bp,int
datasize = numhashes = numsaved = numrecv = minrequests = 0;
for (bundlei=0; bundlei<bp->n; bundlei++)
{
block = bp->blocks[bundlei];
if ( bits256_nonz(bp->hashes[bundlei]) > 0 )
{
numhashes++;
if ( block != 0 && bits256_cmp(block->RO.hash2,bp->hashes[bundlei]) == 0 )
if ( (block= bp->blocks[bundlei]) != 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;

3
iguana/iguana_ramchain.c

@ -1905,6 +1905,7 @@ void iguana_ramchain_disp(struct iguana_ramchain *ramchain)
void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile)
{
void *ptr; int32_t recvlen,hdrsi,checki; char fname[1024]; static const bits256 zero;
printf("UNMARK.[%d:%d]\n",block->hdrsi,i);
block->queued = 0;
block->fpipbits = 0;
block->fpos = -1;
@ -2137,8 +2138,6 @@ struct iguana_ramchain *iguana_bundleload(struct iguana_info *coin,struct iguana
block->fpipbits = (uint32_t)calc_ipbits("127.0.0.1");
block->RO = B[i];
//printf("%x ",(int32_t)B[i].hash2.ulongs[3]);
if ( bp->blocks[i] == 0 )
bp->blocks[i] = block;
if ( bits256_nonz(bp->hashes[i]) == 0 )
bp->hashes[i] = B[i].hash2;
if ( bp->bundleheight+i == coin->blocks.hwmchain.height+1 )

27
iguana/iguana_recv.c

@ -563,7 +563,7 @@ void iguana_bundlespeculate(struct iguana_info *coin,struct iguana_bundle *bp,in
int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,int32_t bundlei,struct iguana_block *block)
{
static const bits256 zero;
struct iguana_ramchain blockR; int32_t hdrsi,checki; long size = 0; FILE *fp; char fname[1024];
struct iguana_ramchain blockR; int32_t hdrsi,checki,retval=-1; long size = 0; FILE *fp; char fname[1024];
block->bundlei = bundlei;
block->hdrsi = bp->hdrsi;
if ( bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 )
@ -572,7 +572,10 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
if ( block == bp->blocks[bundlei] )
{
if ( block->mainchain == 0 )
{
printf("mainchain blockptr.%p vs %p\n",block,bp->blocks[bundlei]);
return(-1);
}
}
else if ( bp->blocks[bundlei] != 0 )
{
@ -585,7 +588,7 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
if ( bp->emitfinish == 0 )
{
block->fpos = -1;
if ( 0 && iguana_ramchainfile(coin,0,&blockR,bp,bundlei,block) == 0 )
if ( 1 && iguana_ramchainfile(coin,0,&blockR,bp,bundlei,block) == 0 )
{
size = sizeof(blockR);
iguana_ramchain_free(coin,&blockR,1);
@ -602,6 +605,7 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
}
if ( size != 0 )
{
retval = 0;
printf("initialize with fp.[%d:%d] len.%ld\n",bp->hdrsi,bundlei,size);
block->RO.recvlen = (int32_t)size;
block->fpipbits = 1;
@ -609,14 +613,8 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i
block->fpos = 0;
block->issued = (uint32_t)time(NULL);
}
else
{
if ( block->issued == 0 )
iguana_blockQ("bundleset",coin,bp,bundlei,block->RO.hash2,coin->current == 0 || bp->hdrsi <= coin->current->hdrsi+coin->MAXBUNDLES);
iguana_blockunmark(coin,block,bp,bundlei,0);
}
}
return(0);
return(retval);
}
// main context, ie single threaded
@ -642,7 +640,12 @@ struct iguana_bundle *iguana_bundleset(struct iguana_info *coin,struct iguana_bl
bp = 0, bundlei = -2;
if ( (bp= iguana_bundlefind(coin,&bp,&bundlei,hash2)) != 0 && bundlei < coin->chain->bundlesize )
{
iguana_bundlehashadd(coin,bp,bundlei,block);
if ( iguana_bundlehashadd(coin,bp,bundlei,block) < 0 )
{
if ( block->issued == 0 )
iguana_blockQ("bundleset",coin,bp,bundlei,block->RO.hash2,coin->current == 0 || bp->hdrsi <= coin->current->hdrsi+coin->MAXBUNDLES);
//iguana_blockunmark(coin,block,bp,bundlei,0);
}
//fprintf(stderr,"bundle found %d:%d\n",bp->hdrsi,bundlei);
//printf("bundlehashadd set.%d\n",bundlei);
if ( bundlei > 0 )
@ -1008,7 +1011,7 @@ int32_t iguana_blockreq(struct iguana_info *coin,int32_t height,int32_t priority
int32_t iguana_reqblocks(struct iguana_info *coin)
{
int32_t hdrsi,lflag,bundlei,iters=0,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp; char str[1024];
int32_t hdrsi,lflag,bundlei,iters=0,flag = 0; bits256 hash2; struct iguana_block *next,*block; struct iguana_bundle *bp;
if ( time(NULL) < coin->lastreqtime+2 )
return(0);
coin->lastreqtime = (uint32_t)time(NULL);
@ -1107,7 +1110,7 @@ int32_t iguana_reqblocks(struct iguana_info *coin)
{
int32_t j;
//memset(bp->hashes[bundlei].bytes,0,sizeof(bp->hashes[bundlei]));
bp->blocks[bundlei] = 0;
//bp->blocks[bundlei] = 0;
for (j=0; j<1&&bundlei+j+1<bp->n; j++)
{
if ( time(NULL) > bp->issued[bundlei+1+j]+10 )

2
iguana/main.c

@ -1186,7 +1186,7 @@ void iguana_main(void *arg)
if ( 1 )
{
sleep(1);
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"VALIDATE\":1,\"prefetchlag\":13,\"startpend\":64,\"endpend\":64,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":8,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
if ( 1 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"VALIDATE\":1,\"prefetchlag\":13,\"startpend\":1,\"endpend\":1,\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":128,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":8,\"poll\":1}"),0,myinfo->rpcport)) != 0 )
{
free(str);
if ( 0 && (str= SuperNET_JSON(myinfo,cJSON_Parse("{\"userhome\":\"/Users/jimbolaptop/Library/Application Support\",\"agent\":\"iguana\",\"method\":\"addcoin\",\"services\":1024,\"maxpeers\":256,\"newcoin\":\"BTCD\",\"active\":1}"),0,myinfo->rpcport)) != 0 )

Loading…
Cancel
Save