mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-13 00:05:10 +00:00
7b5c36b1c6
/admin rest api implementation and tests * open api doc * Add rest admin test to all tests * Enrich /admin get peers interface, group protocols by peers in response
28 lines
881 B
Nim
28 lines
881 B
Nim
when (NimMajor, NimMinor) < (1, 4):
|
|
{.push raises: [Defect].}
|
|
else:
|
|
{.push raises: [].}
|
|
|
|
import
|
|
libp2p/[peerinfo, switch]
|
|
|
|
import
|
|
./peers
|
|
|
|
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)
|
|
|