From 1bb389ad4e7356aa7544307af6e95b1b8dd0b6f4 Mon Sep 17 00:00:00 2001 From: Kim De Mey Date: Tue, 3 Oct 2023 14:44:08 +0200 Subject: [PATCH] Use admin prefix for nodeInfo and addPeer JSON-RPCs (#1799) --- hive_integration/nimbus/enode.sh | 2 +- nimbus/rpc/common.nim | 29 ++++++++++++++++------------- 2 files changed, 17 insertions(+), 14 deletions(-) diff --git a/hive_integration/nimbus/enode.sh b/hive_integration/nimbus/enode.sh index f5395afa9..0c4ad0c5a 100644 --- a/hive_integration/nimbus/enode.sh +++ b/hive_integration/nimbus/enode.sh @@ -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" diff --git a/nimbus/rpc/common.nim b/nimbus/rpc/common.nim index 6ef969b12..8bb7c42b2 100644 --- a/nimbus/rpc/common.nim +++ b/nimbus/rpc/common.nim @@ -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())