mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-06-02 09:15:04 +02:00
Merge bitcoin/bitcoin#32364: refactor: validation: mark CheckBlockIndex as const
3e6ac5bf77refactor: validation: mark CheckBlockIndex as const (stickies-v)61a51eccbbvalidation: don't use GetAll() in CheckBlockIndex() (stickies-v)d05481df64refactor: validation: mark SnapshotBase as const (stickies-v) Pull request description: While reviewing another PR, I [noticed](https://github.com/bitcoin/bitcoin/pull/31405#discussion_r2056509235) that `ChainstateManager::CheckBlockIndex()` is not a `const` method. To try and assert that this method was not causing any side-effects, I modified the method to make it `const`. It did not surface any errors, but I think it would be good to merge this change regardless, even if `CheckBlockIndex` is only used in regtest. This PR removes `CheckBlockIndex()`'s calls to non-const `ChainstateManager` methods by marking `SnapshotBase` `const` and ~inlining the `GetAll()` calls (thereby also performing consistency checks on invalid or fully validated `m_disabled==true` chainstates, as slight behaviour change), and finally marks `CheckBlockIndex()` as `const`. ACKs for top commit: achow101: ACK3e6ac5bf77mzumsande: Code Review ACK3e6ac5bf77TheCharlatan: ACK3e6ac5bf77Tree-SHA512: 3d3cd351f5af1fab9a9498218ec62dba6e397fc7b5f4868ae0a77dc2b7c813d12c4f53f253f209101a3f6523695014e20c82dfac27cf0035611d5dd29feb80b5
This commit is contained in:
@@ -534,7 +534,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
|
||||
@@ -598,7 +598,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
|
||||
@@ -984,7 +984,7 @@ public:
|
||||
*
|
||||
* By default this only executes fully when using the Regtest chain; see: m_options.check_block_index.
|
||||
*/
|
||||
void CheckBlockIndex();
|
||||
void CheckBlockIndex() const;
|
||||
|
||||
/**
|
||||
* Alias for ::cs_main.
|
||||
|
||||
Reference in New Issue
Block a user