Perform normalization of `last_libp2p_address`.
This commit is contained in:
parent
4f7e76137f
commit
af9e626fb1
|
@ -35,6 +35,17 @@ RestJson.useDefaultSerializationFor(
|
||||||
RestNodePeerCount,
|
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,
|
proc validateState(states: seq[PeerStateKind]): Result[ConnectionStateSet,
|
||||||
cstring] =
|
cstring] =
|
||||||
var res: set[ConnectionState]
|
var res: set[ConnectionState]
|
||||||
|
@ -181,7 +192,9 @@ proc getLastSeenAddress(node: BeaconNode, id: PeerId): string =
|
||||||
|
|
||||||
if len(temp) > 0:
|
if len(temp) > 0:
|
||||||
sort(temp, compare, SortOrder.Ascending)
|
sort(temp, compare, SortOrder.Ascending)
|
||||||
$temp[0].address
|
let res = normalize(temp[0].address, id).valueOr:
|
||||||
|
return ""
|
||||||
|
$res
|
||||||
else:
|
else:
|
||||||
""
|
""
|
||||||
|
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 8855bce0854ecf4adad7a0556bb2b2d2f98e0e20
|
Subproject commit a70d65dd4f33a52471c07f07e3fe1d65f82996ba
|
Loading…
Reference in New Issue