As described in the issues #16418 and #28371, it’s a possibility that we could end up having an insufficient number of outbound peers relaying our transactions. Having fewer outbound peers support tx-relay could also have implications on privacy and fee estimation.
While #28488 is suggesting meaures based on comparing fee filters / mempool sizes, there is also the simpler issue of peers that tell us they don’t want transactions, which is determined by the fRelay
field in the version
msg. If such a peer runs bitcoin core, that usually means that it’s running in -blocksonly
mode and accepting inbound connections. The status quo is that we will not avoid these peers and just not send them any transactions.
This PR proposes not to waste any of our 8 full-relay outbound slots on these peers (unless we are in -blocksonly
mode ourselves). Using them as outbound peers for block-relay-only connections is fine though and not impacted.
As was suggested by ajtowns below, we don’t disconnect during version processing, but later during the regularly scheduled EvictExtraOutboundPeers()
task, and only if we are at the maximum of full-outbound peers.
If reviewers think that this proposal is too aggressive, an alternative solution (with a little more complexity) would be to restrict the maximum number of outbound connections to -blocksonly
peers to 1 or 2. Although I currently think that it’s ok to be selective with outbound connections, so I didn’t implement that right away.