Start basic RPC server

This commit is contained in:
Oskar Thoren 2020-04-29 13:19:48 +08:00
parent 7752840d0e
commit a533d47121
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
3 changed files with 15 additions and 12 deletions

View File

@ -96,7 +96,7 @@ type
rpc* {.
desc: "Enable Waku RPC server.",
defaultValue: false
defaultValue: true
name: "rpc" }: bool
rpcAddress* {.

View File

@ -14,12 +14,12 @@ from stew/byteutils import hexToSeqByte, hexToByteArray
# Instead of using rlpx waku_protocol here, lets do mock waku2_protocol
# This should wrap GossipSub, not use EthereumNode here
# Blatant copy of Whisper RPC but for the Waku protocol
# XXX: Wrong, also what is wakuVersionStr?
# We also have rlpx protocol here waku_protocol
# XXX: WRong, should not be EthereumNode, should be libp2p node
proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
# In Waku0/1 we use node.protocolState(Waku) a lot to get information
# Also keys to get priate key, etc
# Where is the equivalent in Waku/2?
# TODO: Extend to get access to protocol state and keys
#proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
proc setupWakuRPC*(rpcsrv: RpcServer) =
# Seems easy enough, lets try to get this first
rpcsrv.rpc("waku_version") do() -> string:
@ -32,5 +32,3 @@ proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
# XXX: Though wrong layer for that - wait how does this work in devp2p sim?
# We connect to nodes there, should be very similar here
# We can also do this from nim-waku repo

View File

@ -37,6 +37,7 @@ type WakuProto = ref object of LPProtocol
const clientId = "Nimbus waku node"
# TODO: We want this to be on top of GossipSub, how does that work?
# XXX: waku version not inherited from protocol
const WakuCodec = "/vac/waku/2.0.0-alpha0"
let globalListeningAddr = parseIpAddress("0.0.0.0")
@ -105,7 +106,7 @@ proc newWakuProto(switch: Switch): WakuProto =
proc run(config: WakuNodeConf) =
info "libp2p support NYI"
info "libp2p support WIP"
if config.logLevel != LogLevel.NONE:
setLogLevel(config.logLevel)
@ -141,13 +142,17 @@ proc run(config: WakuNodeConf) =
let ta = initTAddress(config.rpcAddress,
Port(config.rpcPort + config.portsShift))
var rpcServer = newRpcHttpServer([ta])
# Not using keys right now
let keys = newKeyStorage()
# Ok cool no node here
# TODO: Fix me with node etc
#setupWakuRPC(node, keys, rpcServer)
#setupWakuSimRPC(node, rpcServer)
setupWakuRPC(rpcServer)
rpcServer.start()
# TODO: Use it to get waku version
# Huh not printed
info "rpcServer started"
# TODO: Here setup a libp2p node
# Essentially something like this in nbc/eth2_network: