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