16
16
#include < reverse_iterator.h>
17
17
#include < util/check.h>
18
18
#include < util/moneystr.h>
19
+ #include < util/overflow.h>
19
20
#include < util/system.h>
20
21
#include < util/time.h>
21
22
#include < validationinterface.h>
@@ -93,9 +94,9 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
93
94
94
95
void CTxMemPoolEntry::UpdateModifiedFee (CAmount fee_diff)
95
96
{
96
- nModFeesWithDescendants += fee_diff;
97
- nModFeesWithAncestors += fee_diff;
98
- m_modified_fee += fee_diff;
97
+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, fee_diff) ;
98
+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, fee_diff) ;
99
+ m_modified_fee = SaturatingAdd (m_modified_fee, fee_diff) ;
99
100
}
100
101
101
102
void CTxMemPoolEntry::UpdateLockPoints (const LockPoints& lp)
@@ -437,7 +438,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
437
438
{
438
439
nSizeWithDescendants += modifySize;
439
440
assert (int64_t (nSizeWithDescendants) > 0 );
440
- nModFeesWithDescendants += modifyFee;
441
+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, modifyFee) ;
441
442
nCountWithDescendants += modifyCount;
442
443
assert (int64_t (nCountWithDescendants) > 0 );
443
444
}
@@ -446,7 +447,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
446
447
{
447
448
nSizeWithAncestors += modifySize;
448
449
assert (int64_t (nSizeWithAncestors) > 0 );
449
- nModFeesWithAncestors += modifyFee;
450
+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, modifyFee) ;
450
451
nCountWithAncestors += modifyCount;
451
452
assert (int64_t (nCountWithAncestors) > 0 );
452
453
nSigOpCostWithAncestors += modifySigOps;
@@ -921,7 +922,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
921
922
{
922
923
LOCK (cs);
923
924
CAmount &delta = mapDeltas[hash];
924
- delta += nFeeDelta;
925
+ delta = SaturatingAdd (delta, nFeeDelta) ;
925
926
txiter it = mapTx.find (hash);
926
927
if (it != mapTx.end ()) {
927
928
mapTx.modify (it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee (nFeeDelta); });
0 commit comments