Propagating subscribes work, BUT at perf (need light node behavior)

This commit is contained in:
Oskar Thoren 2020-06-03 19:32:11 +08:00
parent 037c3f29cb
commit 9fc3e11f3b
No known key found for this signature in database
GPG Key ID: B2ECCFD3BC2EF77E
2 changed files with 23 additions and 8 deletions

View File

@ -68,15 +68,15 @@ info "Version is", version
let res1 = waitFor nodea.wakuSubscribe("foobar")
let res2 = waitFor nodeb.wakuSubscribe("foobar")
# Node 00 and 05 also subscribe
# XXX I confirm this works. Now to tweak it!
let node0 = newRpcHttpClient()
let node5 = newRpcHttpClient()
waitFor node0.connect("localhost", Port(8547))
waitFor node5.connect("localhost", Port(8552))
let res4 = waitFor node0.wakuSubscribe("foobar")
let res5 = waitFor node5.wakuSubscribe("foobar")
# XXX I confirm this works. As in - with this we have A-B
# Now to tweak it!
# let node0 = newRpcHttpClient()
# let node5 = newRpcHttpClient()
# waitFor node0.connect("localhost", Port(8547))
# waitFor node5.connect("localhost", Port(8552))
# let res4 = waitFor node0.wakuSubscribe("foobar")
# let res5 = waitFor node5.wakuSubscribe("foobar")
os.sleep(2000)

View File

@ -70,16 +70,21 @@ method subscribe*(w: WakuSub,
debug "subscribe", topic=topic
# XXX: Pubsub really
# XXX: This is what is called, I think
if w.gossip_enabled:
await procCall GossipSub(w).subscribe(topic, handler)
else:
await procCall FloodSub(w).subscribe(topic, handler)
# Subscribing a peer to a specified topic
method subscribeTopic*(w: WakuSub,
topic: string,
subscribe: bool,
peerId: string) {.async, gcsafe.} =
proc handler(topic: string, data: seq[byte]) {.async, gcsafe.} =
info "Hit NOOP handler", topic
debug "subscribeTopic", topic=topic, subscribe=subscribe, peerId=peerId
if w.gossip_enabled:
@ -87,6 +92,15 @@ method subscribeTopic*(w: WakuSub,
else:
await procCall FloodSub(w).subscribeTopic(topic, subscribe, peerId)
# XXX: This should distingish light and etc node
# NOTE: Relay subscription
# TODO: If peer is light node
info "about to call subscribe"
await w.subscribe(topic, handler)
# TODO: Fix decrement connected peers here or somewhere else
method handleDisconnect*(w: WakuSub, peer: PubSubPeer) {.async.} =
debug "handleDisconnect (NYI)"
@ -104,6 +118,7 @@ method rpcHandler*(w: WakuSub,
await procCall GossipSub(w).rpcHandler(peer, rpcMsgs)
else:
await procCall FloodSub(w).rpcHandler(peer, rpcMsgs)
# XXX: here
method publish*(w: WakuSub,
topic: string,