|
1 | 1 | {.push raises: [].} |
2 | 2 |
|
3 | | -import chronicles, std/options, chronos, results, metrics |
| 3 | +import chronicles, std/[options, sequtils], chronos, results, metrics |
4 | 4 |
|
5 | 5 | import |
6 | 6 | libp2p/crypto/curve25519, |
|
11 | 11 | libp2p/protocols/mix/mix_metrics, |
12 | 12 | libp2p/protocols/mix/delay_strategy, |
13 | 13 | libp2p/protocols/mix/spam_protection, |
14 | | - libp2p/[multiaddress, peerid], |
| 14 | + libp2p/[multiaddress, multicodec, peerid], |
15 | 15 | eth/common/keys |
16 | 16 |
|
17 | 17 | import |
@@ -70,9 +70,19 @@ proc processBootNodes( |
70 | 70 | error "Failed to parse multiaddress", multiAddr = node.multiAddr, error = error |
71 | 71 | continue |
72 | 72 |
|
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 |
76 | 86 |
|
77 | 87 | peermgr.addPeer( |
78 | 88 | RemotePeerInfo.init(peerId, @[networkAddr], mixPubKey = some(node.pubKey)) |
@@ -124,7 +134,6 @@ proc new*( |
124 | 134 | ) |
125 | 135 | procCall MixProtocol(m).init( |
126 | 136 | localMixNodeInfo, |
127 | | - initTable, |
128 | 137 | peermgr.switch, |
129 | 138 | spamProtection = Opt.some(SpamProtection(spamProtection)), |
130 | 139 | delayStrategy = |
@@ -282,17 +291,10 @@ method start*(mix: WakuMix) {.async.} = |
282 | 291 | else: |
283 | 292 | trace "Saved spam protection tree to disk" |
284 | 293 |
|
285 | | - mix.nodePoolLoopHandle = mix.startMixNodePoolMgr() |
286 | | - |
287 | 294 | method stop*(mix: WakuMix) {.async.} = |
288 | 295 | # Stop spam protection |
289 | 296 | if not mix.mixRlnSpamProtection.isNil(): |
290 | 297 | await mix.mixRlnSpamProtection.stop() |
291 | 298 | debug "Spam protection stopped" |
292 | 299 |
|
293 | | - if mix.nodePoolLoopHandle.isNil(): |
294 | | - return |
295 | | - await mix.nodePoolLoopHandle.cancelAndWait() |
296 | | - mix.nodePoolLoopHandle = nil |
297 | | - |
298 | 300 | # Mix Protocol |
0 commit comments