mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-20 19:08:29 +00:00
* Add basic rpc scripts to publish and subscribe * Fix publish topic and payload script Also change parameter name in waku relay due to weird shadowing of log topic: DBG 2020-09-09 12:07:54+08:00 waku_publish tid=8795 file=wakurpc.nim:30 topic=waku payload=@[] DBG 2020-09-09 12:07:54+08:00 publish tid=8795 file=waku_relay.nim:65 topic=WakuRelay Above should show topic=waku but it gets topic=WakuRelay from log scope for some reason. * Scripts take arguments * Add basic nangang tutorial * Update docs/tutorial/nangang.md Co-authored-by: Kim De Mey <kim.demey@gmail.com> * Update docs/tutorial/nangang.md Co-authored-by: Kim De Mey <kim.demey@gmail.com> * meh * ENsure subscribe call succeeds Co-authored-by: Kim De Mey <kim.demey@gmail.com>
32 lines
875 B
Nim
32 lines
875 B
Nim
import
|
|
os, strutils, strformat, chronicles, json_rpc/[rpcclient, rpcserver], nimcrypto/sysrand,
|
|
libp2p/protobuf/minprotobuf,
|
|
eth/common as eth_common, eth/keys,
|
|
system,
|
|
options
|
|
|
|
from strutils import rsplit
|
|
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
|
|
|
|
const sigWakuPath = sourceDir / "wakucallsigs.nim"
|
|
createRpcSigs(RpcHttpClient, sigWakuPath)
|
|
|
|
if paramCount() < 1:
|
|
echo "Please provide rpcPort as argument."
|
|
quit(1)
|
|
|
|
let rpcPort = Port(parseInt(paramStr(1)))
|
|
|
|
echo "Please enter your message:"
|
|
let message = readLine(stdin)
|
|
echo "Message is:", message
|
|
|
|
var node = newRpcHttpClient()
|
|
waitfor node.connect("localhost", rpcPort)
|
|
|
|
# Subscribe ourselves to topic
|
|
#var res = node.wakuSubscribe("waku")
|
|
|
|
# TODO When RPC uses Node, create WakuMessage and pass instead
|
|
var res2 = waitfor node.wakuPublish("waku", cast[seq[byte]]("hello world"))
|