From 9947ce62626c05bd186ae8a4864aa382f673ec1a Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 7 Oct 2021 01:47:14 +0200 Subject: refactor: use const reference for parents in `CTxMemPool::UpdateAncestorsOf` --- src/txmempool.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/txmempool.cpp') diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 5a93f30c8a..3d0f99cd44 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -276,7 +276,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors) { - CTxMemPoolEntry::Parents parents = it->GetMemPoolParents(); + const CTxMemPoolEntry::Parents& parents = it->GetMemPoolParentsConst(); // add or remove this tx as a child of each parent for (const CTxMemPoolEntry& parent : parents) { UpdateChild(mapTx.iterator_to(parent), it, add); -- cgit v1.2.3 From 65aaf9495d19ea3fb875228a7e14aab6c1f2986d Mon Sep 17 00:00:00 2001 From: Sebastian Falbesoner Date: Thu, 7 Oct 2021 03:26:08 +0200 Subject: refactor: move `update_*` structs from txmempool.h to .cpp file These helpers are exclusively used in txmempool.cpp, hence they should also be moved there. Can be reviewed with "--color-moved=dimmed-zebra". --- src/txmempool.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'src/txmempool.cpp') diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 3d0f99cd44..b8af5a8d07 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -21,6 +21,58 @@ #include #include +// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. +struct update_descendant_state +{ + update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) : + modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount) + {} + + void operator() (CTxMemPoolEntry &e) + { e.UpdateDescendantState(modifySize, modifyFee, modifyCount); } + + private: + int64_t modifySize; + CAmount modifyFee; + int64_t modifyCount; +}; + +struct update_ancestor_state +{ + update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) : + modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost) + {} + + void operator() (CTxMemPoolEntry &e) + { e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOpsCost); } + + private: + int64_t modifySize; + CAmount modifyFee; + int64_t modifyCount; + int64_t modifySigOpsCost; +}; + +struct update_fee_delta +{ + explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { } + + void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); } + +private: + int64_t feeDelta; +}; + +struct update_lock_points +{ + explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { } + + void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); } + +private: + const LockPoints& lp; +}; + CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee, int64_t time, unsigned int entry_height, bool spends_coinbase, int64_t sigops_cost, LockPoints lp) -- cgit v1.2.3