mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-16 13:01:19 +02:00
Merge 0c2c3bb3f5 into merged_master (Bitcoin PR bitcoin/bitcoin#30955)
This commit is contained in:
commit
b8f2ccaca4
6 changed files with 163 additions and 106 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include <chain.h>
|
||||
#include <chainparams.h>
|
||||
#include <common/args.h>
|
||||
#include <consensus/merkle.h>
|
||||
#include <consensus/validation.h>
|
||||
#include <deploymentstatus.h>
|
||||
#include <external_signer.h>
|
||||
|
|
@ -890,7 +891,7 @@ public:
|
|||
class BlockTemplateImpl : public BlockTemplate
|
||||
{
|
||||
public:
|
||||
explicit BlockTemplateImpl(std::unique_ptr<CBlockTemplate> block_template) : m_block_template(std::move(block_template))
|
||||
explicit BlockTemplateImpl(std::unique_ptr<CBlockTemplate> block_template, NodeContext& node) : m_block_template(std::move(block_template)), m_node(node)
|
||||
{
|
||||
assert(m_block_template);
|
||||
}
|
||||
|
|
@ -930,7 +931,37 @@ public:
|
|||
return GetWitnessCommitmentIndex(m_block_template->block);
|
||||
}
|
||||
|
||||
std::vector<uint256> getCoinbaseMerklePath() override
|
||||
{
|
||||
return BlockMerkleBranch(m_block_template->block);
|
||||
}
|
||||
|
||||
bool submitSolution(uint32_t version, uint32_t timestamp, uint32_t nonce, CMutableTransaction coinbase) override
|
||||
{
|
||||
CBlock block{m_block_template->block};
|
||||
|
||||
auto cb = MakeTransactionRef(std::move(coinbase));
|
||||
|
||||
if (block.vtx.size() == 0) {
|
||||
block.vtx.push_back(cb);
|
||||
} else {
|
||||
block.vtx[0] = cb;
|
||||
}
|
||||
|
||||
block.nVersion = version;
|
||||
block.nTime = timestamp;
|
||||
block.nNonce = nonce;
|
||||
|
||||
block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||
|
||||
auto block_ptr = std::make_shared<const CBlock>(block);
|
||||
return chainman().ProcessNewBlock(block_ptr, /*force_processing=*/true, /*min_pow_checked=*/true, /*new_block=*/nullptr);
|
||||
}
|
||||
|
||||
const std::unique_ptr<CBlockTemplate> m_block_template;
|
||||
|
||||
ChainstateManager& chainman() { return *Assert(m_node.chainman); }
|
||||
NodeContext& m_node;
|
||||
};
|
||||
|
||||
class MinerImpl : public Mining
|
||||
|
|
@ -997,7 +1028,7 @@ public:
|
|||
{
|
||||
BlockAssembler::Options assemble_options{options};
|
||||
ApplyArgsManOptions(*Assert(m_node.args), assemble_options);
|
||||
return std::make_unique<BlockTemplateImpl>(BlockAssembler{chainman().ActiveChainstate(), context()->mempool.get(), assemble_options}.CreateNewBlock(script_pub_key));
|
||||
return std::make_unique<BlockTemplateImpl>(BlockAssembler{chainman().ActiveChainstate(), context()->mempool.get(), assemble_options}.CreateNewBlock(script_pub_key), m_node);
|
||||
}
|
||||
|
||||
NodeContext* context() override { return &m_node; }
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue