admin
Last updated
Was this helpful?
Last updated
Was this helpful?
The admin
API gives access to several non-standard RPC methods, which allows fine grained control over an Etn-sc instance, including but not limited to network peer and RPC endpoint management.
The addPeer administrative method requests adding a new remote node to the list of tracked static nodes. The node will try to maintain connectivity to these nodes at all times, reconnecting every once in a while if the remote connection goes down.
The method accepts a single argument, the URL of the remote peer to start tracking and returns a BOOL indicating whether the peer was accepted for tracking or some error occurred.
Go
admin.AddPeer(url string) (bool, error)
Console
admin.addPeer(url)
RPC
{"method": "admin_addPeer", "params": [url]}
Adds the given node to a reserved trusted list which allows the node to always connect, even if the slots are full. It returns a BOOL to indicate whether the peer was successfully added to the list.
Console
admin.addTrustedPeer(url)
RPC
{"method": "admin_addTrustedPeer", "params": [url]}
The datadir administrative property can be queried for the absolute path the running Etn-sc node currently uses to store all its databases.
Go
admin.Datadir() (string, error)
Console
admin.datadir
RPC
{"method": "admin_datadir"}
Exports the current blockchain into a local file. It optionally takes a first and last block number, in which case it exports only that range of blocks. It returns a boolean indicating whether the operation succeeded.
Console
admin.exportChain(file, first, last)
RPC
{"method": "admin_exportChain", "params": [string, uint64, uint64]}
Imports an exported list of blocks from a local file. Importing involves processing the blocks and inserting them into the canonical chain. The state from the parent block of this range is required. It returns a boolean indicating whether the operation succeeded.
Console
admin.importChain(file)
RPC
{"method": "admin_importChain", "params": [string]}
Go
admin.NodeInfo() (*p2p.NodeInfo, error)
Console
admin.nodeInfo
RPC
{"method": "admin_nodeInfo"}
add: emitted when a peer is added
drop: emitted when a peer is dropped
msgsend: emitted when a message is successfully sent to a peer
msgrecv: emitted when a message is received from a peer
Go
admin.Peers() ([]*p2p.PeerInfo, error)
Console
admin.peers
RPC
{"method": "admin_peers"}
Disconnects from a remote node if the connection exists. It returns a boolean indicating validations succeeded. Note a true value doesn't necessarily mean that there was a connection which was disconnected.
Console
admin.removePeer(url)
RPC
{"method": "admin_removePeer", "params": [string]}
Removes a remote node from the trusted peer set, but it does not disconnect it automatically. It returns a boolean indicating validations succeeded.
Console
admin.removeTrustedPeer(url)
RPC
{"method": "admin_removeTrustedPeer", "params": [string]}
host: network interface to open the listener socket on (defaults to "localhost")
port: network port to open the listener socket on (defaults to 8545)
apis: API modules to offer over this interface (defaults to "eth,net,web3")
The method returns a boolean flag specifying whether the HTTP RPC listener was opened or not. Please note, only one HTTP endpoint is allowed to be active at any time.
Go
admin.StartHTTP(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)
Console
admin.startHTTP(host, port, cors, apis)
RPC
{"method": "admin_startHTTP", "params": [host, port, cors, apis]}
host: network interface to open the listener socket on (defaults to "localhost")
port: network port to open the listener socket on (defaults to 8546)
apis: API modules to offer over this interface (defaults to "eth,net,web3")
The method returns a boolean flag specifying whether the WebSocket RPC listener was opened or not. Please note, only one WebSocket endpoint is allowed to be active at any time.
Go
admin.StartWS(host *string, port *rpc.HexNumber, cors *string, apis *string) (bool, error)
Console
admin.startWS(host, port, cors, apis)
RPC
{"method": "admin_startWS", "params": [host, port, cors, apis]}
The stopHTTP administrative method closes the currently open HTTP RPC endpoint. As the node can only have a single HTTP endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Go
admin.StopHTTP() (bool, error)
Console
admin.stopHTTP()
RPC
{"method": "admin_stopHTTP"
The stopWS administrative method closes the currently open WebSocket RPC endpoint. As the node can only have a single WebSocket endpoint running, this method takes no parameters, returning a boolean whether the endpoint was closed or not.
Go
admin.StopWS() (bool, error)
Console
admin.stopWS()
RPC
{"method": "admin_stopWS"
The nodeInfo administrative property can be queried for all the information known about the running Etn-sc node at the networking granularity. These include general information about the node itself as a participant of the P2P overlay protocol, as well as specialized information added by each of the running application protocols (e.g. eth, les, shh, bzz).
PeerEvents creates an which receives peer events from the node's p2p server. The type of events emitted by the server are as follows:
The peers administrative property can be queried for all the information known about the connected remote nodes at the networking granularity. These include general information about the nodes themselves as participants of the P2P overlay protocol, as well as specialized information added by each of the running application protocols (e.g. eth, les, shh, bzz).
The startHTTP administrative method starts an HTTP based JSON-RPC webserver to handle client requests. All the parameters are optional:
cors: header to use (defaults to "")
The startWS administrative method starts an WebSocket based API webserver to handle client requests. All the parameters are optional:
cors: header to use (defaults to "")