7

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"?

8

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.
5

--maxpeers "1" means one peer computer is connected to your node.

if you run > admin.peers in geth console it will return [] if you are running in --dev mode

to see connected peers

> admin.peers

returns

{
    caps: ["eth/61", "eth/62", "eth/63"],
    id: "dcae857cb89ab8xxxxxx32bde07ecff2b836bef51cba90a157afe05df50636a7",
    name: "Geth/v1.3.5/linux/go1.5.1",
    network: {
      localAddress: "37.139.x.xx:30303",
      remoteAddress: "46.x.xxx.162:33208"
    },
    protocols: {
      eth: {
        difficulty: 13215741744858590000,
        head: "1e3da5c7aea3c9300c57622532ce6a00edb79fdc6b05e79f9e4bc5930c1cf46c",
        version: 63
      }
    }
}

To see no of peers connected

> admin.peers.length

returns

13 // means 13 nodes connected to your node.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.