Skip to content

Commit 8e59af5

Browse files
committed
feefilter: Compute the absolute fee rather than stored rate to match mempool acceptance logic
1 parent a689c11 commit 8e59af5

File tree

3 files changed

+15
-11
lines changed

3 files changed

+15
-11
lines changed

src/net_processing.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3847,10 +3847,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
38473847
if (fSendTrickle && pto->m_tx_relay->fSendMempool) {
38483848
auto vtxinfo = mempool.infoAll();
38493849
pto->m_tx_relay->fSendMempool = false;
3850-
CAmount filterrate = 0;
3850+
CFeeRate filterrate;
38513851
{
38523852
LOCK(pto->m_tx_relay->cs_feeFilter);
3853-
filterrate = pto->m_tx_relay->minFeeFilter;
3853+
filterrate = CFeeRate(pto->m_tx_relay->minFeeFilter);
38543854
}
38553855

38563856
LOCK(pto->m_tx_relay->cs_filter);
@@ -3859,9 +3859,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
38593859
const uint256& hash = txinfo.tx->GetHash();
38603860
CInv inv(MSG_TX, hash);
38613861
pto->m_tx_relay->setInventoryTxToSend.erase(hash);
3862-
if (filterrate) {
3863-
if (txinfo.feeRate.GetFeePerK() < filterrate)
3864-
continue;
3862+
// Don't send transactions that peers will not put into their mempool
3863+
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {
3864+
continue;
38653865
}
38663866
if (pto->m_tx_relay->pfilter) {
38673867
if (!pto->m_tx_relay->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;
@@ -3884,10 +3884,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
38843884
for (std::set<uint256>::iterator it = pto->m_tx_relay->setInventoryTxToSend.begin(); it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
38853885
vInvTx.push_back(it);
38863886
}
3887-
CAmount filterrate = 0;
3887+
CFeeRate filterrate;
38883888
{
38893889
LOCK(pto->m_tx_relay->cs_feeFilter);
3890-
filterrate = pto->m_tx_relay->minFeeFilter;
3890+
filterrate = CFeeRate(pto->m_tx_relay->minFeeFilter);
38913891
}
38923892
// Topologically and fee-rate sort the inventory we send for privacy and priority reasons.
38933893
// A heap is used so that not all items need sorting if only a few are being sent.
@@ -3914,7 +3914,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
39143914
if (!txinfo.tx) {
39153915
continue;
39163916
}
3917-
if (filterrate && txinfo.feeRate.GetFeePerK() < filterrate) {
3917+
// Peer told you to not send transactions at that feerate? Don't bother sending it.
3918+
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {
39183919
continue;
39193920
}
39203921
if (pto->m_tx_relay->pfilter && !pto->m_tx_relay->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,7 @@ void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
773773
}
774774

775775
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
776-
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->GetFee()};
776+
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
777777
}
778778

779779
std::vector<TxMempoolInfo> CTxMemPool::infoAll() const

src/txmempool.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,11 @@ struct TxMempoolInfo
334334
/** Time the transaction entered the mempool. */
335335
std::chrono::seconds m_time;
336336

337-
/** Feerate of the transaction. */
338-
CFeeRate feeRate;
337+
/** Fee of the transaction. */
338+
CAmount fee;
339+
340+
/** Virtual size of the transaction. */
341+
size_t vsize;
339342

340343
/** The fee delta. */
341344
int64_t nFeeDelta;

0 commit comments

Comments
 (0)