mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
rpc: Remove mempool global from miner
This commit is contained in:
@@ -8,22 +8,23 @@
|
||||
#include <consensus/merkle.h>
|
||||
#include <key_io.h>
|
||||
#include <miner.h>
|
||||
#include <node/context.h>
|
||||
#include <pow.h>
|
||||
#include <script/standard.h>
|
||||
#include <validation.h>
|
||||
|
||||
CTxIn generatetoaddress(const std::string& address)
|
||||
CTxIn generatetoaddress(const NodeContext& node, const std::string& address)
|
||||
{
|
||||
const auto dest = DecodeDestination(address);
|
||||
assert(IsValidDestination(dest));
|
||||
const auto coinbase_script = GetScriptForDestination(dest);
|
||||
|
||||
return MineBlock(coinbase_script);
|
||||
return MineBlock(node, coinbase_script);
|
||||
}
|
||||
|
||||
CTxIn MineBlock(const CScript& coinbase_scriptPubKey)
|
||||
CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
|
||||
{
|
||||
auto block = PrepareBlock(coinbase_scriptPubKey);
|
||||
auto block = PrepareBlock(node, coinbase_scriptPubKey);
|
||||
|
||||
while (!CheckProofOfWork(block->GetHash(), block->nBits, Params().GetConsensus())) {
|
||||
++block->nNonce;
|
||||
@@ -36,10 +37,11 @@ CTxIn MineBlock(const CScript& coinbase_scriptPubKey)
|
||||
return CTxIn{block->vtx[0]->GetHash(), 0};
|
||||
}
|
||||
|
||||
std::shared_ptr<CBlock> PrepareBlock(const CScript& coinbase_scriptPubKey)
|
||||
std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
|
||||
{
|
||||
assert(node.mempool);
|
||||
auto block = std::make_shared<CBlock>(
|
||||
BlockAssembler{Params()}
|
||||
BlockAssembler{*node.mempool, Params()}
|
||||
.CreateNewBlock(coinbase_scriptPubKey)
|
||||
->block);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user