diff --git a/src/validation.cpp b/src/validation.cpp index 1213d8be9f9..cd53727d250 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1970,7 +1970,7 @@ Chainstate::Chainstate( m_chainman(chainman), m_from_snapshot_blockhash(from_snapshot_blockhash) {} -const CBlockIndex* Chainstate::SnapshotBase() +const CBlockIndex* Chainstate::SnapshotBase() const { if (!m_from_snapshot_blockhash) return nullptr; if (!m_cached_snapshot_base) m_cached_snapshot_base = Assert(m_chainman.m_blockman.LookupBlockIndex(*m_from_snapshot_blockhash)); diff --git a/src/validation.h b/src/validation.h index e361c7af101..1951120d15c 100644 --- a/src/validation.h +++ b/src/validation.h @@ -532,7 +532,7 @@ protected: bool m_disabled GUARDED_BY(::cs_main) {false}; //! Cached result of LookupBlockIndex(*m_from_snapshot_blockhash) - const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main) {nullptr}; + mutable const CBlockIndex* m_cached_snapshot_base GUARDED_BY(::cs_main){nullptr}; public: //! Reference to a BlockManager instance which itself is shared across all @@ -596,7 +596,7 @@ public: * * nullptr if this chainstate was not created from a snapshot. */ - const CBlockIndex* SnapshotBase() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); + const CBlockIndex* SnapshotBase() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main); /** * The set of all CBlockIndex entries that have as much work as our current