Skip to content

Commit 636991d

Browse files
committed
Merge bitcoin/bitcoin#25264: kernel: pass params to BlockManager rather than using a global
a4741bd 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 a4741bd laanwj: Code review ACK a4741bd Tree-SHA512: bfcc0c35e6c23689e968ccc96ceda39dd5a47fe94fbe617902110fe5865c30a40ea614bcfd4b4a2c846d2e84340aa8973e70b0938786af0fecfa3e6016d7fcad
2 parents 39ddd52 + a4741bd commit 636991d

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

src/node/blockstorage.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,9 +318,9 @@ bool BlockManager::WriteBlockIndexDB()
318318
return true;
319319
}
320320

321-
bool BlockManager::LoadBlockIndexDB()
321+
bool BlockManager::LoadBlockIndexDB(const Consensus::Params& consensus_params)
322322
{
323-
if (!LoadBlockIndex(::Params().GetConsensus())) {
323+
if (!LoadBlockIndex(consensus_params)) {
324324
return false;
325325
}
326326

src/node/blockstorage.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ class BlockManager
153153
std::unique_ptr<CBlockTreeDB> m_block_tree_db GUARDED_BY(::cs_main);
154154

155155
bool WriteBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
156-
bool LoadBlockIndexDB() EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
156+
bool LoadBlockIndexDB(const Consensus::Params& consensus_params) EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
157157

158158
CBlockIndex* AddToBlockIndex(const CBlockHeader& block, CBlockIndex*& best_header) EXCLUSIVE_LOCKS_REQUIRED(cs_main);
159159
/** Create a new block index entry for a given block hash */

src/validation.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4158,7 +4158,7 @@ bool ChainstateManager::LoadBlockIndex()
41584158
// Load block index from databases
41594159
bool needs_init = fReindex;
41604160
if (!fReindex) {
4161-
bool ret = m_blockman.LoadBlockIndexDB();
4161+
bool ret = m_blockman.LoadBlockIndexDB(GetConsensus());
41624162
if (!ret) return false;
41634163

41644164
std::vector<CBlockIndex*> vSortedByHeight{m_blockman.GetAllBlockIndices()};

0 commit comments

Comments
 (0)