block-relay-only connections are additional outbound connections that bitcoind makes since v0.19. They participate in block relay, but do not propagate transactions or addresses. They were introduced in #15759.
When creating an outbound block-relay-only connection, since we know that we’re never going to announce transactions over that connection, we can save on memory usage by not a TxRelay
data structure for that connection. When receiving an inbound connection, we don’t know whether the connection was opened by the peer as block-relay-only or not, and therefore we always construct a TxRelay
data structure for inbound connections.
However, it is possible to tell whether an inbound connection will ever request that we start announcing transactions to it. The fRelay
field in the version
message may be set to 0
to indicate that the peer does not wish to receive transaction announcements. The peer may later request that we start announcing transactions to it by sending a filterload
or filterclear
message, but only if we have offered NODE_BLOOM
services to that peer. NODE_BLOOM
services are disabled by default, and it has been recommended for some time that users not enable NODE_BLOOM
services on public connections, for privacy and anti-DoS reasons.
Therefore, if we have not offered NODE_BLOOM
to the peer and it has set fRelay
to 0
, then we know that it will never request transaction announcements, and that we can save resources by not initializing the TxRelay
data structure.