Changeset View
Changeset View
Standalone View
Standalone View
src/net_processing.cpp
Show First 20 Lines • Show All 3,080 Lines • ▼ Show 20 Lines | if (msg_type == NetMsgType::INV) { | ||||
pfrom.AddKnownTx(txid); | pfrom.AddKnownTx(txid); | ||||
if (fBlocksOnly) { | if (fBlocksOnly) { | ||||
LogPrint(BCLog::NET, | LogPrint(BCLog::NET, | ||||
"transaction (%s) inv sent in violation of " | "transaction (%s) inv sent in violation of " | ||||
"protocol, disconnecting peer=%d\n", | "protocol, disconnecting peer=%d\n", | ||||
txid.ToString(), pfrom.GetId()); | txid.ToString(), pfrom.GetId()); | ||||
pfrom.fDisconnect = true; | pfrom.fDisconnect = true; | ||||
return; | return; | ||||
} else if (!fAlreadyHave && !fImporting && !fReindex && | } else if (!fAlreadyHave && !m_chainman.ActiveChainstate() | ||||
!::ChainstateActive().IsInitialBlockDownload()) { | .IsInitialBlockDownload()) { | ||||
RequestTx(State(pfrom.GetId()), txid, current_time); | RequestTx(State(pfrom.GetId()), txid, current_time); | ||||
} | } | ||||
} | } | ||||
} | } | ||||
if (best_block) { | if (best_block) { | ||||
m_connman.PushMessage( | m_connman.PushMessage( | ||||
&pfrom, | &pfrom, | ||||
▲ Show 20 Lines • Show All 2,420 Lines • ▼ Show 20 Lines | if (pingSend) { | ||||
!pto->HasPermission(PF_FORCERELAY)) { | !pto->HasPermission(PF_FORCERELAY)) { | ||||
Amount currentFilter = | Amount currentFilter = | ||||
m_mempool | m_mempool | ||||
.GetMinFee( | .GetMinFee( | ||||
gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * | ||||
1000000) | 1000000) | ||||
.GetFeePerK(); | .GetFeePerK(); | ||||
int64_t timeNow = GetTimeMicros(); | int64_t timeNow = GetTimeMicros(); | ||||
static FeeFilterRounder g_filter_rounder{ | |||||
CFeeRate{DEFAULT_MIN_RELAY_TX_FEE_PER_KB}}; | |||||
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 Amount 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) { | if (timeNow > pto->m_tx_relay->nextSendTimeFeeFilter) { | ||||
static CFeeRate default_feerate = | Amount filterToSend = g_filter_rounder.round(currentFilter); | ||||
CFeeRate(DEFAULT_MIN_RELAY_TX_FEE_PER_KB); | |||||
static FeeFilterRounder filterRounder(default_feerate); | |||||
Amount filterToSend = filterRounder.round(currentFilter); | |||||
filterToSend = | filterToSend = | ||||
std::max(filterToSend, ::minRelayTxFee.GetFeePerK()); | std::max(filterToSend, ::minRelayTxFee.GetFeePerK()); | ||||
if (filterToSend != pto->m_tx_relay->lastSentFeeFilter) { | if (filterToSend != pto->m_tx_relay->lastSentFeeFilter) { | ||||
m_connman.PushMessage( | m_connman.PushMessage( | ||||
pto, | pto, | ||||
msgMaker.Make(NetMsgType::FEEFILTER, filterToSend)); | msgMaker.Make(NetMsgType::FEEFILTER, filterToSend)); | ||||
pto->m_tx_relay->lastSentFeeFilter = filterToSend; | pto->m_tx_relay->lastSentFeeFilter = filterToSend; | ||||
Show All 31 Lines |