mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Merge #21509: p2p: Don't send FEEFILTER in blocksonly mode.
beead33a21
[test] no send feefilters when txrelay is turned off (glozow)18a9b27dd6
p2p: Don't send FEEFILTER in blocksonly mode (Martin Zumsande) Pull request description: The purpose of FEEFILTER messages (BIP 133) is to inform our peers that we do not want transactions below a specified fee rate. In blocksonly mode, we do not want our peer to send us any transactions at all (and will disconnect if a peer still sends a transaction INV or TX). Therefore, I don't think that it makes sense to send FEEFILTER messages every 10 minutes on average in blocksonly mode - this PR disables it. Note that on block-relay-only connections, FEEFILTER is already disabled, just not in blocksonly mode. ACKs for top commit: glozow: re ACKbeead33a21
🙂 thanks for adding the test! amitiuttarwar: reACKbeead33a21
MarcoFalke: review ACKbeead33a21
jnewbery: reACKbeead33a21
Tree-SHA512: e748cd52fe23d647fa49008b020389956ac508e16ce9fd108d8afb773bff95788298ae229162bd70215d7246fc25c796484966dc05890b0b4ef601f9cd35628b
This commit is contained in:
commit
4399dc8142
2 changed files with 18 additions and 1 deletions
|
@ -4689,7 +4689,10 @@ bool PeerManagerImpl::SendMessages(CNode* pto)
|
|||
//
|
||||
// Message: feefilter
|
||||
//
|
||||
if (pto->m_tx_relay != nullptr && pto->GetCommonVersion() >= FEEFILTER_VERSION && gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
|
||||
if (pto->m_tx_relay != nullptr &&
|
||||
!m_ignore_incoming_txs &&
|
||||
pto->GetCommonVersion() >= FEEFILTER_VERSION &&
|
||||
gArgs.GetBoolArg("-feefilter", DEFAULT_FEEFILTER) &&
|
||||
!pto->HasPermission(PF_FORCERELAY) // peers with the forcerelay permission should not filter txs to us
|
||||
) {
|
||||
CAmount currentFilter = m_mempool.GetMinFee(gArgs.GetArg("-maxmempool", DEFAULT_MAX_MEMPOOL_SIZE) * 1000000).GetFeePerK();
|
||||
|
|
|
@ -61,6 +61,7 @@ class FeeFilterTest(BitcoinTestFramework):
|
|||
def run_test(self):
|
||||
self.test_feefilter_forcerelay()
|
||||
self.test_feefilter()
|
||||
self.test_feefilter_blocksonly()
|
||||
|
||||
def test_feefilter_forcerelay(self):
|
||||
self.log.info('Check that peers without forcerelay permission (default) get a feefilter message')
|
||||
|
@ -119,6 +120,19 @@ class FeeFilterTest(BitcoinTestFramework):
|
|||
conn.wait_for_invs_to_match(txids)
|
||||
conn.clear_invs()
|
||||
|
||||
def test_feefilter_blocksonly(self):
|
||||
"""Test that we don't send fee filters to block-relay-only peers and when we're in blocksonly mode."""
|
||||
self.log.info("Check that we don't send fee filters to block-relay-only peers.")
|
||||
feefilter_peer = self.nodes[0].add_outbound_p2p_connection(FeefilterConn(), p2p_idx=0, connection_type="block-relay-only")
|
||||
feefilter_peer.sync_with_ping()
|
||||
feefilter_peer.assert_feefilter_received(False)
|
||||
|
||||
self.log.info("Check that we don't send fee filters when in blocksonly mode.")
|
||||
self.restart_node(0, ["-blocksonly"])
|
||||
feefilter_peer = self.nodes[0].add_p2p_connection(FeefilterConn())
|
||||
feefilter_peer.sync_with_ping()
|
||||
feefilter_peer.assert_feefilter_received(False)
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
FeeFilterTest().main()
|
||||
|
|
Loading…
Reference in a new issue