Use admin prefix for nodeInfo and addPeer JSON-RPCs (#1799)

This commit is contained in:
Kim De Mey 2023-10-03 14:44:08 +02:00 committed by GitHub
parent 395580ff9d
commit 1bb389ad4e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 14 deletions

View File

@ -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"

View File

@ -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())