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/node/miner.h | |
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/node/miner.h')
-rw-r--r-- | src/node/miner.h | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/node/miner.h b/src/node/miner.h index 4e4f02ce4d..26454df3df 100644 --- a/src/node/miner.h +++ b/src/node/miner.h @@ -147,7 +147,7 @@ private: int64_t m_lock_time_cutoff; const CChainParams& chainparams; - const CTxMemPool& m_mempool; + const CTxMemPool* const m_mempool; CChainState& m_chainstate; public: @@ -157,8 +157,8 @@ public: CFeeRate blockMinFeeRate; }; - explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool); - explicit BlockAssembler(CChainState& chainstate, const CTxMemPool& mempool, const Options& options); + explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool); + explicit BlockAssembler(CChainState& chainstate, const CTxMemPool* mempool, const Options& options); /** Construct a new block template with coinbase to scriptPubKeyIn */ std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn); @@ -177,7 +177,7 @@ private: /** Add transactions based on feerate including unconfirmed ancestors * Increments nPackagesSelected / nDescendantsUpdated with corresponding * statistics from the package selection (for logging statistics). */ - void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(m_mempool.cs); + void addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs); // helper functions for addPackageTxs() /** Remove confirmed (inBlock) entries from given set */ |