<p>Did you add the hardcoded nodes with <code>addnode</code> or with <code>connect</code>?</p>

<p><code>addnode=&lt;ip&gt;</code>          Add a node to connect to and attempt to keep the connection open<br>
<code>connect=&lt;ip&gt;</code>          Connect only to the specified node(s)</p>

<p>So, if you used <code>connect</code>, it will not connect to any but the hardcoded nodes.</p>

CC BY-SA 3.0
2015-12-24T09:52:08.510Z
2015-12-24T09:52:08.510Z
Murch
<p>I am tinkering with the bitcoin source code and trying to understand the exact working of peer discovery mechanism in the <code>testnet</code> mode for which I have made the following changes:</p>

<ol>
<li><p>Disabled the DNS seed discovery in order to force bitcoind to fallback to connect to hardcoded nodes.</p></li>
<li><p>Changed the default hardcoded nodes to my known 4 addresses, lets say A,B,C and D, which I ensure are always online.</p></li>
</ol>

<p>Now, when I run the bitcoind client (call it E), it connects to one of A,B,C or D, running the same modified version of bitcoind. It gets the peer addresses from  the hardcoded node that it first connects to by exchanging <code>getaddr</code> and <code>addr</code> messages but I am not sure how it proceeds after that. I have following queries:</p>

<p>a. If a node falls back to connect to hardcoded nodes, is it supposed to connect to only one of the hardcoded nodes like it happends in my case or can it connect to multiple hardcoded nodes ?</p>

<p>b. After getting peer address via the <code>addr</code> message, when will the node E start connecting to those peers ?</p>

<p>Please point me to the relevant code files/sections if possible. Thanks</p>

CC BY-SA 3.0
2015-10-28T03:02:14.187Z
Have you read http://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other/11273#11273 ? Are you looking for more specific information about what happens after connecting to a hardcoded node?
Nick ODell
CC BY-SA 3.0
2015-10-28T03:35:33.477Z
@NickODell yes I read that already on the bitcoin wiki page. I am looking for 2 specific things: a) Let us say there are 4 hardcoded nodes that are online, then my node E connects to exactly one of them. Why does it not connect to more than 1 hardcoded nodes ? Is that the correct intended behaviour of bitcoin ?     b) After the hardcoded node informs node E about presence of other nodes on the network and node E stores that in `peers.dat`, when will it start connecting to those nodes, because right now in my case it seems to be doing nothing with those nodes.
bawejakunal
<bitcoind><testnet><peers><peer-discovery>
How peer discovery works after connecting to hardcoded nodes?
bawejakunal
# How peer discovery works after connecting to hardcoded nodes?

(Asked by: username_0 on 2015-10-28)

I am tinkering with the bitcoin source code and trying to understand the exact working of peer discovery mechanism in the `testnet` mode for which I have made the following changes:

1. Disabled the DNS seed discovery in order to force bitcoind to fallback to connect to hardcoded nodes.
2. Changed the default hardcoded nodes to my known 4 addresses, lets say A,B,C and D, which I ensure are always online.

Now, when I run the bitcoind client (call it E), it connects to one of A,B,C or D, running the same modified version of bitcoind. It gets the peer addresses from the hardcoded node that it first connects to by exchanging `getaddr` and `addr` messages but I am not sure how it proceeds after that. I have following queries:

a. If a node falls back to connect to hardcoded nodes, is it supposed to connect to only one of the hardcoded nodes like it happends in my case or can it connect to multiple hardcoded nodes ?

b. After getting peer address via the `addr` message, when will the node E start connecting to those peers ?

Please point me to the relevant code files/sections if possible. Thanks

**Tags:** bitcoind, testnet, peers, peer-discovery

> **Comments:**
> **username_1**: Have you read http://bitcoin.stackexchange.com/questions/3536/how-do-bitcoin-clients-find-each-other/11273#11273 ? Are you looking for more specific information about what happens after connecting to a hardcoded node?  
> **username_0**: @username_1 yes I read that already on the bitcoin wiki page. I am looking for 2 specific things: a) Let us say there are 4 hardcoded nodes that are online, then my node E connects to exactly one of them. Why does it not connect to more than 1 hardcoded nodes ? Is that the correct intended behaviour of bitcoin ?     b) After the hardcoded node informs node E about presence of other nodes on the network and node E stores that in `peers.dat`, when will it start connecting to those nodes, because right now in my case it seems to be doing nothing with those nodes.  

---

## 1 answers

### Answer by username_2 on 2015-12-24. Score: 2

Did you add the hardcoded nodes with `addnode` or with `connect`?

`addnode=<ip>` Add a node to connect to and attempt to keep the connection open  
`connect=<ip>` Connect only to the specified node(s)

So, if you used `connect`, it will not connect to any but the hardcoded nodes.


---

