aboutsummaryrefslogtreecommitdiff
path: root/src/net_processing.cpp
diff options
context:
space:
mode:
authorMarcoFalke <falke.marco@gmail.com>2020-06-07 12:41:10 -0400
committerMarcoFalke <falke.marco@gmail.com>2020-06-19 09:27:30 -0400
commitfa525e4d1cfda8c1924d2c69f43bd7ae3b98fb72 (patch)
tree598164e99a59eb52e640b22e438695cc94a67e31 /src/net_processing.cpp
parentfa06d7e93489e61078cfb95ab767c001536a6e10 (diff)
downloadbitcoin-fa525e4d1cfda8c1924d2c69f43bd7ae3b98fb72.tar.xz
net: Avoid wasting inv traffic during IBD
Diffstat (limited to 'src/net_processing.cpp')
-rw-r--r--src/net_processing.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/src/net_processing.cpp b/src/net_processing.cpp
index 4fb4e1c120..02ad41ab00 100644
--- a/src/net_processing.cpp
+++ b/src/net_processing.cpp
@@ -4392,10 +4392,21 @@ bool PeerLogicValidation::SendMessages(CNode* pto)
!pto->HasPermission(PF_FORCERELAY)) {
CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
int64_t timeNow = GetTimeMicros();
+ static FeeFilterRounder g_filter_rounder{CFeeRate{DEFAULT_MIN_RELAY_TX_FEE}};
+ if (m_chainman.ActiveChainstate().IsInitialBlockDownload()) {
+ // Received tx-inv messages are discarded when the active
+ // chainstate is in IBD, so tell the peer to not send them.
+ currentFilter = MAX_MONEY;
+ } else {
+ static const CAmount MAX_FILTER{g_filter_rounder.round(MAX_MONEY)};
+ if (pto->m_tx_relay->lastSentFeeFilter == MAX_FILTER) {
+ // Send the current filter if we sent MAX_FILTER previously
+ // and made it out of IBD.
+ pto->m_tx_relay->nextSendTimeFeeFilter = timeNow - 1;
+ }
+ }
if (timeNow > pto->m_tx_relay->nextSendTimeFeeFilter) {
- static CFeeRate default_feerate(DEFAULT_MIN_RELAY_TX_FEE);
- static FeeFilterRounder filterRounder(default_feerate);
- CAmount filterToSend = filterRounder.round(currentFilter);
+ CAmount filterToSend = g_filter_rounder.round(currentFilter);
// We always have a fee filter of at least minRelayTxFee
filterToSend = std::max(filterToSend, ::minRelayTxFee.GetFeePerK());
if (filterToSend != pto->m_tx_relay->lastSentFeeFilter) {