Fixed regtest for reorg.

This commit is contained in:
Chris Kleeschulte 2017-10-09 17:23:10 -04:00
parent 89d8da3a67
commit 01fafcf066
No known key found for this signature in database
GPG Key ID: 33195D27EF6BDB7F

View File

@ -155,6 +155,10 @@ var TestBitcoind = function TestBitcoind() {
var plusOneBlockHash = data.slice(-32).reverse().toString('hex');
if (plusOneBlockHash !== '0000000000000000000000000000000000000000000000000000000000000000') {
var nextBlock = self.blocks.get(plusOneBlockHash);
if (!nextBlock) {
console.log('did not find next block!!!!');
return;
}
blockHash = bcoin.util.revHex(nextBlock.prevBlock);
} else {
blockHash = self.blocks.getLastIndex().rhash();