From edab78ae6b26462413ece794cb30a3c2e3b13a81 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 6 Apr 2016 21:38:20 -0500 Subject: [PATCH] test --- iguana/iguana_blocks.c | 23 ++++++++++++++++++++++- iguana/iguana_recv.c | 15 +-------------- iguana/iguana_unspents.c | 2 +- 3 files changed, 24 insertions(+), 16 deletions(-) diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 23ce24cc3..70fc9a787 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -290,6 +290,26 @@ int32_t iguana_blockunmain(struct iguana_info *coin,struct iguana_block *block) 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) { 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 ( 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 ) { @@ -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); } block->mainchain = 1; + iguana_walkchain(coin); return(block); } } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 0c9dda46d..b34f5e2eb 100755 --- a/iguana/iguana_recv.c +++ b/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 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; coin->RTramchain_busy = 1; flag += iguana_processrecvQ(coin,&newhwm); @@ -1517,18 +1517,5 @@ int32_t iguana_processrecv(struct iguana_info *coin) // single threaded iguana_jsonQ(); if ( hwmheight != coin->blocks.hwmchain.height ) 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); } diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index 09452716a..0100b2050 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -1928,11 +1928,11 @@ int32_t iguana_realtime_update(struct iguana_info *coin) bp->isRT = 1; 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; B = (void *)(long)((long)rdata + rdata->Boffset); bundlei = (coin->RTheight % coin->chain->bundlesize); 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 ) { iguana_blocksetcounters(coin,block,dest);