mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
Start basic RPC server
This commit is contained in:
parent
f4d17a50d9
commit
6dd15e3798
@ -96,7 +96,7 @@ type
|
|||||||
|
|
||||||
rpc* {.
|
rpc* {.
|
||||||
desc: "Enable Waku RPC server.",
|
desc: "Enable Waku RPC server.",
|
||||||
defaultValue: false
|
defaultValue: true
|
||||||
name: "rpc" }: bool
|
name: "rpc" }: bool
|
||||||
|
|
||||||
rpcAddress* {.
|
rpcAddress* {.
|
||||||
|
|||||||
@ -14,12 +14,12 @@ from stew/byteutils import hexToSeqByte, hexToByteArray
|
|||||||
# Instead of using rlpx waku_protocol here, lets do mock waku2_protocol
|
# Instead of using rlpx waku_protocol here, lets do mock waku2_protocol
|
||||||
# This should wrap GossipSub, not use EthereumNode here
|
# This should wrap GossipSub, not use EthereumNode here
|
||||||
|
|
||||||
# Blatant copy of Whisper RPC but for the Waku protocol
|
# In Waku0/1 we use node.protocolState(Waku) a lot to get information
|
||||||
|
# Also keys to get priate key, etc
|
||||||
# XXX: Wrong, also what is wakuVersionStr?
|
# Where is the equivalent in Waku/2?
|
||||||
# We also have rlpx protocol here waku_protocol
|
# TODO: Extend to get access to protocol state and keys
|
||||||
# XXX: WRong, should not be EthereumNode, should be libp2p node
|
#proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
|
||||||
proc setupWakuRPC*(node: EthereumNode, keys: KeyStorage, rpcsrv: RpcServer) =
|
proc setupWakuRPC*(rpcsrv: RpcServer) =
|
||||||
|
|
||||||
# Seems easy enough, lets try to get this first
|
# Seems easy enough, lets try to get this first
|
||||||
rpcsrv.rpc("waku_version") do() -> string:
|
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?
|
# 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 connect to nodes there, should be very similar here
|
||||||
|
|
||||||
# We can also do this from nim-waku repo
|
|
||||||
|
|
||||||
|
|||||||
@ -37,6 +37,7 @@ type WakuProto = ref object of LPProtocol
|
|||||||
const clientId = "Nimbus waku node"
|
const clientId = "Nimbus waku node"
|
||||||
|
|
||||||
# TODO: We want this to be on top of GossipSub, how does that work?
|
# 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"
|
const WakuCodec = "/vac/waku/2.0.0-alpha0"
|
||||||
|
|
||||||
let globalListeningAddr = parseIpAddress("0.0.0.0")
|
let globalListeningAddr = parseIpAddress("0.0.0.0")
|
||||||
@ -105,7 +106,7 @@ proc newWakuProto(switch: Switch): WakuProto =
|
|||||||
|
|
||||||
proc run(config: WakuNodeConf) =
|
proc run(config: WakuNodeConf) =
|
||||||
|
|
||||||
info "libp2p support NYI"
|
info "libp2p support WIP"
|
||||||
|
|
||||||
if config.logLevel != LogLevel.NONE:
|
if config.logLevel != LogLevel.NONE:
|
||||||
setLogLevel(config.logLevel)
|
setLogLevel(config.logLevel)
|
||||||
@ -141,13 +142,17 @@ proc run(config: WakuNodeConf) =
|
|||||||
let ta = initTAddress(config.rpcAddress,
|
let ta = initTAddress(config.rpcAddress,
|
||||||
Port(config.rpcPort + config.portsShift))
|
Port(config.rpcPort + config.portsShift))
|
||||||
var rpcServer = newRpcHttpServer([ta])
|
var rpcServer = newRpcHttpServer([ta])
|
||||||
|
|
||||||
|
# Not using keys right now
|
||||||
let keys = newKeyStorage()
|
let keys = newKeyStorage()
|
||||||
# Ok cool no node here
|
|
||||||
# TODO: Fix me with node etc
|
|
||||||
#setupWakuRPC(node, keys, rpcServer)
|
#setupWakuRPC(node, keys, rpcServer)
|
||||||
#setupWakuSimRPC(node, rpcServer)
|
#setupWakuSimRPC(node, rpcServer)
|
||||||
|
setupWakuRPC(rpcServer)
|
||||||
rpcServer.start()
|
rpcServer.start()
|
||||||
|
|
||||||
|
# TODO: Use it to get waku version
|
||||||
|
# Huh not printed
|
||||||
|
info "rpcServer started"
|
||||||
|
|
||||||
# TODO: Here setup a libp2p node
|
# TODO: Here setup a libp2p node
|
||||||
# Essentially something like this in nbc/eth2_network:
|
# Essentially something like this in nbc/eth2_network:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user