Skip to content

Commit c058852

Browse files
committed
[refactor] parameterize BlockAssembler::Options in PrepareBlock
1 parent a2de971 commit c058852

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

src/test/util/mining.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
#include <consensus/merkle.h>
99
#include <key_io.h>
1010
#include <node/context.h>
11-
#include <node/miner.h>
1211
#include <pow.h>
1312
#include <script/standard.h>
1413
#include <test/util/script.h>
@@ -74,10 +73,11 @@ CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
7473
return CTxIn{block->vtx[0]->GetHash(), 0};
7574
}
7675

77-
std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
76+
std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey,
77+
const BlockAssembler::Options& assembler_options)
7878
{
7979
auto block = std::make_shared<CBlock>(
80-
BlockAssembler{Assert(node.chainman)->ActiveChainstate(), Assert(node.mempool.get())}
80+
BlockAssembler{Assert(node.chainman)->ActiveChainstate(), Assert(node.mempool.get()), assembler_options}
8181
.CreateNewBlock(coinbase_scriptPubKey)
8282
->block);
8383

@@ -87,3 +87,9 @@ std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coi
8787

8888
return block;
8989
}
90+
std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey)
91+
{
92+
BlockAssembler::Options assembler_options;
93+
ApplyArgsManOptions(*node.args, assembler_options);
94+
return PrepareBlock(node, coinbase_scriptPubKey, assembler_options);
95+
}

src/test/util/mining.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
#ifndef BITCOIN_TEST_UTIL_MINING_H
66
#define BITCOIN_TEST_UTIL_MINING_H
77

8+
#include <node/miner.h>
9+
810
#include <memory>
911
#include <string>
1012
#include <vector>
@@ -25,6 +27,8 @@ CTxIn MineBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey);
2527

2628
/** Prepare a block to be mined */
2729
std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey);
30+
std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext& node, const CScript& coinbase_scriptPubKey,
31+
const node::BlockAssembler::Options& assembler_options);
2832

2933
/** RPC-like helper function, returns the generated coin */
3034
CTxIn generatetoaddress(const node::NodeContext&, const std::string& address);

0 commit comments

Comments
 (0)