mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-13 22:41:25 +02:00
mining: add submitBlock IPC method to Mining interface
Add a submitBlock method to the Mining IPC interface, similar to the submitblock RPC. This accepts a fully assembled block, validates it, and if accepted as new, processes it into chainstate. This is needed for Stratum v2 Job Declarator Server (JDS), where accepted solutions may correspond to jobs not tied to a Bitcoin Core BlockTemplate. JDS receives PushSolution fields and reconstructs full blocks; without an IPC submitBlock method, final submission requires the submitblock RPC. The method returns detailed status (reason/debug strings) matching the checkBlock pattern, giving callers enough information to handle validation failures.
This commit is contained in:
@@ -1023,6 +1023,17 @@ public:
|
||||
return state.IsValid();
|
||||
}
|
||||
|
||||
bool submitBlock(const CBlock& block_in, std::string& reason, std::string& debug) override
|
||||
{
|
||||
auto block = std::make_shared<const CBlock>(block_in);
|
||||
bool new_block;
|
||||
const bool accepted = SubmitBlock(chainman(), block, &new_block, reason, debug);
|
||||
// ProcessNewBlock() can accept and store a block before it is checked
|
||||
// for validity. Treat duplicates as errors for mining clients, and only
|
||||
// return success when validation completed without setting a reason.
|
||||
return accepted && new_block && reason.empty();
|
||||
}
|
||||
|
||||
const NodeContext* context() override { return &m_node; }
|
||||
ChainstateManager& chainman() { return *Assert(m_node.chainman); }
|
||||
KernelNotifications& notifications() { return *Assert(m_node.notifications); }
|
||||
|
||||
Reference in New Issue
Block a user