mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-21 14:34:49 +01:00
Require CBlockIndex::IsAssumedValid() to hold cs_main
This commit is contained in:
parent
572393448b
commit
8ef457cb83
2 changed files with 7 additions and 2 deletions
|
@ -320,7 +320,11 @@ public:
|
|||
|
||||
//! @returns true if the block is assumed-valid; this means it is queued to be
|
||||
//! validated by a background chainstate.
|
||||
bool IsAssumedValid() const { return nStatus & BLOCK_ASSUMED_VALID; }
|
||||
bool IsAssumedValid() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main)
|
||||
{
|
||||
AssertLockHeld(::cs_main);
|
||||
return nStatus & BLOCK_ASSUMED_VALID;
|
||||
}
|
||||
|
||||
//! Raise the validity level of this block index entry.
|
||||
//! Returns true if the validity was changed.
|
||||
|
|
|
@ -235,7 +235,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_activate_snapshot, TestChain100Setup)
|
|||
*chainman.SnapshotBlockhash());
|
||||
|
||||
// Ensure that the genesis block was not marked assumed-valid.
|
||||
BOOST_CHECK(!chainman.ActiveChain().Genesis()->IsAssumedValid());
|
||||
BOOST_CHECK(WITH_LOCK(::cs_main, return !chainman.ActiveChain().Genesis()->IsAssumedValid()));
|
||||
|
||||
const AssumeutxoData& au_data = *ExpectedAssumeutxo(snapshot_height, ::Params());
|
||||
const CBlockIndex* tip = chainman.ActiveTip();
|
||||
|
@ -356,6 +356,7 @@ BOOST_FIXTURE_TEST_CASE(chainstatemanager_loadblockindex, TestChain100Setup)
|
|||
|
||||
// Mark some region of the chain assumed-valid.
|
||||
for (int i = 0; i <= cs1.m_chain.Height(); ++i) {
|
||||
LOCK(::cs_main);
|
||||
auto index = cs1.m_chain[i];
|
||||
|
||||
if (i < last_assumed_valid_idx && i >= assumed_valid_start_idx) {
|
||||
|
|
Loading…
Add table
Reference in a new issue