mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-12 05:14:14 +00:00
Add nimbus_addPeer rpc call
This commit is contained in:
parent
730013bde3
commit
84a89e918a
@ -9,8 +9,8 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
std/[strutils, tables],
|
std/[strutils, tables],
|
||||||
nimcrypto, eth/common as eth_common, stint, json_rpc/server,
|
nimcrypto, eth/common as eth_common, stint, json_rpc/server, json_rpc/errors,
|
||||||
eth/p2p, eth/p2p/enode,
|
eth/p2p, eth/p2p/enode, eth/p2p/peer_pool,
|
||||||
../config, ./hexstrings
|
../config, ./hexstrings
|
||||||
|
|
||||||
type
|
type
|
||||||
@ -57,3 +57,10 @@ proc setupCommonRpc*(node: EthereumNode, conf: NimbusConf, server: RpcServer) =
|
|||||||
listener: $enode.address.tcpPort
|
listener: $enode.address.tcpPort
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
server.rpc("nimbus_addPeer") do(enode: string) -> bool:
|
||||||
|
var res = ENode.fromString(enode)
|
||||||
|
if res.isOk:
|
||||||
|
asyncCheck node.peerPool.connectToNode(newNode(res.get()))
|
||||||
|
return true
|
||||||
|
raise (ref InvalidRequest)(code: -32602, msg: "Invalid ENode")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user