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:
Dean Eigenmann 2020-09-02 05:08:48 +02:00 committed by GitHub
parent 792e71bb60
commit 7a2bbdff11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 14 additions and 3 deletions

View File

@ -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

View File

@ -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,

View File

@ -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)