Skip to content

Commit 6e747e8

Browse files
ajtownsdongcarl
authored andcommitted
validation: default initialize and guard chainman members
1 parent 98f4bda commit 6e747e8

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

src/test/validation_chainstate_tests.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ BOOST_FIXTURE_TEST_CASE(chainstate_update_tip, TestChain100Setup)
9393
BOOST_REQUIRE(CreateAndActivateUTXOSnapshot(m_node, m_path_root));
9494

9595
// Ensure our active chain is the snapshot chainstate.
96-
BOOST_CHECK(chainman.IsSnapshotActive());
96+
BOOST_CHECK(WITH_LOCK(::cs_main, return chainman.IsSnapshotActive()));
9797

9898
curr_tip = ::g_best_block;
9999

src/test/validation_chainstatemanager_tests.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
4545
WITH_LOCK(::cs_main, c1.InitCoinsCache(1 << 23));
4646

4747
BOOST_CHECK(!manager.IsSnapshotActive());
48-
BOOST_CHECK(!manager.IsSnapshotValidated());
48+
BOOST_CHECK(WITH_LOCK(::cs_main, return !manager.IsSnapshotValidated()));
4949
auto all = manager.GetAll();
5050
BOOST_CHECK_EQUAL_COLLECTIONS(all.begin(), all.end(), chainstates.begin(), chainstates.end());
5151

@@ -78,7 +78,7 @@ BOOST_AUTO_TEST_CASE(chainstatemanager)
7878
BOOST_CHECK(c2.ActivateBestChain(_, nullptr));
7979

8080
BOOST_CHECK(manager.IsSnapshotActive());
81-
BOOST_CHECK(!manager.IsSnapshotValidated());
81+
BOOST_CHECK(WITH_LOCK(::cs_main, return !manager.IsSnapshotValidated()));
8282
BOOST_CHECK_EQUAL(&c2, &manager.ActiveChainstate());
8383
BOOST_CHECK(&c1 != &manager.ActiveChainstate());
8484
auto all2 = manager.GetAll();

src/validation.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -831,9 +831,9 @@ class ChainstateManager
831831

832832
//! If true, the assumed-valid chainstate has been fully validated
833833
//! by the background validation chainstate.
834-
bool m_snapshot_validated{false};
834+
bool m_snapshot_validated GUARDED_BY(::cs_main){false};
835835

836-
CBlockIndex* m_best_invalid;
836+
CBlockIndex* m_best_invalid GUARDED_BY(::cs_main){nullptr};
837837

838838
//! Internal helper for ActivateSnapshot().
839839
[[nodiscard]] bool PopulateAndValidateSnapshot(
@@ -940,7 +940,7 @@ class ChainstateManager
940940
std::optional<uint256> SnapshotBlockhash() const;
941941

942942
//! Is there a snapshot in use and has it been fully validated?
943-
bool IsSnapshotValidated() const { return m_snapshot_validated; }
943+
bool IsSnapshotValidated() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main) { return m_snapshot_validated; }
944944

945945
/**
946946
* Process an incoming block. This only returns after the best known valid

0 commit comments

Comments
 (0)