admin_addPeer (#708)

Signed-off-by: Adrian Sutton <adrian.sutton@consensys.net>
pull/2/head
MadelineMurray 6 years ago committed by GitHub
parent f4b0e1d0ce
commit b078310845
  1. 5
      docs/Configuring-Pantheon/Networking.md
  2. 4
      docs/Configuring-Pantheon/Testing-Developing-Nodes.md
  3. 43
      docs/Reference/JSON-RPC-API-Methods.md

@ -37,10 +37,13 @@ the maximum number of peers. The default is 25.
## No Discovery
The [`--discovery-enabled`](../Reference/Pantheon-CLI-Syntax.md#discovery-enabled) option
The [`--discovery-enabled`](../Reference/Pantheon-CLI-Syntax.md#discovery-enabled) command line option
can be used to disable P2P peer discovery.
Set this option to `false` if you are running a test node or a test network with fixed nodes.
Use the [`admin_addPeer`](../Reference/JSON-RPC-API-Methods.md#admin_addpeer) JSON-RPC method to add peers when
[`--discovery-enabled`](../Reference/Pantheon-CLI-Syntax.md#discovery-enabled) is set to false.
## Monitoring Peer Connections
Use the [`debug_metrics`](../Reference/JSON-RPC-API-Methods.md#debug_metrics) JSON-RPC API method

@ -42,8 +42,8 @@ option is `enode://<id>@<host:port>` where:
* `<id>` is the node public key written to the specified file (`bootnode` in the above example) excluding the initial 0x.
* `<host:port>` is the host and port the bootnode is listening on for P2P peer discovery.
Specified by the [`--p2p-host` option](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and
[`--p2p-port` option](../Reference/Pantheon-CLI-Syntax.md#p2p-port) option for the bootnode
Specified by the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and
[`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port) options for the bootnode
(default host is `127.0.0.1` and port is `30303`).
!!! example

@ -14,6 +14,49 @@ The following lists the Pantheon JSON-RPC API commands:
The `ADMIN` API methods are not enabled by default. Use the [`--rpc-http-api`](Pantheon-CLI-Syntax.md#rpc-http-api)
or [`--rpc-ws-api`](Pantheon-CLI-Syntax.md#rpc-ws-api) options to enable the `ADMIN` API methods.
### admin_addPeer
Adds a node to the list of tracked static nodes. The node attempts to maintain connectivity to tracked static nodes.
If the remote connection goes down, the node attempts to reconnect every 60 seconds.
**Parameters**
`string` : Enode of peer to add
The enode is `enode://<id>@<host:port>` where:
* `<id>` is the node public key excluding the initial 0x.
* `<host:port>` is the host and port the node is listening on for P2P peer discovery.
Specified by the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) and
[`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port) options.
!!! example
If the [`--p2p-host`](../Reference/Pantheon-CLI-Syntax.md#p2p-host) or [`--p2p-port`](../Reference/Pantheon-CLI-Syntax.md#p2p-port) options are not specified and the node public key is `0xc35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f`
The enode URL is:
`enode://c35c3ec90a8a51fd5703594c6303382f3ae6b2ecb9589bab2c04b3794f2bc3fc2631dabb0c08af795787a6c004d8f532230ae6e9925cbbefb0b28b79295d615f@127.0.0.1:30303`
**Returns**
`result` : `boolean` - `true` if peer added or `false` if peer already on list of static nodes.
!!! example
```bash tab="curl HTTP request"
$ curl -X POST --data '{"jsonrpc":"2.0","method":"admin_addPeer","params":["enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"],"id":1}' <JSON-RPC-http-endpoint:port>
```
```bash tab="wscat WS request"
{"jsonrpc":"2.0","method":"admin_addPeer","params":["enode://f59c0ab603377b6ec88b89d5bb41b98fc385030ab1e4b03752db6f7dab364559d92c757c13116ae6408d2d33f0138e7812eb8b696b2a22fe3332c4b5127b22a3@127.0.0.1:30304"],"id":1}
```
```json tab="JSON result"
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
```
### admin_peers
Returns networking information about connected remote nodes.

Loading…
Cancel
Save