ipc mining: Prevent `Assertion m_node.chainman' failed`` errors on early startup

This fixes ``Assertion `m_node.chainman' failed`` errors first reported
https://github.com/bitcoin/bitcoin/issues/33994#issuecomment-3602551596 when
IPC mining methods are called before ChainstateManager is loaded.

The fix works by making the `Init.makeMining` method block until chainstate
data is loaded.
This commit is contained in:
Ryan Ofsky
2026-02-24 08:31:38 -05:00
parent a7cabf92e4
commit bbc8f1e0a7
6 changed files with 52 additions and 5 deletions

View File

@@ -160,7 +160,11 @@ public:
};
//! Return implementation of Mining interface.
std::unique_ptr<Mining> MakeMining(node::NodeContext& node);
//!
//! @param[in] wait_loaded waits for chainstate data to be loaded before
//! returning. Used to prevent external clients from
//! being able to crash the node during startup.
std::unique_ptr<Mining> MakeMining(node::NodeContext& node, bool wait_loaded=true);
} // namespace interfaces