2024-06-28 10:34:57 +00:00
|
|
|
{.push raises: [].}
|
2023-10-05 12:00:09 +00:00
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
import libp2p/[peerinfo, switch]
|
2023-10-05 12:00:09 +00:00
|
|
|
|
2024-03-15 23:08:47 +00:00
|
|
|
import ./peers
|
2023-10-05 12:00:09 +00:00
|
|
|
|
|
|
|
proc constructMultiaddrStr*(wireaddr: MultiAddress, peerId: PeerId): string =
|
|
|
|
# Constructs a multiaddress with both wire address and p2p identity
|
|
|
|
return $wireaddr & "/p2p/" & $peerId
|
|
|
|
|
|
|
|
proc constructMultiaddrStr*(peerInfo: PeerInfo): string =
|
|
|
|
# Constructs a multiaddress with both location (wire) address and p2p identity
|
|
|
|
if peerInfo.listenAddrs.len == 0:
|
|
|
|
return ""
|
|
|
|
return constructMultiaddrStr(peerInfo.listenAddrs[0], peerInfo.peerId)
|
|
|
|
|
|
|
|
proc constructMultiaddrStr*(remotePeerInfo: RemotePeerInfo): string =
|
|
|
|
# Constructs a multiaddress with both location (wire) address and p2p identity
|
|
|
|
if remotePeerInfo.addrs.len == 0:
|
|
|
|
return ""
|
|
|
|
return constructMultiaddrStr(remotePeerInfo.addrs[0], remotePeerInfo.peerId)
|