@@ -44,18 +44,20 @@ struct update_descendant_state
4444
4545struct update_ancestor_state
4646{
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)
4950 {}
5051
5152 void operator () (CTxMemPoolEntry &e)
52- { e.UpdateAncestorState (modifySize, modifyFee, modifyCount, modifySigOpsCost); }
53+ { e.UpdateAncestorState (modifySize, modifyFee, modifyCount, modifySigOpsCost, discountSize ); }
5354
5455 private:
5556 int64_t modifySize;
5657 CAmount modifyFee;
5758 int64_t modifyCount;
5859 int64_t modifySigOpsCost;
60+ int64_t discountSize;
5961};
6062
6163struct update_fee_delta
@@ -103,6 +105,7 @@ CTxMemPoolEntry::CTxMemPoolEntry(const CTransactionRef& tx, CAmount fee,
103105 nSizeWithAncestors{GetTxSize ()},
104106 nModFeesWithAncestors{nFee},
105107 nSigOpCostWithAncestors{sigOpCost},
108+ discountSizeWithAncestors{GetDiscountTxSize ()},
106109 setPeginsSpent (_setPeginsSpent) {}
107110
108111void CTxMemPoolEntry::UpdateFeeDelta (int64_t newFeeDelta)
@@ -122,6 +125,11 @@ size_t CTxMemPoolEntry::GetTxSize() const
122125 return GetVirtualTransactionSize (nTxWeight, sigOpCost);
123126}
124127
128+ size_t CTxMemPoolEntry::GetDiscountTxSize () const
129+ {
130+ return GetDiscountVirtualTransactionSize (*tx, sigOpCost, ::nBytesPerSigOp);
131+ }
132+
125133void CTxMemPool::UpdateForDescendants (txiter updateIt, cacheMap& cachedDescendants,
126134 const std::set<uint256>& setExclude, std::set<uint256>& descendants_to_remove,
127135 uint64_t ancestor_size_limit, uint64_t ancestor_count_limit)
@@ -160,7 +168,7 @@ void CTxMemPool::UpdateForDescendants(txiter updateIt, cacheMap& cachedDescendan
160168 modifyCount++;
161169 cachedDescendants[updateIt].insert (mapTx.iterator_to (descendant));
162170 // 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 () ));
164172 // Don't directly remove the transaction here -- doing so would
165173 // invalidate iterators in cachedDescendants. Mark it for removal
166174 // by inserting into descendants_to_remove.
@@ -371,12 +379,14 @@ void CTxMemPool::UpdateEntryForAncestors(txiter it, const setEntries &setAncesto
371379 int64_t updateSize = 0 ;
372380 CAmount updateFee = 0 ;
373381 int64_t updateSigOpsCost = 0 ;
382+ int64_t discountSize = 0 ;
374383 for (txiter ancestorIt : setAncestors) {
375384 updateSize += ancestorIt->GetTxSize ();
376385 updateFee += ancestorIt->GetModifiedFee ();
377386 updateSigOpsCost += ancestorIt->GetSigOpCost ();
387+ discountSize += ancestorIt->GetDiscountTxSize ();
378388 }
379- mapTx.modify (it, update_ancestor_state (updateSize, updateFee, updateCount, updateSigOpsCost));
389+ mapTx.modify (it, update_ancestor_state (updateSize, updateFee, updateCount, updateSigOpsCost, discountSize ));
380390}
381391
382392void CTxMemPool::UpdateChildrenForRemoval (txiter it)
@@ -406,8 +416,9 @@ void CTxMemPool::UpdateForRemoveFromMempool(const setEntries &entriesToRemove, b
406416 int64_t modifySize = -((int64_t )removeIt->GetTxSize ());
407417 CAmount modifyFee = -removeIt->GetModifiedFee ();
408418 int modifySigOps = -removeIt->GetSigOpCost ();
419+ int64_t discountSize = -((int64_t )removeIt->GetDiscountTxSize ());
409420 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 ));
411422 }
412423 }
413424 }
@@ -456,7 +467,7 @@ void CTxMemPoolEntry::UpdateDescendantState(int64_t modifySize, CAmount modifyFe
456467 assert (int64_t (nCountWithDescendants) > 0 );
457468}
458469
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 )
460471{
461472 nSizeWithAncestors += modifySize;
462473 assert (int64_t (nSizeWithAncestors) > 0 );
@@ -465,6 +476,7 @@ void CTxMemPoolEntry::UpdateAncestorState(int64_t modifySize, CAmount modifyFee,
465476 assert (int64_t (nCountWithAncestors) > 0 );
466477 nSigOpCostWithAncestors += modifySigOps;
467478 assert (int (nSigOpCostWithAncestors) >= 0 );
479+ discountSizeWithAncestors += discountSize;
468480}
469481
470482CTxMemPool::CTxMemPool (CBlockPolicyEstimator* estimator, int check_ratio)
@@ -1030,7 +1042,7 @@ void CTxMemPool::PrioritiseTransaction(const uint256& hash, const CAmount& nFeeD
10301042 CalculateDescendants (it, setDescendants);
10311043 setDescendants.erase (it);
10321044 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 ));
10341046 }
10351047 ++nTransactionsUpdated;
10361048 }
0 commit comments