mirror of https://github.com/waku-org/nwaku.git
feature/mount-store (#111)
* mounts the store protocol * todo * Update waku/node/v2/wakunode2.nim Co-authored-by: Oskar Thorén <me@oskarth.com> * fix * Update waku/node/v2/wakunode2.nim Co-authored-by: Oskar Thorén <me@oskarth.com> * eol Co-authored-by: Oskar Thorén <me@oskarth.com> Co-authored-by: Oskar Thorén <ot@oskarthoren.com>
This commit is contained in:
parent
792e71bb60
commit
7a2bbdff11
|
@ -10,7 +10,9 @@ import
|
|||
# NOTE For TopicHandler, solve with exports?
|
||||
libp2p/protocols/pubsub/pubsub,
|
||||
libp2p/peerinfo,
|
||||
../../protocol/v2/waku_relay, ../common,
|
||||
rpc/wakurpc,
|
||||
standard_setup,
|
||||
../../protocol/v2/[waku_relay, waku_store], ../common,
|
||||
./waku_types, ./config, ./standard_setup, ./rpc/wakurpc
|
||||
|
||||
# key and crypto modules different
|
||||
|
@ -126,8 +128,11 @@ proc start*(node: WakuNode) {.async.} =
|
|||
node.libp2pTransportLoops = await node.switch.start()
|
||||
|
||||
# NOTE WakuRelay is being instantiated as part of creating switch with PubSub field set
|
||||
#
|
||||
# TODO Mount Waku Store and Waku Filter here
|
||||
let storeProto = WakuStore.init()
|
||||
node.switch.mount(storeProto)
|
||||
|
||||
let wakuRelay = cast[WakuRelay](node.switch.pubSub.get())
|
||||
wakuRelay.addFilter("store", storeProto.filter())
|
||||
|
||||
# TODO Get this from WakuNode obj
|
||||
let peerInfo = node.peerInfo
|
||||
|
|
|
@ -12,6 +12,9 @@ type
|
|||
|
||||
Filters* = Table[string, Filter]
|
||||
|
||||
proc subscribe*(filters: var Filters, name: string, filter: Filter) =
|
||||
filters.add(name, filter)
|
||||
|
||||
proc init*(T: type Filter, topics: seq[string], handler: FilterMessageHandler): T =
|
||||
result = T(
|
||||
topics: topics,
|
||||
|
|
|
@ -138,3 +138,6 @@ method stop*(w: WakuRelay) {.async.} =
|
|||
await procCall GossipSub(w).stop()
|
||||
else:
|
||||
await procCall FloodSub(w).stop()
|
||||
|
||||
proc addFilter*(w: WakuRelay, name: string, filter: Filter) =
|
||||
w.filters.subscribe(name, filter)
|
||||
|
|
Loading…
Reference in New Issue