mirror of
https://github.com/logos-messaging/logos-messaging-nim.git
synced 2026-01-04 06:53:12 +00:00
enhancement/remove-flood (#295)
* removes flood * rm Co-authored-by: Oskar Thorén <ot@oskarthoren.com>
This commit is contained in:
parent
b6b90f6f54
commit
27df67fd99
@ -35,7 +35,6 @@ proc generateNodes*(
|
|||||||
verifySignature = verifySignature,
|
verifySignature = verifySignature,
|
||||||
sign = sign,
|
sign = sign,
|
||||||
# XXX unclear why including this causes a compiler error, it is part of WakuRelay type
|
# XXX unclear why including this causes a compiler error, it is part of WakuRelay type
|
||||||
#gossipEnabled = gossip,
|
|
||||||
msgIdProvider = msgIdProvider).PubSub
|
msgIdProvider = msgIdProvider).PubSub
|
||||||
|
|
||||||
switch.mount(wakuRelay)
|
switch.mount(wakuRelay)
|
||||||
|
|||||||
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
import
|
import
|
||||||
chronos, chronicles, metrics,
|
chronos, chronicles, metrics,
|
||||||
libp2p/protocols/pubsub/[pubsub, floodsub, gossipsub],
|
libp2p/protocols/pubsub/[pubsub, gossipsub],
|
||||||
libp2p/protocols/pubsub/rpc/messages,
|
libp2p/protocols/pubsub/rpc/messages,
|
||||||
libp2p/stream/connection,
|
libp2p/stream/connection,
|
||||||
../waku_types
|
../waku_types
|
||||||
@ -35,14 +35,7 @@ method init*(w: WakuRelay) =
|
|||||||
method initPubSub*(w: WakuRelay) =
|
method initPubSub*(w: WakuRelay) =
|
||||||
debug "initWakuRelay"
|
debug "initWakuRelay"
|
||||||
|
|
||||||
# Not using GossipSub
|
procCall GossipSub(w).initPubSub()
|
||||||
# XXX: FloodSub subscribe doesn't work
|
|
||||||
w.gossipEnabled = true
|
|
||||||
|
|
||||||
if w.gossipEnabled:
|
|
||||||
procCall GossipSub(w).initPubSub()
|
|
||||||
else:
|
|
||||||
procCall FloodSub(w).initPubSub()
|
|
||||||
|
|
||||||
w.init()
|
w.init()
|
||||||
|
|
||||||
@ -50,10 +43,8 @@ method subscribe*(w: WakuRelay,
|
|||||||
pubSubTopic: string,
|
pubSubTopic: string,
|
||||||
handler: TopicHandler) {.async.} =
|
handler: TopicHandler) {.async.} =
|
||||||
debug "subscribe", pubSubTopic=pubSubTopic
|
debug "subscribe", pubSubTopic=pubSubTopic
|
||||||
if w.gossipEnabled:
|
|
||||||
await procCall GossipSub(w).subscribe(pubSubTopic, handler)
|
await procCall GossipSub(w).subscribe(pubSubTopic, handler)
|
||||||
else:
|
|
||||||
await procCall FloodSub(w).subscribe(pubSubTopic, handler)
|
|
||||||
|
|
||||||
method publish*(w: WakuRelay,
|
method publish*(w: WakuRelay,
|
||||||
pubSubTopic: string,
|
pubSubTopic: string,
|
||||||
@ -61,38 +52,25 @@ method publish*(w: WakuRelay,
|
|||||||
): Future[int] {.async.} =
|
): Future[int] {.async.} =
|
||||||
debug "publish", pubSubTopic=pubSubTopic, message=message
|
debug "publish", pubSubTopic=pubSubTopic, message=message
|
||||||
|
|
||||||
if w.gossipEnabled:
|
return await procCall GossipSub(w).publish(pubSubTopic, message)
|
||||||
return await procCall GossipSub(w).publish(pubSubTopic, message)
|
|
||||||
else:
|
|
||||||
return await procCall FloodSub(w).publish(pubSubTopic, message)
|
|
||||||
|
|
||||||
method unsubscribe*(w: WakuRelay,
|
method unsubscribe*(w: WakuRelay,
|
||||||
topics: seq[TopicPair]) {.async.} =
|
topics: seq[TopicPair]) {.async.} =
|
||||||
debug "unsubscribe"
|
debug "unsubscribe"
|
||||||
if w.gossipEnabled:
|
|
||||||
await procCall GossipSub(w).unsubscribe(topics)
|
await procCall GossipSub(w).unsubscribe(topics)
|
||||||
else:
|
|
||||||
await procCall FloodSub(w).unsubscribe(topics)
|
|
||||||
|
|
||||||
method unsubscribeAll*(w: WakuRelay,
|
method unsubscribeAll*(w: WakuRelay,
|
||||||
pubSubTopic: string) {.async.} =
|
pubSubTopic: string) {.async.} =
|
||||||
debug "unsubscribeAll"
|
debug "unsubscribeAll"
|
||||||
if w.gossipEnabled:
|
|
||||||
await procCall GossipSub(w).unsubscribeAll(pubSubTopic)
|
await procCall GossipSub(w).unsubscribeAll(pubSubTopic)
|
||||||
else:
|
|
||||||
await procCall FloodSub(w).unsubscribeAll(pubSubTopic)
|
|
||||||
|
|
||||||
# GossipSub specific methods --------------------------------------------------
|
# GossipSub specific methods --------------------------------------------------
|
||||||
method start*(w: WakuRelay) {.async.} =
|
method start*(w: WakuRelay) {.async.} =
|
||||||
debug "start"
|
debug "start"
|
||||||
if w.gossipEnabled:
|
await procCall GossipSub(w).start()
|
||||||
await procCall GossipSub(w).start()
|
|
||||||
else:
|
|
||||||
await procCall FloodSub(w).start()
|
|
||||||
|
|
||||||
method stop*(w: WakuRelay) {.async.} =
|
method stop*(w: WakuRelay) {.async.} =
|
||||||
debug "stop"
|
debug "stop"
|
||||||
if w.gossipEnabled:
|
await procCall GossipSub(w).stop()
|
||||||
await procCall GossipSub(w).stop()
|
|
||||||
else:
|
|
||||||
await procCall FloodSub(w).stop()
|
|
||||||
|
|||||||
@ -88,7 +88,6 @@ type
|
|||||||
Filters* = Table[string, Filter]
|
Filters* = Table[string, Filter]
|
||||||
|
|
||||||
WakuRelay* = ref object of GossipSub
|
WakuRelay* = ref object of GossipSub
|
||||||
gossipEnabled*: bool
|
|
||||||
|
|
||||||
WakuInfo* = object
|
WakuInfo* = object
|
||||||
# NOTE One for simplicity, can extend later as needed
|
# NOTE One for simplicity, can extend later as needed
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user