Addresses for outbound connections are largely chosen at random. The filtering of addresses comes at the time the addresses are first received by the node before they are added to the address database. This filter checks what services the nodes offer, what network they are on (e.g. IPv4, IPv6, TOR), and the time that they were reported to last be seen. Your node will choose to store addresses that are recent, use a network that your node is connected to, and offers full node services (NODE_NETWORK
and NODE_NETWORK_LIMITED
). We also avoid nodes that have been recently disconnected or banned.
These addresses are stored in buckets. These buckets are based on /16 for IPv4 and /32 for IPv6. In the future, these buckets will be determined by Autonomous System.
When making outbound connections, nodes are basically chosen at random. Your node will ensure that each outbound node belong to different buckets. If a node is chosen that belongs to a bucket that already has an outbound connection, it is skipped. We also try to choose nodes that we didn't already try to connect to recently unless we have built up a lot of failed connection attempts. Lastly, your node will try connect to nodes using the default port unless there have been a lot of failed connection attempts.
For nodes that you are specifically adding with addnode
, these nodes do not take up the standard outbound connection slots. There are an additional 8 addnode connection slots. If these are full, then the node that you are adding will simply wait until one of those nodes disconnects before a connection to it is attempted. So there is no kicking of outbound peers at all.