@@ -44,18 +44,20 @@ struct update_descendant_state
44
44
45
45
struct update_ancestor_state
46
46
{
47
- update_ancestor_state (int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost) :
48
- modifySize (_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost)
47
+ update_ancestor_state (int64_t _modifySize, CAmount _modifyFee, int64_t _modifyCount, int64_t _modifySigOpsCost, int64_t _discountSize) :
48
+ modifySize (_modifySize), modifyFee(_modifyFee), modifyCount(_modifyCount), modifySigOpsCost(_modifySigOpsCost),
49
+ discountSize (_discountSize)
49
50
{}
50
51
51
52
void operator () (CTxMemPoolEntry &e)
52
- { e.UpdateAncestorState (modifySize, modifyFee, modifyCount, modifySigOpsCost); }
53
+ { e.UpdateAncestorState (modifySize, modifyFee, modifyCount, modifySigOpsCost, discountSize ); }
53
54
54
55
private:
55
56
int64_t modifySize;
56
57
CAmount modifyFee;
57
58
int64_t modifyCount;
58
59
int64_t modifySigOpsCost;
60
+ int64_t discountSize;
59
61
};
60
62
61
63
struct update_fee_delta
@@ -103,6 +105,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
103
105
nSizeWithAncestors{GetTxSize ()},
104
106
nModFeesWithAncestors{nFee},
105
107
nSigOpCostWithAncestors{sigOpCost},
108
+ discountSizeWithAncestors{GetDiscountTxSize ()},
106
109
setPeginsSpent (_setPeginsSpent) {}
107
110
108
111
void CTxMemPoolEntry::UpdateFeeDelta (int64_t newFeeDelta)
@@ -122,6 +125,11 @@ size_t CTxMemPoolEntry::GetTxSize() const
122
125
return GetVirtualTransactionSize (nTxWeight, sigOpCost);
123
126
}
124
127
128
+ size_t CTxMemPoolEntry::GetDiscountTxSize () const
129
+ {
130
+ return GetDiscountVirtualTransactionSize (*tx, sigOpCost, ::nBytesPerSigOp);
131
+ }
132
+
125
133
void CTxMemPool::UpdateForDescendants (txiter updateIt, cacheMap& cachedDescendants,
126
134
const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove,
127
135
uint64_t ancestor_size_limit, uint64_t ancestor_count_limit)
@@ -160,7 +168,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
160
168
modifyCount++;
161
169
cachedDescendants[updateIt].insert (mapTx.iterator_to (descendant));
162
170
// Update ancestor state for each descendant
163
- mapTx.modify (mapTx.iterator_to (descendant), update_ancestor_state (updateIt->GetTxSize (), updateIt->GetModifiedFee (), 1 , updateIt->GetSigOpCost ()));
171
+ mapTx.modify (mapTx.iterator_to (descendant), update_ancestor_state (updateIt->GetTxSize (), updateIt->GetModifiedFee (), 1 , updateIt->GetSigOpCost (), updateIt-> GetDiscountTxSize () ));
164
172
// Don't directly remove the transaction here -- doing so would
165
173
// invalidate iterators in cachedDescendants. Mark it for removal
166
174
// by inserting into descendants_to_remove.
@@ -371,12 +379,14 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
371
379
int64_t updateSize = 0 ;
372
380
CAmount updateFee = 0 ;
373
381
int64_t updateSigOpsCost = 0 ;
382
+ int64_t discountSize = 0 ;
374
383
for (txiter ancestorIt : setAncestors) {
375
384
updateSize += ancestorIt->GetTxSize ();
376
385
updateFee += ancestorIt->GetModifiedFee ();
377
386
updateSigOpsCost += ancestorIt->GetSigOpCost ();
387
+ discountSize += ancestorIt->GetDiscountTxSize ();
378
388
}
379
- mapTx.modify (it, update_ancestor_state (updateSize, updateFee, updateCount, updateSigOpsCost));
389
+ mapTx.modify (it, update_ancestor_state (updateSize, updateFee, updateCount, updateSigOpsCost, discountSize ));
380
390
}
381
391
382
392
void CTxMemPool::UpdateChildrenForRemoval (txiter it)
@@ -406,8 +416,9 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
406
416
int64_t modifySize = -((int64_t )removeIt->GetTxSize ());
407
417
CAmount modifyFee = -removeIt->GetModifiedFee ();
408
418
int modifySigOps = -removeIt->GetSigOpCost ();
419
+ int64_t discountSize = -((int64_t )removeIt->GetDiscountTxSize ());
409
420
for (txiter dit : setDescendants) {
410
- mapTx.modify (dit, update_ancestor_state (modifySize, modifyFee, -1 , modifySigOps));
421
+ mapTx.modify (dit, update_ancestor_state (modifySize, modifyFee, -1 , modifySigOps, discountSize ));
411
422
}
412
423
}
413
424
}
@@ -456,7 +467,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
456
467
assert (int64_t (nCountWithDescendants) > 0 );
457
468
}
458
469
459
- void CTxMemPoolEntry::UpdateAncestorState (int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps)
470
+ void CTxMemPoolEntry::UpdateAncestorState (int64_t modifySize, CAmount modifyFee, int64_t modifyCount, int64_t modifySigOps, int64_t discountSize )
460
471
{
461
472
nSizeWithAncestors += modifySize;
462
473
assert (int64_t (nSizeWithAncestors) > 0 );
@@ -465,6 +476,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
465
476
assert (int64_t (nCountWithAncestors) > 0 );
466
477
nSigOpCostWithAncestors += modifySigOps;
467
478
assert (int (nSigOpCostWithAncestors) >= 0 );
479
+ discountSizeWithAncestors += discountSize;
468
480
}
469
481
470
482
CTxMemPool::CTxMemPool (CBlockPolicyEstimator* estimator, int check_ratio)
@@ -1030,7 +1042,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
1030
1042
CalculateDescendants (it, setDescendants);
1031
1043
setDescendants.erase (it);
1032
1044
for (txiter descendantIt : setDescendants) {
1033
- mapTx.modify (descendantIt, update_ancestor_state (0 , nFeeDelta, 0 , 0 ));
1045
+ mapTx.modify (descendantIt, update_ancestor_state (0 , nFeeDelta, 0 , 0 , 0 ));
1034
1046
}
1035
1047
++nTransactionsUpdated;
1036
1048
}
0 commit comments