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,
|
||||
protobuf/minprotobuf, errors, utility
|
||||
import stew/[base58, base32, endians2, results]
|
||||
export results, minprotobuf, vbuffer, utility
|
||||
export results, minprotobuf, vbuffer, utility, multicodec
|
||||
|
||||
logScope:
|
||||
topics = "libp2p multiaddress"
|
||||
|
|
|
@ -163,12 +163,9 @@ proc expandWildcardAddresses(
|
|||
)
|
||||
addresses.add(wildcardAddresses)
|
||||
else:
|
||||
listenAddr.concat(peerIdMa).withValue(ma):
|
||||
addresses.add(ma)
|
||||
addresses.add(listenAddr)
|
||||
else:
|
||||
let suffixed = listenAddr.concat(peerIdMa).valueOr:
|
||||
continue
|
||||
addresses.add(suffixed)
|
||||
addresses.add(listenAddr)
|
||||
addresses
|
||||
|
||||
method setup*(
|
||||
|
|
|
@ -344,10 +344,12 @@ proc start*(s: Switch) {.async, public.} =
|
|||
await s.stop()
|
||||
raise fut.error
|
||||
|
||||
let peerIdMa = MultiAddress.init(multiCodec("p2p"), s.peerInfo.peerId).tryGet()
|
||||
for t in s.transports: # for each transport
|
||||
if t.addrs.len > 0 or t.running:
|
||||
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()
|
||||
|
||||
|
|
Loading…
Reference in New Issue