<blockquote>
<p><strong>how long on average would it take for a node to discover all other nodes</strong></p>
</blockquote>
<p>No normal node ever does this.</p>
<p>A normal node only connects directly with a very small number of other nodes (e.g. max 8 outbound, max 125 inbound) and relies on those other nodes to pass on information to the small number of nodes they are in contact with. This way information diffuses across the entire network.</p>
<p>Since nodes are continually appearing and disappearing any attempt to contact all nodes would be essentially endless or both incomplete and incorrect (it would include nodes that have been removed since the start of the discovery process)</p>

CC BY-SA 4.0
2020-10-08T09:57:37.560Z
2020-10-08T10:03:46.383Z
2020-10-08T10:03:46.383Z
RedGrittyBrick
<blockquote>
<p>discover all other nodes in Bitcoin network and connect to them</p>
</blockquote>
<p>Discovery and connecting are a bit different. To discover a node that node has to have advertised itself using an <code>addr</code> message. I believe nodes that don't accept incoming connections (have no listening port) don't do this, so they can not be discovered unless your node listens for incoming connections and they initiate the connection.</p>
<p>Connecting to known nodes is simple and is what statistic tools such as <a href="http://bitnodes.earn.com/" rel="nofollow noreferrer">bitnodes</a> do, an I'm assuming this is what you have in mind otherwise as @RedGrittyBrick there is no point.</p>
<p>It could start from initial peer discovery using DNS seeders then it is a matter of making a TCP connection to each node's IP address through the port they listen on (almost always the default 8333 and 18333 for mainnet and testnet) and performing the handshake (<code>version</code>+<code>verack</code>) which doesn't take more than a second. A <code>getaddr</code> message could be sent to each node asking for a list of nodes they know of to construct a list and connect to each of them.<br />
I don't think going through all <em>reachable nodes</em> (about 10k) would take longer than a minute.</p>

CC BY-SA 4.0
2020-10-08T10:18:40.903Z
2020-10-08T10:18:40.903Z
Coding Enthusiast
<p>I am wondering how long on average would it take for a node to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this?</p>

<peer-discovery>
How long on average would it take to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this?
user110232
# How long on average would it take to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this?

(Asked by: username_0 on 2020-10-08)

I am wondering how long on average would it take for a node to discover all other nodes in Bitcoin network and connect to them? Are there technical obstacles to this?

**Tags:** peer-discovery


---

## 2 answers

### Answer by username_1 on 2020-10-08. Score: 2

> **how long on average would it take for a node to discover all other nodes**

No normal node ever does this.

A normal node only connects directly with a very small number of other nodes (e.g. max 8 outbound, max 125 inbound) and relies on those other nodes to pass on information to the small number of nodes they are in contact with. This way information diffuses across the entire network.

Since nodes are continually appearing and disappearing any attempt to contact all nodes would be essentially endless or both incomplete and incorrect (it would include nodes that have been removed since the start of the discovery process)


---

### Answer by username_2 on 2020-10-08. Score: 0

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

Discovery and connecting are a bit different. To discover a node that node has to have advertised itself using an `addr` message. I believe nodes that don't accept incoming connections (have no listening port) don't do this, so they can not be discovered unless your node listens for incoming connections and they initiate the connection.

Connecting to known nodes is simple and is what statistic tools such as [bitnodes](http://bitnodes.earn.com/) do, an I'm assuming this is what you have in mind otherwise as @username_1 there is no point.

It could start from initial peer discovery using DNS seeders then it is a matter of making a TCP connection to each node's IP address through the port they listen on (almost always the default 8333 and 18333 for mainnet and testnet) and performing the handshake (`version`+`verack`) which doesn't take more than a second. A `getaddr` message could be sent to each node asking for a list of nodes they know of to construct a list and connect to each of them.  
I don't think going through all *reachable nodes* (about 10k) would take longer than a minute.


---

