Skip to content

P2P

P2P network RPC interface

Set or query network status

1. p2p_getPeers

  • Usage:

  Get currently connected nodes

  • Params:

   null

  • Return:P2P peer-to-peer information connecting with local

  • Example:

shell:

curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_getPeers","params":"", "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 p2p_getPeers 3
  • Response:
{
  "jsonrpc": "2.0",
  "id": 3,
  "result": [
    "3[email protected]39.98.39.224",
    "9[email protected]39.99.44.60"
  ]
}

2. p2p_addPeer

  • Usage:

  Add peer node

  • Params:

   null

  • Return:nil

  • Example:

shell:

curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_addPeer","params":["enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f10917[email protected]192.168.74.1:55555"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 p2p_addPeer "enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f10917[email protected]192.168.74.1:55555" 3
  • Response:
{"jsonrpc": "2.0", "id": 3, "result": None}

3. p2p_removePeer

  • Usage:

  remove peer node

  • Params:

   null

  • Return:nil

  • Example:

shell:

curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_removePeer","params":["enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f10917[email protected]192.168.74.1:55555"], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 p2p_removePeer "enode://e1b2f83b7b0f5845cc74ca12bb40152e520842bbd0597b7770cb459bd40f10917[email protected]192.168.74.1:55555" 3
  • Response:
{"jsonrpc": "2.0", "id": 3, "result": None}

4. p2p_localNode

  • Usage:

  Need to get local eNode for P2P link

  • Params:

   null

  • Return:local enode

  • Example:

shell:

curl http://127.0.0.1:10085 -X POST --data '{"jsonrpc":"2.0","method":"p2p_localNode","params":[""], "id": 3}' -H "Content-Type:application/json"

cli:

drep-cli 127.0.0.1:10085 p2p_localNode 3
  • Response:
{"enode://9[email protected]192.168.31.63:10086}