mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-05 23:43:07 +00:00
Propagating subscribes work, BUT at perf (need light node behavior)
This commit is contained in:
parent
aeb34d68de
commit
83abcf58d8
@ -68,15 +68,15 @@ info "Version is", version
|
|||||||
let res1 = waitFor nodea.wakuSubscribe("foobar")
|
let res1 = waitFor nodea.wakuSubscribe("foobar")
|
||||||
let res2 = waitFor nodeb.wakuSubscribe("foobar")
|
let res2 = waitFor nodeb.wakuSubscribe("foobar")
|
||||||
|
|
||||||
|
|
||||||
# Node 00 and 05 also subscribe
|
# Node 00 and 05 also subscribe
|
||||||
# XXX I confirm this works. Now to tweak it!
|
# XXX I confirm this works. As in - with this we have A-B
|
||||||
let node0 = newRpcHttpClient()
|
# Now to tweak it!
|
||||||
let node5 = newRpcHttpClient()
|
# let node0 = newRpcHttpClient()
|
||||||
waitFor node0.connect("localhost", Port(8547))
|
# let node5 = newRpcHttpClient()
|
||||||
waitFor node5.connect("localhost", Port(8552))
|
# waitFor node0.connect("localhost", Port(8547))
|
||||||
let res4 = waitFor node0.wakuSubscribe("foobar")
|
# waitFor node5.connect("localhost", Port(8552))
|
||||||
let res5 = waitFor node5.wakuSubscribe("foobar")
|
# let res4 = waitFor node0.wakuSubscribe("foobar")
|
||||||
|
# let res5 = waitFor node5.wakuSubscribe("foobar")
|
||||||
|
|
||||||
os.sleep(2000)
|
os.sleep(2000)
|
||||||
|
|
||||||
|
|||||||
@ -70,16 +70,21 @@ method subscribe*(w: WakuSub,
|
|||||||
debug "subscribe", topic=topic
|
debug "subscribe", topic=topic
|
||||||
# XXX: Pubsub really
|
# XXX: Pubsub really
|
||||||
|
|
||||||
|
# XXX: This is what is called, I think
|
||||||
if w.gossip_enabled:
|
if w.gossip_enabled:
|
||||||
await procCall GossipSub(w).subscribe(topic, handler)
|
await procCall GossipSub(w).subscribe(topic, handler)
|
||||||
else:
|
else:
|
||||||
await procCall FloodSub(w).subscribe(topic, handler)
|
await procCall FloodSub(w).subscribe(topic, handler)
|
||||||
|
|
||||||
|
|
||||||
# Subscribing a peer to a specified topic
|
# Subscribing a peer to a specified topic
|
||||||
method subscribeTopic*(w: WakuSub,
|
method subscribeTopic*(w: WakuSub,
|
||||||
topic: string,
|
topic: string,
|
||||||
subscribe: bool,
|
subscribe: bool,
|
||||||
peerId: string) {.async, gcsafe.} =
|
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
|
debug "subscribeTopic", topic=topic, subscribe=subscribe, peerId=peerId
|
||||||
|
|
||||||
if w.gossip_enabled:
|
if w.gossip_enabled:
|
||||||
@ -87,6 +92,15 @@ method subscribeTopic*(w: WakuSub,
|
|||||||
else:
|
else:
|
||||||
await procCall FloodSub(w).subscribeTopic(topic, subscribe, peerId)
|
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
|
# TODO: Fix decrement connected peers here or somewhere else
|
||||||
method handleDisconnect*(w: WakuSub, peer: PubSubPeer) {.async.} =
|
method handleDisconnect*(w: WakuSub, peer: PubSubPeer) {.async.} =
|
||||||
debug "handleDisconnect (NYI)"
|
debug "handleDisconnect (NYI)"
|
||||||
@ -104,6 +118,7 @@ method rpcHandler*(w: WakuSub,
|
|||||||
await procCall GossipSub(w).rpcHandler(peer, rpcMsgs)
|
await procCall GossipSub(w).rpcHandler(peer, rpcMsgs)
|
||||||
else:
|
else:
|
||||||
await procCall FloodSub(w).rpcHandler(peer, rpcMsgs)
|
await procCall FloodSub(w).rpcHandler(peer, rpcMsgs)
|
||||||
|
# XXX: here
|
||||||
|
|
||||||
method publish*(w: WakuSub,
|
method publish*(w: WakuSub,
|
||||||
topic: string,
|
topic: string,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user