Search code examples
ethereumgeth

Add Peers does not add a peer in Geth console


I am trying to add a peer. I created two nodes using the following commands on geth.The boot node creation command is

geth --datadir ./chaindata3 --port 30304 --nodiscover --networkid 12 --rpc --rpcport "8546" --rpccorsdomain "*" --ipcdisable console

The other node creation command

geth --datadir ./chaindata4 --port 30307 --nodiscover --networkid 12 --ipcdisable --bootnodes "enode://7143091f47a3d4aae216ce781e28b53c1faa9daa08bbeaa9a01adbd9b3933fb3b83acff00a375bf0a4b30b1135b7aabef422c28c60279de34e9399a3d91d7c88@127.0.0.1:30304" console

When i type the command admin.peers it returns an empty list. Can someone please help me with this?


Solution

  • Setup actual boot node, don't treat base node (first full node as boot node).

    bootnode -genkey boot.key
    
    bootnode -addr localhost:port -nodekey boot.key  -verbosity 9
    

    Start other nodes pointing the boot node

    ex:

    geth --datadir "data" --syncmode "full" --rpcport port --rpc --rpcaddr "localhost"  --port port --rpccorsdomain "*" --rpcapi "personal,eth,net,db,web3,txpool,miner" --bootnodes "enode://************@localhost:port" --networkid 100  --ipcdisable --mine console
    

    Sorry couldn't format:that's why added new answer