diff --git a/beacon_chain/rpc/rest_node_api.nim b/beacon_chain/rpc/rest_node_api.nim index 80481ab7a..84df78639 100644 --- a/beacon_chain/rpc/rest_node_api.nim +++ b/beacon_chain/rpc/rest_node_api.nim @@ -35,6 +35,17 @@ RestJson.useDefaultSerializationFor( RestNodePeerCount, ) +proc normalize*(address: MultiAddress, value: PeerId): MaResult[MultiAddress] = + ## Checks if `address` has `p2p` suffix, and if not add it. + let + protos = ? address.protocols() + index = protos.find(multiCodec("p2p")) + if index == -1: + let suffix = ? MultiAddress.init(multiCodec("p2p"), value) + concat(address, suffix) + else: + ok(address) + proc validateState(states: seq[PeerStateKind]): Result[ConnectionStateSet, cstring] = var res: set[ConnectionState] @@ -181,7 +192,9 @@ proc getLastSeenAddress(node: BeaconNode, id: PeerId): string = if len(temp) > 0: sort(temp, compare, SortOrder.Ascending) - $temp[0].address + let res = normalize(temp[0].address, id).valueOr: + return "" + $res else: "" diff --git a/vendor/nim-libp2p b/vendor/nim-libp2p index 8855bce08..a70d65dd4 160000 --- a/vendor/nim-libp2p +++ b/vendor/nim-libp2p @@ -1 +1 @@ -Subproject commit 8855bce0854ecf4adad7a0556bb2b2d2f98e0e20 +Subproject commit a70d65dd4f33a52471c07f07e3fe1d65f82996ba