20
20
#include < reverse_iterator.h>
21
21
#include < util/check.h>
22
22
#include < util/moneystr.h>
23
+ #include < util/overflow.h>
23
24
#include < util/system.h>
24
25
#include < util/time.h>
25
26
#include < validationinterface.h>
@@ -102,9 +103,9 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
102
103
103
104
void CTxMemPoolEntry::UpdateModifiedFee (CAmount fee_diff)
104
105
{
105
- nModFeesWithDescendants += fee_diff;
106
- nModFeesWithAncestors += fee_diff;
107
- m_modified_fee += fee_diff;
106
+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, fee_diff) ;
107
+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, fee_diff) ;
108
+ m_modified_fee = SaturatingAdd (m_modified_fee, fee_diff) ;
108
109
}
109
110
110
111
void CTxMemPoolEntry::UpdateLockPoints (const LockPoints& lp)
@@ -459,7 +460,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
459
460
{
460
461
nSizeWithDescendants += modifySize;
461
462
assert (int64_t (nSizeWithDescendants) > 0 );
462
- nModFeesWithDescendants += modifyFee;
463
+ nModFeesWithDescendants = SaturatingAdd (nModFeesWithDescendants, modifyFee) ;
463
464
nCountWithDescendants += modifyCount;
464
465
assert (int64_t (nCountWithDescendants) > 0 );
465
466
}
@@ -468,7 +469,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
468
469
{
469
470
nSizeWithAncestors += modifySize;
470
471
assert (int64_t (nSizeWithAncestors) > 0 );
471
- nModFeesWithAncestors += modifyFee;
472
+ nModFeesWithAncestors = SaturatingAdd (nModFeesWithAncestors, modifyFee) ;
472
473
nCountWithAncestors += modifyCount;
473
474
assert (int64_t (nCountWithAncestors) > 0 );
474
475
nSigOpCostWithAncestors += modifySigOps;
@@ -1018,7 +1019,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
1018
1019
{
1019
1020
LOCK (cs);
1020
1021
CAmount &delta = mapDeltas[hash];
1021
- delta += nFeeDelta;
1022
+ delta = SaturatingAdd (delta, nFeeDelta) ;
1022
1023
txiter it = mapTx.find (hash);
1023
1024
if (it != mapTx.end ()) {
1024
1025
mapTx.modify (it, [&nFeeDelta](CTxMemPoolEntry& e) { e.UpdateModifiedFee (nFeeDelta); });
0 commit comments