mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-03-05 14:06:27 -05:00
net: Avoid wasting inv traffic during IBD
This commit is contained in:
parent
fa06d7e934
commit
fa525e4d1c
2 changed files with 17 additions and 4 deletions
|
@ -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) {
|
||||
|
|
|
@ -46,10 +46,12 @@ class NetTest(BitcoinTestFramework):
|
|||
def set_test_params(self):
|
||||
self.setup_clean_chain = True
|
||||
self.num_nodes = 2
|
||||
self.extra_args = [["-minrelaytxfee=0.00001000"],["-minrelaytxfee=0.00000500"]]
|
||||
self.extra_args = [["-minrelaytxfee=0.00001000"], ["-minrelaytxfee=0.00000500"]]
|
||||
self.supports_cli = False
|
||||
|
||||
def run_test(self):
|
||||
self.log.info('Get out of IBD for the minfeefilter test')
|
||||
self.nodes[0].generate(1)
|
||||
self.log.info('Connect nodes both way')
|
||||
connect_nodes(self.nodes[0], 1)
|
||||
connect_nodes(self.nodes[1], 0)
|
||||
|
|
Loading…
Add table
Reference in a new issue