mirror of https://github.com/waku-org/nwaku.git
Minor bridge improvements (#563)
This commit is contained in:
parent
6e742433be
commit
e0d8d8f468
|
@ -172,7 +172,9 @@ proc start*(cmb: Chat2MatterBridge) {.async.} =
|
|||
debug "Start listening on Waku v2"
|
||||
await cmb.nodev2.start()
|
||||
|
||||
cmb.nodev2.mountRelay() # Always mount relay for bridge
|
||||
# Always mount relay for bridge
|
||||
# `triggerSelf` is false on a `bridge` to avoid duplicates
|
||||
cmb.nodev2.mountRelay(triggerSelf = false)
|
||||
|
||||
# Bridging
|
||||
# Handle messages on Waku v2 and bridge to Matterbridge
|
||||
|
|
|
@ -65,27 +65,27 @@ func toWakuMessage(env: Envelope): WakuMessage =
|
|||
proc toWakuV2(bridge: WakuBridge, env: Envelope) {.async.} =
|
||||
let msg = env.toWakuMessage()
|
||||
|
||||
debug "message converted to V2", msg=msg
|
||||
|
||||
if bridge.seen.containsOrAdd(msg.encode().buffer.hash()):
|
||||
# This is a duplicate message. Return
|
||||
trace "Already seen. Dropping.", msg=msg
|
||||
waku_bridge_dropped.inc(labelValues = ["duplicate"])
|
||||
return
|
||||
|
||||
trace "Sending message to V2", msg=msg
|
||||
|
||||
waku_bridge_transfers.inc(labelValues = ["v1_to_v2"])
|
||||
|
||||
await bridge.nodev2.publish(DefaultBridgeTopic, msg)
|
||||
|
||||
proc toWakuV1(bridge: WakuBridge, msg: WakuMessage) {.gcsafe.} =
|
||||
debug "sending message to V1", msg=msg
|
||||
|
||||
if bridge.seen.containsOrAdd(msg.encode().buffer.hash()):
|
||||
# This is a duplicate message. Return
|
||||
trace "Already seen. Dropping.", msg=msg
|
||||
waku_bridge_dropped.inc(labelValues = ["duplicate"])
|
||||
return
|
||||
|
||||
trace "Sending message to V1", msg=msg
|
||||
|
||||
waku_bridge_transfers.inc(labelValues = ["v2_to_v1"])
|
||||
|
||||
# @TODO: use namespacing to map v2 contentTopics to v1 topics
|
||||
|
@ -154,7 +154,9 @@ proc start*(bridge: WakuBridge) {.async.} =
|
|||
debug "Start listening on Waku v2"
|
||||
await bridge.nodev2.start()
|
||||
|
||||
bridge.nodev2.mountRelay() # Always mount relay for bridge
|
||||
# Always mount relay for bridge.
|
||||
# `triggerSelf` is false on a `bridge` to avoid duplicates
|
||||
bridge.nodev2.mountRelay(triggerSelf = false)
|
||||
|
||||
# Bridging
|
||||
# Handle messages on Waku v1 and bridge to Waku v2
|
||||
|
|
|
@ -441,12 +441,13 @@ proc mountRelay*(node: WakuNode,
|
|||
topics: seq[string] = newSeq[string](),
|
||||
rlnRelayEnabled = false,
|
||||
keepAlive = false,
|
||||
relayMessages = true) {.gcsafe.} =
|
||||
relayMessages = true,
|
||||
triggerSelf = true) {.gcsafe.} =
|
||||
let wakuRelay = WakuRelay.init(
|
||||
switch = node.switch,
|
||||
# Use default
|
||||
#msgIdProvider = msgIdProvider,
|
||||
triggerSelf = true,
|
||||
triggerSelf = triggerSelf,
|
||||
sign = false,
|
||||
verifySignature = false
|
||||
)
|
||||
|
|
Loading…
Reference in New Issue