mirror of https://github.com/waku-org/nwaku.git
Fix SIGSERV error by initializing child methods
This commit is contained in:
parent
550556bb97
commit
2070f65828
|
@ -42,8 +42,7 @@ proc newStandardSwitch*(privKey = none(PrivateKey),
|
|||
else:
|
||||
# Creating switch from generate node
|
||||
# XXX: Hacky test, hijacking WakuSub here
|
||||
# XXX: If I use WakuSub here I get a SIGSERV
|
||||
#echo "Using WakuSub here"
|
||||
echo "Using WakuSub here"
|
||||
#PubSub newPubSub(FloodSub, peerInfo, triggerSelf)
|
||||
PubSub newPubSub(WakuSub, peerInfo, triggerSelf)
|
||||
|
||||
|
|
|
@ -51,8 +51,9 @@ task protocol2, "Build the experimental Waku protocol":
|
|||
buildBinary "waku_protocol", "waku/protocol/v2/", "-d:chronicles_log_level=DEBUG"
|
||||
|
||||
task wakutest2, "Build Experimental Waku tests":
|
||||
test "v2/test_waku"
|
||||
#buildBinary "waku_test", "waku/protocol/v2/", "-d:chronicles_log_level=DEBUG --lineTrace:on --threads:on"
|
||||
let name = "v2/test_waku"
|
||||
buildBinary name, "tests/", "-d:chronicles_log_level=DEBUG"
|
||||
exec "build/" & name
|
||||
|
||||
task wakunode2, "Build Experimental Waku cli":
|
||||
buildBinary "wakunode", "waku/node/v2/", "-d:chronicles_log_level=TRACE"
|
||||
|
|
|
@ -9,6 +9,7 @@ import chronos, chronicles
|
|||
import libp2p/protocols/pubsub/pubsub,
|
||||
libp2p/protocols/pubsub/pubsubpeer,
|
||||
libp2p/protocols/pubsub/floodsub,
|
||||
libp2p/protocols/pubsub/rpc/[messages, message],
|
||||
libp2p/connection
|
||||
|
||||
logScope:
|
||||
|
@ -27,6 +28,7 @@ type
|
|||
text*: string
|
||||
|
||||
method init(w: WakuSub) =
|
||||
debug "init"
|
||||
proc handler(conn: Connection, proto: string) {.async.} =
|
||||
## main protocol handler that gets triggered on every
|
||||
## connection for a protocol string
|
||||
|
@ -46,29 +48,38 @@ method init(w: WakuSub) =
|
|||
w.handler = handler
|
||||
w.codec = WakuSubCodec
|
||||
|
||||
#
|
||||
method initPubSub*(w: WakuSub) =
|
||||
echo "initWakuSub"
|
||||
debug "initWakuSub"
|
||||
w.text = "Foobar"
|
||||
echo "w.text", w.text
|
||||
echo "ok2"
|
||||
# XXX
|
||||
procCall FloodSub(w).initPubSub()
|
||||
w.init()
|
||||
|
||||
# Here floodsub field is a topic to remote peer map
|
||||
# We also have a seen message forwarded to peers
|
||||
method subscribeTopic*(w: WakuSub,
|
||||
topic: string,
|
||||
subscribe: bool,
|
||||
peerId: string) {.gcsafe.} =
|
||||
debug "subscribeTopic"
|
||||
procCall FloodSub(w).subscribeTopic(topic, subscribe, peerId)
|
||||
|
||||
# method subscribeTopic
|
||||
# method handleDisconnect
|
||||
# method rpcHandler
|
||||
# method init
|
||||
# method publish
|
||||
# method unsubscribe
|
||||
# method initPubSub
|
||||
method handleDisconnect*(w: WakuSub, peer: PubSubPeer) {.async.} =
|
||||
debug "handleDisconnect NYI"
|
||||
|
||||
# To defer to parent object something like:
|
||||
# procCall PubSub(f).publish(topic, data)
|
||||
|
||||
# Then we should be able to write tests like floodsub test
|
||||
|
||||
# Can also do in-line here
|
||||
method rpcHandler*(w: WakuSub,
|
||||
peer: PubSubPeer,
|
||||
rpcMsgs: seq[RPCMsg]) {.async.} =
|
||||
debug "rpcHandler"
|
||||
await procCall FloodSub(w).rpcHandler(peer, rpcMsgs)
|
||||
|
||||
method publish*(w: WakuSub,
|
||||
topic: string,
|
||||
data: seq[byte]) {.async.} =
|
||||
debug "publish"
|
||||
await procCall FloodSub(w).publish(topic, data)
|
||||
|
||||
method unsubscribe*(w: WakuSub,
|
||||
topics: seq[TopicPair]) {.async.} =
|
||||
debug "unsubscribe"
|
||||
await procCall FloodSub(w).unsubscribe(topics)
|
||||
|
|
Loading…
Reference in New Issue