interfaces/mining: Add createNewBlock2 that does not override or lose options

This commit is contained in:
Luke Dashjr 2025-01-30 19:41:05 +00:00
parent 275a540ea8
commit 23fd2eb9b1
2 changed files with 7 additions and 1 deletions

View File

@ -40,13 +40,14 @@ public:
virtual std::optional<uint256> getTipHash() = 0;
/**
* Construct a new block template
* Construct a new block template. For the createNewBlock variant, subclass options (if any) are silently lost and overridden by any config args. For createNewBlock2, the options are assumed to be complete.
*
* @param[in] script_pub_key the coinbase output
* @param[in] options options for creating the block
* @returns a block template
*/
virtual std::unique_ptr<node::CBlockTemplate> createNewBlock(const CScript& script_pub_key, const node::BlockCreateOptions& options={}) = 0;
virtual std::unique_ptr<node::CBlockTemplate> createNewBlock2(const CScript& script_pub_key, const node::BlockCreateOptions& assemble_options) = 0;
/**
* Processes new block. A valid new block is automatically relayed to peers.

View File

@ -913,6 +913,11 @@ public:
{
BlockAssembler::Options assemble_options{options};
ApplyArgsManOptions(*Assert(m_node.args), assemble_options);
return createNewBlock2(script_pub_key, assemble_options);
}
std::unique_ptr<CBlockTemplate> createNewBlock2(const CScript& script_pub_key, const BlockCreateOptions& assemble_options) override
{
return BlockAssembler{chainman().ActiveChainstate(), context()->mempool.get(), assemble_options}.CreateNewBlock(script_pub_key);
}