Browse Source

test

release/v0.1
jl777 9 years ago
parent
commit
edab78ae6b
  1. 23
      iguana/iguana_blocks.c
  2. 15
      iguana/iguana_recv.c
  3. 2
      iguana/iguana_unspents.c

23
iguana/iguana_blocks.c

@ -290,6 +290,26 @@ int32_t iguana_blockunmain(struct iguana_info *coin,struct iguana_block *block)
return(n); return(n);
} }
int32_t iguana_walkchain(struct iguana_info *coin)
{
char str[65]; int32_t height,hdrsi,bundlei,n = 0; struct iguana_block *block;
height = coin->blocks.hwmchain.height;
while ( (block= iguana_blockfind("main",coin,iguana_blockhash(coin,height))) != 0 )
{
hdrsi = (height / coin->chain->bundlesize);
bundlei = (height % coin->chain->bundlesize);
if ( bits256_cmp(iguana_blockhash(coin,height),block->RO.hash2) != 0 )
{
printf("blockhash error at %d %s\n",height,bits256_str(str,block->RO.hash2));
break;
}
n++;
height--;
}
printf("n.%d vs hwm.%d %s\n",n,coin->blocks.hwmchain.height,bits256_str(str,coin->blocks.hwmchain.RO.hash2));
return(n);
}
struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_block *newblock) struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_block *newblock)
{ {
int32_t valid,bundlei,height=-1; struct iguana_block *hwmchain,*block = 0,*prev=0,*next; int32_t valid,bundlei,height=-1; struct iguana_block *hwmchain,*block = 0,*prev=0,*next;
@ -386,7 +406,7 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
{ {
if ( (bp= coin->bundles[block->height / coin->chain->bundlesize]) != 0 ) if ( (bp= coin->bundles[block->height / coin->chain->bundlesize]) != 0 )
{ {
if ( memcmp(bp->hashes[block->height % coin->chain->bundlesize].bytes,block->RO.hash2.bytes,sizeof(bits256)) != 0 ) if ( memcmp(bp->hashes[block->height % coin->chain->bundlesize].bytes,block->RO.hash2.bytes,sizeof(bits256)) != 0 || block != bp->blocks[block->height % coin->chain->bundlesize] )
{ {
if ( bits256_nonz(bp->hashes[block->height % coin->chain->bundlesize]) > 0 ) if ( bits256_nonz(bp->hashes[block->height % coin->chain->bundlesize]) > 0 )
{ {
@ -409,6 +429,7 @@ struct iguana_block *_iguana_chainlink(struct iguana_info *coin,struct iguana_bl
//iguana_blockQ("mainchain",coin,bp,block->height % coin->chain->bundlesize,block->RO.hash2,0); //iguana_blockQ("mainchain",coin,bp,block->height % coin->chain->bundlesize,block->RO.hash2,0);
} }
block->mainchain = 1; block->mainchain = 1;
iguana_walkchain(coin);
return(block); return(block);
} }
} }

15
iguana/iguana_recv.c

@ -1476,7 +1476,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr)
int32_t iguana_processrecv(struct iguana_info *coin) // single threaded int32_t iguana_processrecv(struct iguana_info *coin) // single threaded
{ {
int32_t i,n,newhwm = 0,hwmheight,flag = 0; struct iguana_bundle *bp; struct iguana_block *block; char str[2000]; int32_t i,newhwm = 0,hwmheight,flag = 0; struct iguana_bundle *bp; struct iguana_block *block; char str[2000];
hwmheight = coin->blocks.hwmchain.height; hwmheight = coin->blocks.hwmchain.height;
coin->RTramchain_busy = 1; coin->RTramchain_busy = 1;
flag += iguana_processrecvQ(coin,&newhwm); flag += iguana_processrecvQ(coin,&newhwm);
@ -1517,18 +1517,5 @@ int32_t iguana_processrecv(struct iguana_info *coin) // single threaded
iguana_jsonQ(); iguana_jsonQ();
if ( hwmheight != coin->blocks.hwmchain.height ) if ( hwmheight != coin->blocks.hwmchain.height )
flag = 1; flag = 1;
n = 1;
block = iguana_blockfind("main",coin,iguana_blockhash(coin,coin->blocks.hwmchain.height-n));
while ( block != 0 )
{
if ( bits256_cmp(iguana_blockhash(coin,coin->blocks.hwmchain.height-n),block->RO.hash2) != 0 )
{
printf("blockhash error at %d %s\n",coin->blocks.hwmchain.height-n,bits256_str(str,block->RO.hash2));
break;
}
block = iguana_blockfind("RTupdate",coin,block->RO.prev_block);
n++;
}
printf("n.%d vs hwm.%d %s\n",n,coin->blocks.hwmchain.height,bits256_str(str,coin->blocks.hwmchain.RO.hash2));
return(flag); return(flag);
} }

2
iguana/iguana_unspents.c

@ -1928,11 +1928,11 @@ int32_t iguana_realtime_update(struct iguana_info *coin)
bp->isRT = 1; bp->isRT = 1;
while ( (rdata= coin->RTramchain.H.data) != 0 && coin->RTheight <= coin->blocks.hwmchain.height ) while ( (rdata= coin->RTramchain.H.data) != 0 && coin->RTheight <= coin->blocks.hwmchain.height )
{ {
printf("RT.%d vs hwm.%d starti.%d bp->n %d\n",coin->RTheight,coin->blocks.hwmchain.height,coin->RTstarti,bp->n);
dest = &coin->RTramchain; dest = &coin->RTramchain;
B = (void *)(long)((long)rdata + rdata->Boffset); B = (void *)(long)((long)rdata + rdata->Boffset);
bundlei = (coin->RTheight % coin->chain->bundlesize); bundlei = (coin->RTheight % coin->chain->bundlesize);
block = iguana_bundleblock(coin,&hash2,bp,bundlei); block = iguana_bundleblock(coin,&hash2,bp,bundlei);
char str[65]; printf("RT.%d vs hwm.%d starti.%d bp->n %d block.%p prev %s\n",coin->RTheight,coin->blocks.hwmchain.height,coin->RTstarti,bp->n,block,bits256_str(str,block->RO.prev_block));
if ( block != 0 && bits256_nonz(block->RO.prev_block) != 0 ) if ( block != 0 && bits256_nonz(block->RO.prev_block) != 0 )
{ {
iguana_blocksetcounters(coin,block,dest); iguana_blocksetcounters(coin,block,dest);

Loading…
Cancel
Save