Skip to content

Commit 36fceda

Browse files
committed
feefilter: Compute the absolute fee rather than stored rate to match mempool acceptance logic
1 parent 073cb3c commit 36fceda

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
@@ -3694,10 +3694,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
36943694
if (fSendTrickle && pto->fSendMempool) {
36953695
auto vtxinfo = mempool.infoAll();
36963696
pto->fSendMempool = false;
3697-
CAmount filterrate = 0;
3697+
CFeeRate filterrate;
36983698
{
36993699
LOCK(pto->cs_feeFilter);
3700-
filterrate = pto->minFeeFilter;
3700+
filterrate = CFeeRate(pto->minFeeFilter);
37013701
}
37023702

37033703
LOCK(pto->cs_filter);
@@ -3706,9 +3706,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
37063706
const uint256& hash = txinfo.tx->GetHash();
37073707
CInv inv(MSG_TX, hash);
37083708
pto->setInventoryTxToSend.erase(hash);
3709-
if (filterrate) {
3710-
if (txinfo.feeRate.GetFeePerK() < filterrate)
3711-
continue;
3709+
// Don't send transactions that peers will not put into their mempool
3710+
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {
3711+
continue;
37123712
}
37133713
if (pto->pfilter) {
37143714
if (!pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;
@@ -3731,10 +3731,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
37313731
for (std::set<uint256>::iterator it = pto->setInventoryTxToSend.begin(); it != pto->setInventoryTxToSend.end(); it++) {
37323732
vInvTx.push_back(it);
37333733
}
3734-
CAmount filterrate = 0;
3734+
CFeeRate filterrate;
37353735
{
37363736
LOCK(pto->cs_feeFilter);
3737-
filterrate = pto->minFeeFilter;
3737+
filterrate = CFeeRate(pto->minFeeFilter);
37383738
}
37393739
// Topologically and fee-rate sort the inventory we send for privacy and priority reasons.
37403740
// A heap is used so that not all items need sorting if only a few are being sent.
@@ -3761,7 +3761,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
37613761
if (!txinfo.tx) {
37623762
continue;
37633763
}
3764-
if (filterrate && txinfo.feeRate.GetFeePerK() < filterrate) {
3764+
// Peer told you to not send transactions at that feerate? Don't bother sending it.
3765+
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {
37653766
continue;
37663767
}
37673768
if (pto->pfilter && !pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;

src/txmempool.cpp

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

857857
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) {
858-
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->GetFee()};
858+
return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()};
859859
}
860860

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

src/txmempool.h

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,11 @@ struct TxMempoolInfo
338338
/** Time the transaction entered the mempool. */
339339
int64_t nTime;
340340

341-
/** Feerate of the transaction. */
342-
CFeeRate feeRate;
341+
/** Fee of the transaction. */
342+
CAmount fee;
343+
344+
/** Virtual size of the transaction. */
345+
size_t vsize;
343346

344347
/** The fee delta. */
345348
int64_t nFeeDelta;

0 commit comments

Comments
 (0)