Skip to content

Commit

Permalink
[fees]: ignore all transaction with in block child
Browse files Browse the repository at this point in the history
  • Loading branch information
ismaelsadeeq committed May 14, 2024
1 parent 99d7538 commit a6e8133
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/policy/fees.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,22 @@ bool CBlockPolicyEstimator::processBlockTx(unsigned int nBlockHeight, const Remo
return true;
}

void CBlockPolicyEstimator::removeParentTxs(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block)
{
std::set<Txid> seen_transactions;
for (const auto& tx : txs_removed_for_block) {
seen_transactions.insert(tx.info.m_tx->GetHash());
for (const auto& input : tx.info.m_tx->vin) {
const Txid& parentId = input.prevout.hash;
if (seen_transactions.count(parentId)) {
// Ignore any transaction with a child in the received block
// It may be fee bumped by the child.
_removeTx(parentId, /*inblock=*/true);
seen_transactions.erase(parentId);
}
}
}
}
void CBlockPolicyEstimator::processBlock(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block,
unsigned int nBlockHeight)
{
Expand Down Expand Up @@ -690,6 +706,8 @@ void CBlockPolicyEstimator::processBlock(const std::vector<RemovedMempoolTransac
shortStats->UpdateMovingAverages();
longStats->UpdateMovingAverages();

removeParentTxs(txs_removed_for_block);

unsigned int countedTxs = 0;
// Update averages with data points from current block
for (const auto& tx : txs_removed_for_block) {
Expand Down
3 changes: 3 additions & 0 deletions src/policy/fees.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,9 @@ class CBlockPolicyEstimator : public CValidationInterface
/** Process a transaction confirmed in a block*/
bool processBlockTx(unsigned int nBlockHeight, const RemovedMempoolTransactionInfo& tx) EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);

/* Remove transactions with child from fee estimation tracking stats */
void removeParentTxs(const std::vector<RemovedMempoolTransactionInfo>& txs_removed_for_block) EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);

/** Helper for estimateSmartFee */
double estimateCombinedFee(unsigned int confTarget, double successThreshold, bool checkShorterHorizon, EstimationResult *result) const EXCLUSIVE_LOCKS_REQUIRED(m_cs_fee_estimator);
/** Helper for estimateSmartFee */
Expand Down

0 comments on commit a6e8133

Please sign in to comment.