From 2e7b73115c9ea11edac7a1ee8bce029981daab8f Mon Sep 17 00:00:00 2001 From: jm-clius Date: Fri, 2 Jul 2021 09:11:47 +0000 Subject: [PATCH] deploy: 734fe0795f0f7ff3ef22271e949c818e3e2edb54 --- CHANGELOG.md | 1 + .../vendor/libbacktrace-upstream/libtool | 2 +- waku/v2/node/wakunode2.nim | 27 ++++++++++--------- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c4abc7f06..4b656d85b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ This release contains the following: - Enables db migration for the message store. - The `resume` Nim API eliminates duplicates messages before storing them. - Support for stable version of `relay` protocol, with protocol ID `/vac/waku/relay/2.0.0` +- Support for multiple protocol IDs - now matches any protocol that adds postfix to stable ID. #### General refactoring #### Docs diff --git a/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool b/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool index f43c3dddb..4e4b37a17 100755 --- a/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool +++ b/vendor/nim-libbacktrace/vendor/libbacktrace-upstream/libtool @@ -2,7 +2,7 @@ # libtool - Provide generalized library-building support services. # Generated automatically by config.status (libbacktrace) version-unused -# Libtool was configured on host fv-az269-347: +# Libtool was configured on host fv-az278-254: # NOTE: Changes made to this file will be lost: look at ltmain.sh. # # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, diff --git a/waku/v2/node/wakunode2.nim b/waku/v2/node/wakunode2.nim index 9f6f198d6..9ab8f1ea8 100644 --- a/waku/v2/node/wakunode2.nim +++ b/waku/v2/node/wakunode2.nim @@ -87,6 +87,15 @@ type func asEthKey*(key: PrivateKey): keys.PrivateKey = keys.PrivateKey(key.skkey) +func protocolMatcher(codec: string): Matcher = + ## Returns a protocol matcher function for the provided codec + + proc match(proto: string): bool {.gcsafe.} = + ## Matches a proto with any postfix to the provided codec. + ## E.g. if the codec is `/vac/waku/filter/2.0.0` it matches the protos: + ## `/vac/waku/filter/2.0.0`, `/vac/waku/filter/2.0.0-beta3`, `/vac/waku/filter/2.0.0-actualnonsense` + return proto.startsWith(codec) + proc removeContentFilters(filters: var Filters, contentFilters: seq[ContentFilter]) {.gcsafe.} = # Flatten all unsubscribe topics into single seq let unsubscribeTopics = contentFilters.mapIt(it.contentTopic) @@ -389,7 +398,7 @@ proc mountFilter*(node: WakuNode) = waku_node_messages.inc(labelValues = ["filter"]) node.wakuFilter = WakuFilter.init(node.peerManager, node.rng, filterHandler) - node.switch.mount(node.wakuFilter) + node.switch.mount(node.wakuFilter, protocolMatcher(WakuFilterCodec)) node.subscriptions.subscribe(WakuFilterCodec, node.wakuFilter.subscription()) # NOTE: If using the swap protocol, it must be mounted before store. This is @@ -397,7 +406,7 @@ proc mountFilter*(node: WakuNode) = proc mountSwap*(node: WakuNode, swapConfig: SwapConfig = SwapConfig.init()) = info "mounting swap", mode = $swapConfig.mode node.wakuSwap = WakuSwap.init(node.peerManager, node.rng, swapConfig) - node.switch.mount(node.wakuSwap) + node.switch.mount(node.wakuSwap, protocolMatcher(WakuSwapCodec)) # NYI - Do we need this? #node.subscriptions.subscribe(WakuSwapCodec, node.wakuSwap.subscription()) @@ -411,7 +420,7 @@ proc mountStore*(node: WakuNode, store: MessageStore = nil, persistMessages: boo debug "mounting store with swap" node.wakuStore = WakuStore.init(node.peerManager, node.rng, store, node.wakuSwap) - node.switch.mount(node.wakuStore) + node.switch.mount(node.wakuStore, protocolMatcher(WakuStoreCodec)) if persistMessages: node.subscriptions.subscribe(WakuStoreCodec, node.wakuStore.subscription()) @@ -480,13 +489,7 @@ proc mountRelay*(node: WakuNode, info "mounting relay", rlnRelayEnabled=rlnRelayEnabled, relayMessages=relayMessages - proc relayMatch(proto: string): bool {.gcsafe.} = - ## Matches the WakuRelayCodec with any postfix. - ## E.g. if WakuRelayCodec is `/vac/waku/relay/2.0.0` it matches: - ## `/vac/waku/relay/2.0.0`, `/vac/waku/relay/2.0.0-beta2`, `/vac/waku/relay/2.0.0-actualnonsense` - return proto.startsWith(WakuRelayCodec) - - node.switch.mount(wakuRelay, relayMatch) + node.switch.mount(wakuRelay, protocolMatcher(WakuRelayCodec)) if not relayMessages: ## Some nodes may choose not to have the capability to relay messages (e.g. "light" nodes). @@ -534,8 +537,8 @@ proc mountLightPush*(node: WakuNode) = else: debug "mounting lightpush with relay" node.wakuLightPush = WakuLightPush.init(node.peerManager, node.rng, nil, node.wakuRelay) - - node.switch.mount(node.wakuLightPush) + + node.switch.mount(node.wakuLightPush, protocolMatcher(WakuLightPushCodec)) proc mountLibp2pPing*(node: WakuNode) = info "mounting libp2p ping protocol"