aboutsummaryrefslogtreecommitdiff
path: root/src/validation.h
diff options
context:
space:
mode:
authorJames O'Beirne <james.obeirne@pm.me>2021-10-28 16:07:46 -0400
committerJames O'Beirne <james.obeirne@pm.me>2021-12-13 13:45:27 -0500
commit0fd599a51a700c028d6f7ed8067d2d9f6e6a04a5 (patch)
treeb3f7e049a45d00dc3e849aea9c0f5fe7c53862ed /src/validation.h
parentd0c6e61f5dd3b6af818459d9d03b7ba316c5a3f7 (diff)
downloadbitcoin-0fd599a51a700c028d6f7ed8067d2d9f6e6a04a5.tar.xz
validation: have LoadBlockIndex account for snapshot use
Ensure that blocks past the snapshot base block (i.e. the end of the assumed-valid region of the chain) are not included in setBlockIndexCandidates for the background validation chainstate. These blocks, while fully validated and lacking the BLOCK_ASSUMED_VALID flag, *rely* on blocks which are assumed-valid, and so shouldn't be added to the IBD chainstate. Co-authored-by: Russ Yanofsky <russ@yanofsky.org>
Diffstat (limited to 'src/validation.h')
-rw-r--r--src/validation.h12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/validation.h b/src/validation.h
index 4da8ec8d24..7c7ad4bbc6 100644
--- a/src/validation.h
+++ b/src/validation.h
@@ -427,20 +427,16 @@ public:
std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main);
- bool LoadBlockIndexDB(std::set<CBlockIndex*, CBlockIndexWorkComparator>& setBlockIndexCandidates) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
+ bool LoadBlockIndexDB(ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
/**
* Load the blocktree off disk and into memory. Populate certain metadata
* per index entry (nStatus, nChainWork, nTimeMax, etc.) as well as peripheral
* collections like setDirtyBlockIndex.
- *
- * @param[out] block_index_candidates Fill this set with any valid blocks for
- * which we've downloaded all transactions.
*/
bool LoadBlockIndex(
const Consensus::Params& consensus_params,
- std::set<CBlockIndex*, CBlockIndexWorkComparator>& block_index_candidates)
- EXCLUSIVE_LOCKS_REQUIRED(cs_main);
+ ChainstateManager& chainman) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Clear all data members. */
void Unload() EXCLUSIVE_LOCKS_REQUIRED(cs_main);
@@ -626,6 +622,10 @@ public:
*/
const std::optional<uint256> m_from_snapshot_blockhash;
+ //! Return true if this chainstate relies on blocks that are assumed-valid. In
+ //! practice this means it was created based on a UTXO snapshot.
+ bool reliesOnAssumedValid() { return m_from_snapshot_blockhash.has_value(); }
+
/**
* The set of all CBlockIndex entries with either BLOCK_VALID_TRANSACTIONS (for
* itself and all ancestors) *or* BLOCK_ASSUMED_VALID (if using background