mirror of
https://github.com/status-im/nim-libp2p.git
synced 2025-02-18 07:46:42 +00:00
move peer id concatenation to switch
This commit is contained in:
parent
3a659ffddb
commit
1b2b009f79
@ -18,7 +18,7 @@ import tables, strutils, sets
|
|||||||
import multicodec, multihash, multibase, transcoder, vbuffer, peerid,
|
import multicodec, multihash, multibase, transcoder, vbuffer, peerid,
|
||||||
protobuf/minprotobuf, errors, utility
|
protobuf/minprotobuf, errors, utility
|
||||||
import stew/[base58, base32, endians2, results]
|
import stew/[base58, base32, endians2, results]
|
||||||
export results, minprotobuf, vbuffer, utility
|
export results, minprotobuf, vbuffer, utility, multicodec
|
||||||
|
|
||||||
logScope:
|
logScope:
|
||||||
topics = "libp2p multiaddress"
|
topics = "libp2p multiaddress"
|
||||||
|
@ -163,12 +163,9 @@ proc expandWildcardAddresses(
|
|||||||
)
|
)
|
||||||
addresses.add(wildcardAddresses)
|
addresses.add(wildcardAddresses)
|
||||||
else:
|
else:
|
||||||
listenAddr.concat(peerIdMa).withValue(ma):
|
addresses.add(listenAddr)
|
||||||
addresses.add(ma)
|
|
||||||
else:
|
else:
|
||||||
let suffixed = listenAddr.concat(peerIdMa).valueOr:
|
addresses.add(listenAddr)
|
||||||
continue
|
|
||||||
addresses.add(suffixed)
|
|
||||||
addresses
|
addresses
|
||||||
|
|
||||||
method setup*(
|
method setup*(
|
||||||
|
@ -344,10 +344,12 @@ proc start*(s: Switch) {.async, public.} =
|
|||||||
await s.stop()
|
await s.stop()
|
||||||
raise fut.error
|
raise fut.error
|
||||||
|
|
||||||
|
let peerIdMa = MultiAddress.init(multiCodec("p2p"), s.peerInfo.peerId).tryGet()
|
||||||
for t in s.transports: # for each transport
|
for t in s.transports: # for each transport
|
||||||
if t.addrs.len > 0 or t.running:
|
if t.addrs.len > 0 or t.running:
|
||||||
s.acceptFuts.add(s.accept(t))
|
s.acceptFuts.add(s.accept(t))
|
||||||
s.peerInfo.listenAddrs &= t.addrs
|
let addrs = t.addrs.mapIt(it.concat(peerIdMa).tryget())
|
||||||
|
s.peerInfo.listenAddrs &= addrs
|
||||||
|
|
||||||
await s.peerInfo.update()
|
await s.peerInfo.update()
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user