mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
[refactor] Cleanup BlockAssembler mempool usage
The `addPackageTxs` method of the `BlockAssembler` currently has access to two mempool variables, as an argument and as a member. Clean this up and clarify that they both are the same mempool instance by removing the argument and instead only using the member variable in the method. Co-Authored-By: Anthony Towns <aj@erisian.com.au> Co-authored-by: stickies-v <stickies-v@protonmail.com>
This commit is contained in:
parent
d4cc0c6845
commit
192dac1d33
2 changed files with 9 additions and 6 deletions
|
@ -142,8 +142,7 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
|
||||||
int nPackagesSelected = 0;
|
int nPackagesSelected = 0;
|
||||||
int nDescendantsUpdated = 0;
|
int nDescendantsUpdated = 0;
|
||||||
if (m_mempool) {
|
if (m_mempool) {
|
||||||
LOCK(m_mempool->cs);
|
addPackageTxs(nPackagesSelected, nDescendantsUpdated);
|
||||||
addPackageTxs(*m_mempool, nPackagesSelected, nDescendantsUpdated);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto time_1{SteadyClock::now()};
|
const auto time_1{SteadyClock::now()};
|
||||||
|
@ -292,9 +291,10 @@ void BlockAssembler::SortForBlock(const CTxMemPool::setEntries& package, std::ve
|
||||||
// Each time through the loop, we compare the best transaction in
|
// Each time through the loop, we compare the best transaction in
|
||||||
// mapModifiedTxs with the next transaction in the mempool to decide what
|
// mapModifiedTxs with the next transaction in the mempool to decide what
|
||||||
// transaction package to work on next.
|
// transaction package to work on next.
|
||||||
void BlockAssembler::addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated)
|
void BlockAssembler::addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated)
|
||||||
{
|
{
|
||||||
AssertLockHeld(mempool.cs);
|
const auto& mempool{*Assert(m_mempool)};
|
||||||
|
LOCK(mempool.cs);
|
||||||
|
|
||||||
// mapModifiedTx will store sorted packages after they are modified
|
// mapModifiedTx will store sorted packages after they are modified
|
||||||
// because some of their txs are already in the block
|
// because some of their txs are already in the block
|
||||||
|
|
|
@ -187,8 +187,11 @@ private:
|
||||||
// Methods for how to add transactions to a block.
|
// Methods for how to add transactions to a block.
|
||||||
/** Add transactions based on feerate including unconfirmed ancestors
|
/** Add transactions based on feerate including unconfirmed ancestors
|
||||||
* Increments nPackagesSelected / nDescendantsUpdated with corresponding
|
* Increments nPackagesSelected / nDescendantsUpdated with corresponding
|
||||||
* statistics from the package selection (for logging statistics). */
|
* statistics from the package selection (for logging statistics).
|
||||||
void addPackageTxs(const CTxMemPool& mempool, int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(mempool.cs);
|
*
|
||||||
|
* @pre BlockAssembler::m_mempool must not be nullptr
|
||||||
|
*/
|
||||||
|
void addPackageTxs(int& nPackagesSelected, int& nDescendantsUpdated) EXCLUSIVE_LOCKS_REQUIRED(!m_mempool->cs);
|
||||||
|
|
||||||
// helper functions for addPackageTxs()
|
// helper functions for addPackageTxs()
|
||||||
/** Remove confirmed (inBlock) entries from given set */
|
/** Remove confirmed (inBlock) entries from given set */
|
||||||
|
|
Loading…
Add table
Reference in a new issue