Use admin prefix for nodeInfo and addPeer JSON-RPCs (#1799)
This commit is contained in:
parent
395580ff9d
commit
1bb389ad4e
|
@ -9,7 +9,7 @@
|
|||
# Immediately abort the script on any error encountered
|
||||
set -e
|
||||
|
||||
TARGET_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"net_nodeInfo","params":[],"id":1}' "localhost:8545" )
|
||||
TARGET_RESPONSE=$(curl -s -X POST -H "Content-Type: application/json" --data '{"jsonrpc":"2.0","method":"admin_nodeInfo","params":[],"id":1}' "localhost:8545" )
|
||||
|
||||
TARGET_ENODE=$(echo ${TARGET_RESPONSE}| jq -r '.result.enode')
|
||||
echo "$TARGET_ENODE"
|
||||
|
|
|
@ -46,21 +46,24 @@ proc setupCommonRpc*(node: EthereumNode, conf: NimbusConf, server: RpcServer) =
|
|||
let peerCount = uint node.numPeers
|
||||
result = encodeQuantity(peerCount)
|
||||
|
||||
server.rpc("net_nodeInfo") do() -> NodeInfo:
|
||||
let enode = toENode(node)
|
||||
let nodeId = toNodeId(node.keys.pubkey)
|
||||
result = NodeInfo(
|
||||
id: nodeId.toHex,
|
||||
name: conf.agentString,
|
||||
enode: $enode,
|
||||
ip: $enode.address.ip,
|
||||
ports: NodePorts(
|
||||
discovery: $enode.address.udpPort,
|
||||
listener: $enode.address.tcpPort
|
||||
server.rpc("admin_nodeInfo") do() -> NodeInfo:
|
||||
let
|
||||
enode = toENode(node)
|
||||
nodeId = toNodeId(node.keys.pubkey)
|
||||
nodeInfo = NodeInfo(
|
||||
id: nodeId.toHex,
|
||||
name: conf.agentString,
|
||||
enode: $enode,
|
||||
ip: $enode.address.ip,
|
||||
ports: NodePorts(
|
||||
discovery: $enode.address.udpPort,
|
||||
listener: $enode.address.tcpPort
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
server.rpc("nimbus_addPeer") do(enode: string) -> bool:
|
||||
return nodeInfo
|
||||
|
||||
server.rpc("admin_addPeer") do(enode: string) -> bool:
|
||||
var res = ENode.fromString(enode)
|
||||
if res.isOk:
|
||||
asyncSpawn node.connectToNode(res.get())
|
||||
|
|
Loading…
Reference in New Issue