Peer Discovery – How long on average would it take to discover and connect to all other nodes in the Bitcoin network? Are there any technical barriers to this?

discover all other nodes in the Bitcoin network and connect to them

Discovery and connection are a little different. To discover a node, this node must have announced itself using a addr a message. I think nodes that don’t accept incoming connections (don’t have a listening port) don’t, so they can’t be discovered unless your node listens for incoming connections and you they initiate the connection.

Connecting to known nodes is straightforward and that’s what statistical tools like binary nodes do, I guess that’s what you have in mind, if not as @RedGrittyBrick it’s no use.

This can start from the initial discovery of peers using DNS seeders, and then it involves establishing a TCP connection to each node’s IP address through the port they are listening on (almost always values by default 8333 and 18333 for mainnet and testnet) and perform the handshake (version+verack) which does not take more than a second. A getaddr A message could be sent to each node requesting a list of nodes they know to build a list and connect to each of them.
I don’t think I’ll go through it all accessible nodes (about 10k) would take over a minute.

Source link