Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 4,639 Lines • ▼ Show 20 Lines | std::vector<CInv> vInv; | ||||
pto->m_tx_relay->setInventoryTxToSend.clear(); | pto->m_tx_relay->setInventoryTxToSend.clear(); | ||||
} | } | ||||
} | } | ||||
// Respond to BIP35 mempool requests | // Respond to BIP35 mempool requests | ||||
if (fSendTrickle && pto->m_tx_relay->fSendMempool) { | if (fSendTrickle && pto->m_tx_relay->fSendMempool) { | ||||
auto vtxinfo = g_mempool.infoAll(); | auto vtxinfo = g_mempool.infoAll(); | ||||
pto->m_tx_relay->fSendMempool = false; | pto->m_tx_relay->fSendMempool = false; | ||||
Amount filterrate = Amount::zero(); | 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); | ||||
for (const auto &txinfo : vtxinfo) { | for (const auto &txinfo : vtxinfo) { | ||||
const TxId &txid = txinfo.tx->GetId(); | const TxId &txid = txinfo.tx->GetId(); | ||||
CInv inv(MSG_TX, txid); | CInv inv(MSG_TX, txid); | ||||
pto->m_tx_relay->setInventoryTxToSend.erase(txid); | pto->m_tx_relay->setInventoryTxToSend.erase(txid); | ||||
if (filterrate != Amount::zero() && | // Don't send transactions that peers will not put into | ||||
txinfo.feeRate.GetFeePerK() < filterrate) { | // their mempool | ||||
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) { | |||||
continue; | continue; | ||||
} | } | ||||
if (pto->m_tx_relay->pfilter && | if (pto->m_tx_relay->pfilter && | ||||
!pto->m_tx_relay->pfilter->IsRelevantAndUpdate( | !pto->m_tx_relay->pfilter->IsRelevantAndUpdate( | ||||
*txinfo.tx)) { | *txinfo.tx)) { | ||||
continue; | continue; | ||||
} | } | ||||
pto->m_tx_relay->filterInventoryKnown.insert(txid); | pto->m_tx_relay->filterInventoryKnown.insert(txid); | ||||
Show All 13 Lines | std::vector<CInv> vInv; | ||||
// Produce a vector with all candidates for sending | // Produce a vector with all candidates for sending | ||||
std::vector<std::set<TxId>::iterator> vInvTx; | std::vector<std::set<TxId>::iterator> vInvTx; | ||||
vInvTx.reserve(pto->m_tx_relay->setInventoryTxToSend.size()); | vInvTx.reserve(pto->m_tx_relay->setInventoryTxToSend.size()); | ||||
for (std::set<TxId>::iterator it = | for (std::set<TxId>::iterator it = | ||||
pto->m_tx_relay->setInventoryTxToSend.begin(); | pto->m_tx_relay->setInventoryTxToSend.begin(); | ||||
it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) { | it != pto->m_tx_relay->setInventoryTxToSend.end(); it++) { | ||||
vInvTx.push_back(it); | vInvTx.push_back(it); | ||||
} | } | ||||
Amount filterrate = Amount::zero(); | 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 | // Topologically and fee-rate sort the inventory we send for | ||||
// privacy and priority reasons. A heap is used so that not all | // privacy and priority reasons. A heap is used so that not all | ||||
// items need sorting if only a few are being sent. | // items need sorting if only a few are being sent. | ||||
CompareInvMempoolOrder compareInvMempoolOrder(&g_mempool); | CompareInvMempoolOrder compareInvMempoolOrder(&g_mempool); | ||||
std::make_heap(vInvTx.begin(), vInvTx.end(), | std::make_heap(vInvTx.begin(), vInvTx.end(), | ||||
compareInvMempoolOrder); | compareInvMempoolOrder); | ||||
// No reason to drain out at many times the network's capacity, | // No reason to drain out at many times the network's capacity, | ||||
Show All 17 Lines | std::vector<CInv> vInv; | ||||
if (pto->m_tx_relay->filterInventoryKnown.contains(txid)) { | if (pto->m_tx_relay->filterInventoryKnown.contains(txid)) { | ||||
continue; | continue; | ||||
} | } | ||||
// Not in the mempool anymore? don't bother sending it. | // Not in the mempool anymore? don't bother sending it. | ||||
auto txinfo = g_mempool.info(txid); | auto txinfo = g_mempool.info(txid); | ||||
if (!txinfo.tx) { | if (!txinfo.tx) { | ||||
continue; | continue; | ||||
} | } | ||||
if (filterrate != Amount::zero() && | // Peer told you to not send transactions at that feerate? | ||||
txinfo.feeRate.GetFeePerK() < filterrate) { | // Don't bother sending it. | ||||
if (txinfo.fee < filterrate.GetFee(txinfo.vsize)) { | |||||
continue; | continue; | ||||
} | } | ||||
if (pto->m_tx_relay->pfilter && | if (pto->m_tx_relay->pfilter && | ||||
!pto->m_tx_relay->pfilter->IsRelevantAndUpdate( | !pto->m_tx_relay->pfilter->IsRelevantAndUpdate( | ||||
*txinfo.tx)) { | *txinfo.tx)) { | ||||
continue; | continue; | ||||
} | } | ||||
// Send | // Send | ||||
▲ Show 20 Lines • Show All 274 Lines • Show Last 20 Lines |