mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-09-12 05:32:22 +02:00
p2p: Don't participate in addr relay with feeler connections
Feeler connections are short-lived connections made to check that a node is alive, useful for test-before-evict from addrman, and for moving addresses from the new to the tried table. We currently send a GETADDR message to feelers, but then disconnect before being able to receive a response. This wastes some bandwidth, so we can avoid sending the GETADDR altogether. Not sending the initial GETADDR will effectively disable addr relay: we initialize addr relay for the peer when we send GETADDR, and the peer initializes addr relay to us when they receive it. So the peer will not relay any announcement to us, and we will not relay any to them either. This is ok, since the use of feelers is to test if there is a bitcoin node behind an address, not exchange addresses with them.
This commit is contained in:
@@ -280,12 +280,17 @@ class AddrTest(BitcoinTestFramework):
|
||||
tip_header = from_hex(CBlockHeader(), self.nodes[0].getblockheader(self.nodes[0].getbestblockhash(), False))
|
||||
full_outbound_peer.send_and_ping(msg_headers([tip_header]))
|
||||
|
||||
self.log.info('Check that we do not send a getaddr message to a block-relay-only or inbound peer')
|
||||
self.log.info('Check that we do not send a getaddr message to a block-relay-only, feeler or inbound peer')
|
||||
block_relay_peer = self.nodes[0].add_outbound_p2p_connection(AddrReceiver(), p2p_idx=1, connection_type="block-relay-only")
|
||||
block_relay_peer.sync_with_ping()
|
||||
assert_equal(block_relay_peer.getaddr_received(), False)
|
||||
block_relay_peer.send_and_ping(msg_headers([tip_header]))
|
||||
|
||||
feeler_peer = self.nodes[0].add_outbound_p2p_connection(AddrReceiver(), p2p_idx=2, connection_type="feeler")
|
||||
# bitcoind closes feeler connections as soon as it receives a version message
|
||||
assert_equal(feeler_peer.is_connected, False)
|
||||
assert_equal(feeler_peer.getaddr_received(), False)
|
||||
|
||||
inbound_peer = self.nodes[0].add_p2p_connection(AddrReceiver(send_getaddr=False))
|
||||
inbound_peer.sync_with_ping()
|
||||
assert_equal(inbound_peer.getaddr_received(), False)
|
||||
|
||||
Reference in New Issue
Block a user