nwaku/waku/node/v2/quicksim.nim

75 lines
2.2 KiB
Nim
Raw Normal View History

import
os, strformat, chronicles, json_rpc/[rpcclient, rpcserver], nimcrypto/sysrand,
eth/common as eth_common, eth/keys,
options
#options as what # TODO: Huh? Redefinition?
from os import DirSep
from strutils import rsplit
template sourceDir: string = currentSourcePath.rsplit(DirSep, 1)[0]
const sigWakuPath = &"{sourceDir}{DirSep}rpc{DirSep}wakucallsigs.nim"
createRpcSigs(RpcHttpClient, sigWakuPath)
const topicAmount = 100
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
debug "Hit handler", topic=topic, data=data
2020-06-02 03:18:55 +00:00
# All full nodes connected etc
#
# let node1 = newRpcHttpClient()
# let node2 = newRpcHttpClient()
# let node3 = newRpcHttpClient()
# let node4 = newRpcHttpClient()
# let node5 = newRpcHttpClient()
# let node6 = newRpcHttpClient()
2020-06-02 03:18:55 +00:00
# waitFor node1.connect("localhost", Port(8547))
# waitFor node2.connect("localhost", Port(8548))
# waitFor node3.connect("localhost", Port(8549))
# waitFor node4.connect("localhost", Port(8550))
# waitFor node5.connect("localhost", Port(8551))
# waitFor node6.connect("localhost", Port(8552))
# let version = waitFor node6.wakuVersion()
# info "Version is", version
# # TODO: Implement handler logic
# # All subscribing to foobar topic
# let res2 = waitFor node2.wakuSubscribe("foobar")
# let res3 = waitFor node3.wakuSubscribe("foobar")
# let res4 = waitFor node4.wakuSubscribe("foobar")
# let res5 = waitFor node5.wakuSubscribe("foobar")
# let res6 = waitFor node6.wakuSubscribe("foobar")
# os.sleep(2000)
# # info "Posting envelopes on all subscribed topics"
# for i in 0..<topicAmount:
# os.sleep(50)
# let res2 = waitFor node1.wakuPublish("foobar", "hello world")
# os.sleep(2000)
# for i in 0..<topicAmount:
# os.sleep(50)
# let res2 = waitFor node1.wakuPublish("foobar", "hello world2")
let nodea = newRpcHttpClient()
let nodeb = newRpcHttpClient()
waitFor nodea.connect("localhost", Port(8545))
waitFor nodeb.connect("localhost", Port(8546))
let version = waitFor nodea.wakuVersion()
info "Version is", version
let res1 = waitFor nodea.wakuSubscribe("foobar")
let res2 = waitFor nodeb.wakuSubscribe("foobar")
os.sleep(2000)
2020-06-02 03:18:55 +00:00
for i in 0..<topicAmount:
os.sleep(50)
let res3 = waitFor nodea.wakuPublish("foobar", "hello world")