I have joined a private network and it works fine when I add the peers with admin.addPeer
but I have to add the peers every time I launch geth.
How can I make the list of peers permanent?
I have joined a private network and it works fine when I add the peers with admin.addPeer
but I have to add the peers every time I launch geth.
How can I make the list of peers permanent?
There are several categories of nodes in Ethereum:
1. Bootnodes
These are nodes used for bootstrapping purposes, and which are hard-coded into your Geth binary. The hard-coded values can be overridden using the --bootnodes
option when running Geth from the command line. Alternatively, the hard-codings can be changed by editing the Geth code and rebuilding from source. In your case, it sounds like these hard-codings haven't been updated with any of the nodes in your private network, which is why you can't connect straight out of the box.
2. Static nodes
These are peers you always want to connect to. They're not necessarily boot nodes. You can set them either by using admin.addPeer
command, as you've found, or by editing your <datadir>/static-nodes.json
file, as described in the official documentation. In your case, I'd recommend editing this file.
3. Trusted nodes
Slightly different to static nodes, in that connections to these nodes don't count towards the total, limited connection count. As explained here.
<datadir>/geth/static-nodes.json
as mentioned in the docs you linked? This directory contains folders chaindata
, lightchaindata
, nodes
, and files transactions.rlp
, LOCK
, nodekey
– Nyxynyx
Jul 17 '18 at 16:19
you could when launching geth
specify the different nodes separated by commas as follow :
geth --bootnodes enode://pubkey1@ip1:port1,enode://pubkey2@ip2:port2,enode://pubkey3@ip3:port3
More details : https://github.com/ethereum/go-ethereum/wiki/Connecting-to-the-network
to automate the task you could create a batch file in windows or a script in linux