mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-11 21:20:39 +02:00
refactor: Move LoadGenesisBlock to ChainstateManager
The function does not need anything from any chainstate, so it should not sit in the Chainstate class. Also, mark it [[nodiscard]], and the one place that ignores the return value with (void). Also, change the error log strings to not include the __func__, which is redundant with -logsourcelocations. This is not a refactor, but this log is only for debugging extremely rare errors.
This commit is contained in:
@@ -1305,7 +1305,7 @@ void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_
|
||||
chainman.m_blockman.m_blockfiles_indexed = true;
|
||||
LogInfo("Reindexing finished");
|
||||
// To avoid ending up in a situation without genesis block, re-try initializing (no-op if reindexing worked):
|
||||
chainman.ActiveChainstate().LoadGenesisBlock();
|
||||
(void)chainman.LoadGenesisBlock();
|
||||
}
|
||||
|
||||
// -loadblock=
|
||||
|
||||
@@ -62,7 +62,7 @@ static ChainstateLoadResult CompleteChainstateInitialization(
|
||||
// If we're not mid-reindex (based on disk + args), add a genesis block on disk
|
||||
// (otherwise we use the one already on disk).
|
||||
// This is called again in ImportBlocks after the reindex completes.
|
||||
if (chainman.m_blockman.m_blockfiles_indexed && !chainman.ActiveChainstate().LoadGenesisBlock()) {
|
||||
if (chainman.m_blockman.m_blockfiles_indexed && !chainman.LoadGenesisBlock()) {
|
||||
return {ChainstateLoadStatus::FAILURE, _("Error initializing block database")};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user