|
22 | 22 | #include <cmath>
|
23 | 23 | #include <optional>
|
24 | 24 |
|
| 25 | +// Helpers for modifying CTxMemPool::mapTx, which is a boost multi_index. |
| 26 | +struct update_descendant_state |
| 27 | +{ |
| 28 | + update_descendant_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount) : |
| 29 | + modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount) |
| 30 | + {} |
| 31 | + |
| 32 | + void operator() (CTxMemPoolEntry &e) |
| 33 | + { e.UpdateDescendantState(modifySize, modifyFee, modifyCount); } |
| 34 | + |
| 35 | + private: |
| 36 | + int64_t modifySize; |
| 37 | + CAmount modifyFee; |
| 38 | + int64_t modifyCount; |
| 39 | +}; |
| 40 | + |
| 41 | +struct update_ancestor_state |
| 42 | +{ |
| 43 | + update_ancestor_state(int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) : |
| 44 | + modifySize(_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost) |
| 45 | + {} |
| 46 | + |
| 47 | + void operator() (CTxMemPoolEntry &e) |
| 48 | + { e.UpdateAncestorState(modifySize, modifyFee, modifyCount, modifySigOpsCost); } |
| 49 | + |
| 50 | + private: |
| 51 | + int64_t modifySize; |
| 52 | + CAmount modifyFee; |
| 53 | + int64_t modifyCount; |
| 54 | + int64_t modifySigOpsCost; |
| 55 | +}; |
| 56 | + |
| 57 | +struct update_fee_delta |
| 58 | +{ |
| 59 | + explicit update_fee_delta(int64_t _feeDelta) : feeDelta(_feeDelta) { } |
| 60 | + |
| 61 | + void operator() (CTxMemPoolEntry &e) { e.UpdateFeeDelta(feeDelta); } |
| 62 | + |
| 63 | +private: |
| 64 | + int64_t feeDelta; |
| 65 | +}; |
| 66 | + |
| 67 | +struct update_lock_points |
| 68 | +{ |
| 69 | + explicit update_lock_points(const LockPoints& _lp) : lp(_lp) { } |
| 70 | + |
| 71 | + void operator() (CTxMemPoolEntry &e) { e.UpdateLockPoints(lp); } |
| 72 | + |
| 73 | +private: |
| 74 | + const LockPoints& lp; |
| 75 | +}; |
| 76 | + |
25 | 77 | CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
26 | 78 | int64_t time, unsigned int entry_height,
|
27 | 79 | bool spends_coinbase, int64_t sigops_cost, LockPoints lp)
|
@@ -277,7 +329,7 @@ bool CTxMemPool::CalculateMemPoolAncestors(const CTxMemPoolEntry &entry,
|
277 | 329 |
|
278 | 330 | void CTxMemPool::UpdateAncestorsOf(bool add, txiter it, setEntries &setAncestors)
|
279 | 331 | {
|
280 |
| - CTxMemPoolEntry::Parents parents = it->GetMemPoolParents(); |
| 332 | + const CTxMemPoolEntry::Parents& parents = it->GetMemPoolParentsConst(); |
281 | 333 | // add or remove this tx as a child of each parent
|
282 | 334 | for (const CTxMemPoolEntry& parent : parents) {
|
283 | 335 | UpdateChild(mapTx.iterator_to(parent), it, add);
|
|
0 commit comments