|
14 | 14 | #include <policy/policy.h>
|
15 | 15 | #include <policy/settings.h>
|
16 | 16 | #include <reverse_iterator.h>
|
| 17 | +#include <util/check.h> |
17 | 18 | #include <util/moneystr.h>
|
18 | 19 | #include <util/system.h>
|
19 | 20 | #include <util/time.h>
|
@@ -82,18 +83,19 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
|
82 | 83 | entryHeight{entry_height},
|
83 | 84 | spendsCoinbase{spends_coinbase},
|
84 | 85 | sigOpCost{sigops_cost},
|
| 86 | + m_modified_fee{nFee}, |
85 | 87 | lockPoints{lp},
|
86 | 88 | nSizeWithDescendants{GetTxSize()},
|
87 | 89 | nModFeesWithDescendants{nFee},
|
88 | 90 | nSizeWithAncestors{GetTxSize()},
|
89 | 91 | nModFeesWithAncestors{nFee},
|
90 | 92 | nSigOpCostWithAncestors{sigOpCost} {}
|
91 | 93 |
|
92 |
| -void CTxMemPoolEntry::UpdateFeeDelta(CAmount newFeeDelta) |
| 94 | +void CTxMemPoolEntry::UpdateModifiedFee(CAmount fee_diff) |
93 | 95 | {
|
94 |
| - nModFeesWithDescendants += newFeeDelta - feeDelta; |
95 |
| - nModFeesWithAncestors += newFeeDelta - feeDelta; |
96 |
| - feeDelta = newFeeDelta; |
| 96 | + nModFeesWithDescendants += fee_diff; |
| 97 | + nModFeesWithAncestors += fee_diff; |
| 98 | + m_modified_fee += fee_diff; |
97 | 99 | }
|
98 | 100 |
|
99 | 101 | void CTxMemPoolEntry::UpdateLockPoints(const LockPoints& lp)
|
@@ -483,8 +485,10 @@ void CTxMemPool::addUnchecked(const CTxMemPoolEntry &entry, setEntries &setAnces
|
483 | 485 | // Update transaction for any feeDelta created by PrioritiseTransaction
|
484 | 486 | CAmount delta{0};
|
485 | 487 | ApplyDelta(entry.GetTx().GetHash(), delta);
|
| 488 | + // The following call to UpdateModifiedFee assumes no previous fee modifications |
| 489 | + Assume(entry.GetFee() == entry.GetModifiedFee()); |
486 | 490 | if (delta) {
|
487 |
| - mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); |
| 491 | + mapTx.modify(newit, [&delta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(delta); }); |
488 | 492 | }
|
489 | 493 |
|
490 | 494 | // Update cachedInnerUsage to include contained transaction's usage.
|
@@ -920,7 +924,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
|
920 | 924 | delta += nFeeDelta;
|
921 | 925 | txiter it = mapTx.find(hash);
|
922 | 926 | if (it != mapTx.end()) {
|
923 |
| - mapTx.modify(it, [&delta](CTxMemPoolEntry& e) { e.UpdateFeeDelta(delta); }); |
| 927 | + mapTx.modify(it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee(nFeeDelta); }); |
924 | 928 | // Now update all ancestors' modified fees with descendants
|
925 | 929 | setEntries setAncestors;
|
926 | 930 | uint64_t nNoLimit = std::numeric_limits<uint64_t>::max();
|
|
0 commit comments