diff options
author | Carl Dong <contact@carldong.me> | 2022-05-25 22:06:23 -0400 |
---|---|---|
committer | Carl Dong <contact@carldong.me> | 2022-06-06 15:38:09 -0400 |
commit | 0f1a259657280afc727db97689512aef5ca928fc (patch) | |
tree | df44289c04dd3c24f631b92399c1c6a02811f4ae /src/test/util | |
parent | cc5739b27df830d138119eaa13f2286d91d0dadd (diff) | |
download | bitcoin-0f1a259657280afc727db97689512aef5ca928fc.tar.xz |
miner: Make mempool optional for BlockAssembler
...also adjust callers
Changes:
- In BlockAssembler::CreateNewBlock, we now only lock m_mempool->cs and
call addPackageTxs if m_mempool is not nullptr
- BlockAssembler::addPackageTxs now takes in a mempool reference, and is
annotated to require that mempool's lock.
- In TestChain100Setup::CreateBlock and generateblock, don't construct
an empty mempool, just pass in a nullptr for mempool
Diffstat (limited to 'src/test/util')
-rw-r--r-- | src/test/util/mining.cpp | 2 | ||||
-rw-r--r-- | src/test/util/setup_common.cpp | 3 |
2 files changed, 2 insertions, 3 deletions
diff --git a/src/test/util/mining.cpp b/src/test/util/mining.cpp index a6d624fe84..88cf9647e7 100644 --- a/src/test/util/mining.cpp +++ b/src/test/util/mining.cpp @@ -77,7 +77,7 @@ CTxIn MineBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey) std::shared_ptr<CBlock> PrepareBlock(const NodeContext& node, const CScript& coinbase_scriptPubKey) { auto block = std::make_shared<CBlock>( - BlockAssembler{Assert(node.chainman)->ActiveChainstate(), *Assert(node.mempool)} + BlockAssembler{Assert(node.chainman)->ActiveChainstate(), Assert(node.mempool.get())} .CreateNewBlock(coinbase_scriptPubKey) ->block); diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp index b7566bd1fa..67820d50bd 100644 --- a/src/test/util/setup_common.cpp +++ b/src/test/util/setup_common.cpp @@ -277,8 +277,7 @@ CBlock TestChain100Setup::CreateBlock( const CScript& scriptPubKey, CChainState& chainstate) { - CTxMemPool empty_pool; - CBlock block = BlockAssembler{chainstate, empty_pool}.CreateNewBlock(scriptPubKey)->block; + CBlock block = BlockAssembler{chainstate, nullptr}.CreateNewBlock(scriptPubKey)->block; Assert(block.vtx.size() == 1); for (const CMutableTransaction& tx : txns) { |