[Ethereum] Does the number of geth’s maxpeers option include it’s own node

go-ethereum

In geth's parameters there is a --maxpeers option. Does this option number includes it's own node?

--maxpeers "25" Maximum number of network peers (network disabled if set to 0)

Does --maxpeers "1" means 2 peers in the network including the node which execute the geth command with --maxpeers "1"?

Best Answer

Does the number of maxpeers of geth option include it's own node?

No. Specifying the parameter:

  • --maxpeers 0 will not allow your geth instance to connect to any other peer
  • --maxpeers 1 will allow your geth instance to connect to one other peer
  • --maxpeers n will allow your geth instance to connect to n other nodes


Does --maxpeers "1" means 2 peers in the network including the node which executed the geth command with --maxpeers "1"?

No. Your geth instance where you specified --maxpeers 1 will have at maximum 1 connection to another peer instance. However the other peer instance may have connections to many another instances.


Details below.


Test Environment

  • Single computer with 5 geth instances running on ports 30301, 30302, 30303, 30304 and 30305 .
  • All instances have the same --networkid 8888 and --genesis CustomGenesis.json files - a private network.
  • All instances have a different --datadir {directory} parameter.
  • geth instances 2, 3, 4 and 5 all have their enode URL information listed in static-nodes.json in the --datadir {directory}.
  • IF geth instance 1 is also listed in the static-nodes.json and a copy of this file is also available in it's --datadir {directory}, all 4 other geth instances will be connected to it as peers, regardless of the number specified in each of the geth instance's --maxpeer parameter.
  • IF geth instance 1 does not have the static-nodes.json file but instead uses the --bootnodes {enode URL} and the --maxpeers {n} parameters, the number of connections that geth instance 1 will be connected to is n separate geth nodes.
  • IF geth instance 1 does not have the static-nodes.json file but instead uses the --bootnodes {enode URL} and the --maxpeers {n} followed by the --nodiscover parameter, geth instance 1 will connect to n separate geth nodes. --nodiscover does not run geth in stand-alone mode.
Related Topic