github.com/amazechain/amc@v0.1.3/docs/jsonrpc/admin.md (about) 1 # `admin` Namespace 2 3 The `admin` API allows you to configure your node, including adding and removing peers. 4 5 > **Note** 6 > 7 > As this namespace can configure your node at runtime, it is generally **not advised** to expose it publicly. 8 9 ## `admin_addPeer` 10 11 Add the given peer to the current peer set of the node. 12 13 The method accepts a single argument, the [`enode`][enode] URL of the remote peer to connect to, and returns a `bool` indicating whether the peer was accepted or not. 14 15 | Client | Method invocation | 16 |--------|------------------------------------------------| 17 | RPC | `{"method": "admin_addPeer", "params": [url]}` | 18 19 ### Example 20 21 ```js 22 // > {"jsonrpc":"2.0","id":1,"method":"admin_addPeer","params":["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"]} 23 {"jsonrpc":"2.0","id":1,"result":true} 24 ``` 25 26 ## `admin_removePeer` 27 28 Disconnects from a peer if the connection exists. Returns a `bool` indicating whether the peer was successfully removed or not. 29 30 | Client | Method invocation | 31 |--------|----------------------------------------------------| 32 | RPC | `{"method": "admin_removePeer", "params": [url]}` | 33 34 ### Example 35 36 ```js 37 // > {"jsonrpc":"2.0","id":1,"method":"admin_removePeer","params":["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"]} 38 {"jsonrpc":"2.0","id":1,"result":true} 39 ``` 40 41 ## `admin_addTrustedPeer` 42 43 Adds the given peer to a list of trusted peers, which allows the peer to always connect, even if there would be no room for it otherwise. 44 45 It returns a `bool` indicating whether the peer was added to the list or not. 46 47 | Client | Method invocation | 48 |--------|-------------------------------------------------------| 49 | RPC | `{"method": "admin_addTrustedPeer", "params": [url]}` | 50 51 ### Example 52 53 ```js 54 // > {"jsonrpc":"2.0","id":1,"method":"admin_addTrustedPeer","params":["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"]} 55 {"jsonrpc":"2.0","id":1,"result":true} 56 ``` 57 58 ## `admin_removeTrustedPeer` 59 60 Removes a remote node from the trusted peer set, but it does not disconnect it automatically. 61 62 Returns true if the peer was successfully removed. 63 64 | Client | Method invocation | 65 |--------|----------------------------------------------------------| 66 | RPC | `{"method": "admin_removeTrustedPeer", "params": [url]}` | 67 68 ### Example 69 70 ```js 71 // > {"jsonrpc":"2.0","id":1,"method":"admin_removeTrustedPeer","params":["enode://a979fb575495b8d6db44f750317d0f4622bf4c2aa3365d6af7c284339968eef29b69ad0dce72a4d8db5ebb4968de0e3bec910127f134779fbcb0cb6d3331163c@52.16.188.185:30303"]} 72 {"jsonrpc":"2.0","id":1,"result":true} 73 ``` 74 75 ## `admin_nodeInfo` 76 77 Returns all information known about the running node. 78 79 These include general information about the node itself, as well as what protocols it participates in, its IP and ports. 80 81 | Client | Method invocation | 82 |--------|--------------------------------| 83 | RPC | `{"method": "admin_nodeInfo"}` | 84 85 ### Example 86 87 ```js 88 // > {"jsonrpc":"2.0","id":1,"method":"admin_nodeInfo","params":[]} 89 { 90 "jsonrpc": "2.0", 91 "id": 1, 92 "result": { 93 "enode": "enode://44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d@[::]:30303", 94 "id": "44826a5d6a55f88a18298bca4773fca5749cdc3a5c9f308aa7d810e9b31123f3e7c5fba0b1d70aac5308426f47df2a128a6747040a3815cc7dd7167d03be320d", 95 "ip": "::", 96 "listenAddr": "[::]:30303", 97 "name": "amc/v0.1.0/x86_64-unknown-linux-gnu", 98 "ports": { 99 "discovery": 61015, 100 "listener": 61016 101 }, 102 "protocols": { 103 "eth": { 104 "difficulty": 17334254859343145000, 105 "genesis": "0xd4e56740f876aef8c010b86a40d5f56745a118d0906a34e69aec8c0db1cb8fa3", 106 "head": "0xb83f73fbe6220c111136aefd27b160bf4a34085c65ba89f24246b3162257c36a", 107 "network": 1 108 } 109 } 110 } 111 } 112 ``` 113 114 ## `admin_peerEvents`, `admin_peerEvents_unsubscribe` 115 116 <!-- TODO: This seems to be unimplemented, so it is not really known what the events look like !--> 117 118 Subscribe to events received by peers over the network. 119 120 Like other subscription methods, this returns the ID of the subscription, which is then used in all events subsequently. 121 122 To unsubscribe from peer events, call `admin_peerEvents_unsubscribe` 123 124 | Client | Method invocation | 125 |--------|----------------------------------| 126 | RPC | `{"method": "admin_peerEvents"}` | 127 128 ### Example 129 130 ```js 131 // > {"jsonrpc":"2.0","id":1,"method":"admin_peerEvents","params":[]} 132 // responds with subscription ID 133 {"jsonrpc": "2.0", "id": 1, "result": "0xcd0c3e8af590364c09d0fa6a1210faf5"} 134 ``` 135 136 [enode]: https://ethereum.org/en/developers/docs/networking-layer/network-addresses/#enode