mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-19 01:42:58 +01:00
validation: call RecalculateBestHeader in InvalidChainFound
This means that it is being called in two situations: 1.) As part of the invalidateblock rpc 2.) When we receive a block for which we have a valid header in our block index, but the block turns out to be invalid
This commit is contained in:
parent
9275e9689a
commit
783cb7337f
@ -2046,7 +2046,7 @@ void Chainstate::InvalidChainFound(CBlockIndex* pindexNew)
|
||||
m_chainman.m_best_invalid = pindexNew;
|
||||
}
|
||||
if (m_chainman.m_best_header != nullptr && m_chainman.m_best_header->GetAncestor(pindexNew->nHeight) == pindexNew) {
|
||||
m_chainman.m_best_header = m_chain.Tip();
|
||||
m_chainman.RecalculateBestHeader();
|
||||
}
|
||||
|
||||
LogPrintf("%s: invalid block=%s height=%d log2_work=%f date=%s\n", __func__,
|
||||
|
@ -41,6 +41,8 @@ class InvalidateTest(BitcoinTestFramework):
|
||||
self.nodes[0].invalidateblock(badhash)
|
||||
assert_equal(self.nodes[0].getblockcount(), 4)
|
||||
assert_equal(self.nodes[0].getbestblockhash(), besthash_n0)
|
||||
# Should report consistent blockchain info
|
||||
assert_equal(self.nodes[0].getblockchaininfo()["headers"], self.nodes[0].getblockchaininfo()["blocks"])
|
||||
|
||||
self.log.info("Make sure we won't reorg to a lower work chain:")
|
||||
self.connect_nodes(1, 2)
|
||||
|
Loading…
Reference in New Issue
Block a user