Skip to content

Commit eba5d43

Browse files
committed
resolve merge issues
1 parent 0022bf0 commit eba5d43

1 file changed

Lines changed: 15 additions & 13 deletions

File tree

waku/waku_mix/protocol.nim

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{.push raises: [].}
22

3-
import chronicles, std/options, chronos, results, metrics
3+
import chronicles, std/[options, sequtils], chronos, results, metrics
44

55
import
66
libp2p/crypto/curve25519,
@@ -11,7 +11,7 @@ import
1111
libp2p/protocols/mix/mix_metrics,
1212
libp2p/protocols/mix/delay_strategy,
1313
libp2p/protocols/mix/spam_protection,
14-
libp2p/[multiaddress, peerid],
14+
libp2p/[multiaddress, multicodec, peerid],
1515
eth/common/keys
1616

1717
import
@@ -70,9 +70,19 @@ proc processBootNodes(
7070
error "Failed to parse multiaddress", multiAddr = node.multiAddr, error = error
7171
continue
7272

73-
let mixPubInfo = MixPubInfo.init(peerId, multiAddr, node.pubKey, peerPubKey.skkey)
74-
mix.nodePool.add(mixPubInfo)
75-
count += 1
73+
# Strip /p2p/ suffix for mix protocol - it only needs network address
74+
var networkAddr = multiAddr
75+
try:
76+
if multiAddr.contains(multiCodec("p2p")).get():
77+
let parts = multiAddr.items().toSeq()
78+
var addrWithoutP2P = MultiAddress()
79+
for i in 0 ..< parts.len - 1:
80+
let part = parts[i].valueOr:
81+
continue
82+
addrWithoutP2P = addrWithoutP2P & part
83+
networkAddr = addrWithoutP2P
84+
except CatchableError as e:
85+
warn "Failed to strip /p2p/ from multiaddr", error = e.msg
7686

7787
peermgr.addPeer(
7888
RemotePeerInfo.init(peerId, @[networkAddr], mixPubKey = some(node.pubKey))
@@ -124,7 +134,6 @@ proc new*(
124134
)
125135
procCall MixProtocol(m).init(
126136
localMixNodeInfo,
127-
initTable,
128137
peermgr.switch,
129138
spamProtection = Opt.some(SpamProtection(spamProtection)),
130139
delayStrategy =
@@ -282,17 +291,10 @@ method start*(mix: WakuMix) {.async.} =
282291
else:
283292
trace "Saved spam protection tree to disk"
284293

285-
mix.nodePoolLoopHandle = mix.startMixNodePoolMgr()
286-
287294
method stop*(mix: WakuMix) {.async.} =
288295
# Stop spam protection
289296
if not mix.mixRlnSpamProtection.isNil():
290297
await mix.mixRlnSpamProtection.stop()
291298
debug "Spam protection stopped"
292299

293-
if mix.nodePoolLoopHandle.isNil():
294-
return
295-
await mix.nodePoolLoopHandle.cancelAndWait()
296-
mix.nodePoolLoopHandle = nil
297-
298300
# Mix Protocol

0 commit comments

Comments
 (0)