1
1
mirror of https://github.com/bitcoin/bitcoin.git synced 2024-05-17 23:56:39 +00:00

Merge bitcoin/bitcoin#25264: kernel: pass params to BlockManager rather than using a global

a4741bd8d4b90b451d982d98eabd0dc5572baa29 kernel: pass params to BlockManager rather than using a global (Cory Fields)

Pull request description:

  In a discussion today, dongcarl and I realized that is the only usage of the global `Params()` left in the kernel code.

  We can use the readily available reference in `ChainstateManager` instead.

  Note: There are still some uses of `BaseParams` in the kernel, so it doesn't make sense to rearrange the definitions quite yet. Once those are gone we can split the globals into new files.

ACKs for top commit:
  MarcoFalke:
    cr ACK a4741bd8d4b90b451d982d98eabd0dc5572baa29
  laanwj:
    Code review ACK a4741bd8d4b90b451d982d98eabd0dc5572baa29

Tree-SHA512: bfcc0c35e6c23689e968ccc96ceda39dd5a47fe94fbe617902110fe5865c30a40ea614bcfd4b4a2c846d2e84340aa8973e70b0938786af0fecfa3e6016d7fcad
This commit is contained in:
laanwj 2022-06-02 19:04:49 +02:00
commit 636991d0c0
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
3 changed files with 4 additions and 4 deletions

View File

@ -318,9 +318,9 @@ bool BlockManager::WriteBlockIndexDB()
return true; return true;
} }
bool BlockManager::LoadBlockIndexDB() bool BlockManager::LoadBlockIndexDB(const Consensus::Params& consensus_params)
{ {
if (!LoadBlockIndex(::Params().GetConsensus())) { if (!LoadBlockIndex(consensus_params)) {
return false; return false;
} }

View File

@ -153,7 +153,7 @@ public:
std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main); std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main);
bool WriteBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); bool WriteBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main); bool LoadBlockIndexDB(const Consensus::Params& consensus_params) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
CBlockIndex* AddToBlockIndex(const CBlockHeader& block, CBlockIndex*& best_header) EXCLUSIVE_LOCKS_REQUIRED(cs_main); CBlockIndex* AddToBlockIndex(const CBlockHeader& block, CBlockIndex*& best_header) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
/** Create a new block index entry for a given block hash */ /** Create a new block index entry for a given block hash */

View File

@ -4158,7 +4158,7 @@ bool ChainstateManager::LoadBlockIndex()
// Load block index from databases // Load block index from databases
bool needs_init = fReindex; bool needs_init = fReindex;
if (!fReindex) { if (!fReindex) {
bool ret = m_blockman.LoadBlockIndexDB(); bool ret = m_blockman.LoadBlockIndexDB(GetConsensus());
if (!ret) return false; if (!ret) return false;
std::vector<CBlockIndex*> vSortedByHeight{m_blockman.GetAllBlockIndices()}; std::vector<CBlockIndex*> vSortedByHeight{m_blockman.GetAllBlockIndices()};