diff --git a/src/net_processing.cpp b/src/net_processing.cpp index ab30104c47..1123d66638 100644 --- a/src/net_processing.cpp +++ b/src/net_processing.cpp @@ -3578,10 +3578,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto) if (fSendTrickle && pto->fSendMempool) { auto vtxinfo = mempool.infoAll(); pto->fSendMempool = false; - CAmount filterrate = 0; + CFeeRate filterrate; { LOCK(pto->cs_feeFilter); - filterrate = pto->minFeeFilter; + filterrate = CFeeRate(pto->minFeeFilter); } LOCK(pto->cs_filter); @@ -3590,9 +3590,9 @@ bool PeerLogicValidation::SendMessages(CNode* pto) const uint256& hash = txinfo.tx->GetHash(); CInv inv(MSG_TX, hash); pto->setInventoryTxToSend.erase(hash); - if (filterrate) { - if (txinfo.feeRate.GetFeePerK() < filterrate) - continue; + // Don't send transactions that peers will not put into their mempool + if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) { + continue; } if (pto->pfilter) { if (!pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; @@ -3615,10 +3615,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto) for (std::set::iterator it = pto->setInventoryTxToSend.begin(); it != pto->setInventoryTxToSend.end(); it++) { vInvTx.push_back(it); } - CAmount filterrate = 0; + CFeeRate filterrate; { LOCK(pto->cs_feeFilter); - filterrate = pto->minFeeFilter; + filterrate = CFeeRate(pto->minFeeFilter); } // Topologically and fee-rate sort the inventory we send for privacy and priority reasons. // A heap is used so that not all items need sorting if only a few are being sent. @@ -3645,7 +3645,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto) if (!txinfo.tx) { continue; } - if (filterrate && txinfo.feeRate.GetFeePerK() < filterrate) { + // Peer told you to not send transactions at that feerate? Don't bother sending it. + if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) { continue; } if (pto->pfilter && !pto->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; diff --git a/src/txmempool.cpp b/src/txmempool.cpp index 933e471eb7..93688ffd8d 100644 --- a/src/txmempool.cpp +++ b/src/txmempool.cpp @@ -855,7 +855,7 @@ void CTxMemPool::queryHashes(std::vector& vtxid) } static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) { - return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), CFeeRate(it->GetFee(), it->GetTxSize()), it->GetModifiedFee() - it->GetFee()}; + return TxMempoolInfo{it->GetSharedTx(), it->GetTime(), it->GetFee(), it->GetTxSize(), it->GetModifiedFee() - it->GetFee()}; } std::vector CTxMemPool::infoAll() const diff --git a/src/txmempool.h b/src/txmempool.h index 7088c482b8..c5341be381 100644 --- a/src/txmempool.h +++ b/src/txmempool.h @@ -338,8 +338,11 @@ struct TxMempoolInfo /** Time the transaction entered the mempool. */ int64_t nTime; - /** Feerate of the transaction. */ - CFeeRate feeRate; + /** Fee of the transaction. */ + CAmount fee; + + /** Virtual size of the transaction. */ + size_t vsize; /** The fee delta. */ int64_t nFeeDelta;