enhancement/remove-flood (#295)

* removes flood

* rm

Co-authored-by: Oskar Thorén <ot@oskarthoren.com>
This commit is contained in:
Dean Eigenmann 2020-11-24 10:14:18 +01:00 committed by GitHub
parent 63b0e8af76
commit 309bcb05a1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 35 deletions

View File

@ -35,7 +35,6 @@ proc generateNodes*(
verifySignature = verifySignature,
sign = sign,
# XXX unclear why including this causes a compiler error, it is part of WakuRelay type
#gossipEnabled = gossip,
msgIdProvider = msgIdProvider).PubSub
switch.mount(wakuRelay)

View File

@ -5,7 +5,7 @@
import
chronos, chronicles, metrics,
libp2p/protocols/pubsub/[pubsub, floodsub, gossipsub],
libp2p/protocols/pubsub/[pubsub, gossipsub],
libp2p/protocols/pubsub/rpc/messages,
libp2p/stream/connection,
../waku_types
@ -35,14 +35,7 @@ method init*(w: WakuRelay) =
method initPubSub*(w: WakuRelay) =
debug "initWakuRelay"
# Not using GossipSub
# XXX: FloodSub subscribe doesn't work
w.gossipEnabled = true
if w.gossipEnabled:
procCall GossipSub(w).initPubSub()
else:
procCall FloodSub(w).initPubSub()
procCall GossipSub(w).initPubSub()
w.init()
@ -50,10 +43,8 @@ method subscribe*(w: WakuRelay,
pubSubTopic: string,
handler: TopicHandler) {.async.} =
debug "subscribe", pubSubTopic=pubSubTopic
if w.gossipEnabled:
await procCall GossipSub(w).subscribe(pubSubTopic, handler)
else:
await procCall FloodSub(w).subscribe(pubSubTopic, handler)
await procCall GossipSub(w).subscribe(pubSubTopic, handler)
method publish*(w: WakuRelay,
pubSubTopic: string,
@ -61,38 +52,25 @@ method publish*(w: WakuRelay,
): Future[int] {.async.} =
debug "publish", pubSubTopic=pubSubTopic, message=message
if w.gossipEnabled:
return await procCall GossipSub(w).publish(pubSubTopic, message)
else:
return await procCall FloodSub(w).publish(pubSubTopic, message)
return await procCall GossipSub(w).publish(pubSubTopic, message)
method unsubscribe*(w: WakuRelay,
topics: seq[TopicPair]) {.async.} =
debug "unsubscribe"
if w.gossipEnabled:
await procCall GossipSub(w).unsubscribe(topics)
else:
await procCall FloodSub(w).unsubscribe(topics)
await procCall GossipSub(w).unsubscribe(topics)
method unsubscribeAll*(w: WakuRelay,
pubSubTopic: string) {.async.} =
debug "unsubscribeAll"
if w.gossipEnabled:
await procCall GossipSub(w).unsubscribeAll(pubSubTopic)
else:
await procCall FloodSub(w).unsubscribeAll(pubSubTopic)
await procCall GossipSub(w).unsubscribeAll(pubSubTopic)
# GossipSub specific methods --------------------------------------------------
method start*(w: WakuRelay) {.async.} =
debug "start"
if w.gossipEnabled:
await procCall GossipSub(w).start()
else:
await procCall FloodSub(w).start()
await procCall GossipSub(w).start()
method stop*(w: WakuRelay) {.async.} =
debug "stop"
if w.gossipEnabled:
await procCall GossipSub(w).stop()
else:
await procCall FloodSub(w).stop()
await procCall GossipSub(w).stop()

View File

@ -88,7 +88,6 @@ type
Filters* = Table[string, Filter]
WakuRelay* = ref object of GossipSub
gossipEnabled*: bool
WakuInfo* = object
# NOTE One for simplicity, can extend later as needed