0
0
Fork 0
mirror of https://github.com/bitcoin/bitcoin.git synced 2025-03-06 14:19:59 -05:00

feefilter: Compute the absolute fee rather than stored rate to match mempool acceptance logic

This commit is contained in:
Gregory Sanders 2019-07-31 13:21:00 -04:00
parent a689c11907
commit 8e59af55aa
3 changed files with 15 additions and 11 deletions

View file

@ -3847,10 +3847,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
if (fSendTrickle && pto->m_tx_relay->fSendMempool) { if (fSendTrickle && pto->m_tx_relay->fSendMempool) {
auto vtxinfo = mempool.infoAll(); auto vtxinfo = mempool.infoAll();
pto->m_tx_relay->fSendMempool = false; pto->m_tx_relay->fSendMempool = false;
CAmount filterrate = 0; CFeeRate filterrate;
{ {
LOCK(pto->m_tx_relay->cs_feeFilter); LOCK(pto->m_tx_relay->cs_feeFilter);
filterrate = pto->m_tx_relay->minFeeFilter; filterrate = CFeeRate(pto->m_tx_relay->minFeeFilter);
} }
LOCK(pto->m_tx_relay->cs_filter); LOCK(pto->m_tx_relay->cs_filter);
@ -3859,8 +3859,8 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
const uint256& hash = txinfo.tx->GetHash(); const uint256& hash = txinfo.tx->GetHash();
CInv inv(MSG_TX, hash); CInv inv(MSG_TX, hash);
pto->m_tx_relay->setInventoryTxToSend.erase(hash); pto->m_tx_relay->setInventoryTxToSend.erase(hash);
if (filterrate) { // Don't send transactions that peers will not put into their mempool
if (txinfo.feeRate.GetFeePerK() < filterrate) if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) {
continue; continue;
} }
if (pto->m_tx_relay->pfilter) { if (pto->m_tx_relay->pfilter) {
@ -3884,10 +3884,10 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
for (std::set<uint256>::iterator it = pto->m_tx_relay->setInventoryTxToSend.begin(); it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) { for (std::set<uint256>::iterator it = pto->m_tx_relay->setInventoryTxToSend.begin(); it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) {
vInvTx.push_back(it); vInvTx.push_back(it);
} }
CAmount filterrate = 0; CFeeRate filterrate;
{ {
LOCK(pto->m_tx_relay->cs_feeFilter); LOCK(pto->m_tx_relay->cs_feeFilter);
filterrate = pto->m_tx_relay->minFeeFilter; filterrate = CFeeRate(pto->m_tx_relay->minFeeFilter);
} }
// Topologically and fee-rate sort the inventory we send for privacy and priority reasons. // 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. // 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)
if (!txinfo.tx) { if (!txinfo.tx) {
continue; 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; continue;
} }
if (pto->m_tx_relay->pfilter && !pto->m_tx_relay->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue; if (pto->m_tx_relay->pfilter && !pto->m_tx_relay->pfilter->IsRelevantAndUpdate(*txinfo.tx)) continue;

View file

@ -773,7 +773,7 @@ void CTxMemPool::queryHashes(std::vector<uint256>& vtxid) const
} }
static TxMempoolInfo GetInfo(CTxMemPool::indexed_transaction_set::const_iterator it) { 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<TxMempoolInfo> CTxMemPool::infoAll() const std::vector<TxMempoolInfo> CTxMemPool::infoAll() const

View file

@ -334,8 +334,11 @@ struct TxMempoolInfo
/** Time the transaction entered the mempool. */ /** Time the transaction entered the mempool. */
std::chrono::seconds m_time; std::chrono::seconds m_time;
/** Feerate of the transaction. */ /** Fee of the transaction. */
CFeeRate feeRate; CAmount fee;
/** Virtual size of the transaction. */
size_t vsize;
/** The fee delta. */ /** The fee delta. */
int64_t nFeeDelta; int64_t nFeeDelta;