Skip to content

Commit a6e8133

Browse files
committed
[fees]: ignore all transaction with in block child
1 parent 99d7538 commit a6e8133

File tree

2 files changed

+21
-0
lines changed

2 files changed

+21
-0
lines changed

src/policy/fees.cpp

+18
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,22 @@ bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const Remo
662662
return true;
663663
}
664664

665+
void CBlockPolicyEstimator::removeParentTxs(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block)
666+
{
667+
std::set<Txid> seen_transactions;
668+
for (const auto& tx : txs_removed_for_block) {
669+
seen_transactions.insert(tx.info.m_tx->GetHash());
670+
for (const auto& input : tx.info.m_tx->vin) {
671+
const Txid& parentId = input.prevout.hash;
672+
if (seen_transactions.count(parentId)) {
673+
// Ignore any transaction with a child in the received block
674+
// It may be fee bumped by the child.
675+
_removeTx(parentId, /*inblock=*/true);
676+
seen_transactions.erase(parentId);
677+
}
678+
}
679+
}
680+
}
665681
void CBlockPolicyEstimator::processBlock(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block,
666682
unsigned int nBlockHeight)
667683
{
@@ -690,6 +706,8 @@ void CBlockPolicyEstimator::processBlock(const std::vector<RemovedMempoolTransac
690706
shortStats->UpdateMovingAverages();
691707
longStats->UpdateMovingAverages();
692708

709+
removeParentTxs(txs_removed_for_block);
710+
693711
unsigned int countedTxs = 0;
694712
// Update averages with data points from current block
695713
for (const auto& tx : txs_removed_for_block) {

src/policy/fees.h

+3
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,9 @@ class CBlockPolicyEstimator : public CValidationInterface
303303
/** Process a transaction confirmed in a block*/
304304
bool processBlockTx(unsigned int nBlockHeight, const RemovedMempoolTransactionInfo& tx) EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
305305

306+
/* Remove transactions with child from fee estimation tracking stats */
307+
void removeParentTxs(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block) EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
308+
306309
/** Helper for estimateSmartFee */
307310
double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
308311
/** Helper for estimateSmartFee */

0 commit comments

Comments
 (0)