mirror of
https://github.com/waku-org/nwaku.git
synced 2025-01-13 08:14:43 +00:00
beb21c78f4
* Fix receiver exit criteria, not let it wait forever in some cases, added a timely check from the last arrived message * Extend dial and service usage failure metrics with agent string to reveal service nodes origins * Adjusted infra testing content topic to be unique in the system * Extend error logs with peer's agent string, fix exit criteria * Add informative log for not waiting for more messages * Add unknown as default for empty agent identifier * better explain exit logic of receiver * Address review comment - checking for last message arrival return Optional Moment instead of result - better explains what is happening.
79 lines
2.6 KiB
Nim
79 lines
2.6 KiB
Nim
when (NimMajor, NimMinor) < (1, 4):
|
|
{.push raises: [Defect].}
|
|
else:
|
|
{.push raises: [].}
|
|
|
|
import
|
|
std/[options, net, strformat],
|
|
chronicles,
|
|
chronos,
|
|
metrics,
|
|
libbacktrace,
|
|
libp2p/crypto/crypto,
|
|
confutils,
|
|
libp2p/wire
|
|
|
|
import
|
|
waku/[
|
|
factory/external_config,
|
|
node/peer_manager,
|
|
waku_lightpush/common,
|
|
waku_relay,
|
|
waku_filter_v2,
|
|
waku_peer_exchange/protocol,
|
|
waku_core/multiaddrstr,
|
|
waku_enr/capabilities,
|
|
]
|
|
logScope:
|
|
topics = "diagnose connections"
|
|
|
|
proc `$`*(cap: Capabilities): string =
|
|
case cap
|
|
of Capabilities.Relay:
|
|
return "Relay"
|
|
of Capabilities.Store:
|
|
return "Store"
|
|
of Capabilities.Filter:
|
|
return "Filter"
|
|
of Capabilities.Lightpush:
|
|
return "Lightpush"
|
|
of Capabilities.Sync:
|
|
return "Sync"
|
|
|
|
proc allPeers(pm: PeerManager): string =
|
|
var allStr: string = ""
|
|
for idx, peer in pm.wakuPeerStore.peers():
|
|
allStr.add(
|
|
" " & $idx & ". | " & constructMultiaddrStr(peer) & " | agent: " &
|
|
peer.getAgent() & " | protos: " & $peer.protocols & " | caps: " &
|
|
$peer.enr.map(getCapabilities) & "\n"
|
|
)
|
|
return allStr
|
|
|
|
proc logSelfPeers*(pm: PeerManager) =
|
|
let selfLighpushPeers = pm.wakuPeerStore.getPeersByProtocol(WakuLightPushCodec)
|
|
let selfRelayPeers = pm.wakuPeerStore.getPeersByProtocol(WakuRelayCodec)
|
|
let selfFilterPeers = pm.wakuPeerStore.getPeersByProtocol(WakuFilterSubscribeCodec)
|
|
let selfPxPeers = pm.wakuPeerStore.getPeersByProtocol(WakuPeerExchangeCodec)
|
|
|
|
let printable = catch:
|
|
"""*------------------------------------------------------------------------------------------*
|
|
| Self ({constructMultiaddrStr(pm.switch.peerInfo)}) peers:
|
|
*------------------------------------------------------------------------------------------*
|
|
| Lightpush peers({selfLighpushPeers.len()}): ${selfLighpushPeers}
|
|
*------------------------------------------------------------------------------------------*
|
|
| Filter peers({selfFilterPeers.len()}): ${selfFilterPeers}
|
|
*------------------------------------------------------------------------------------------*
|
|
| Relay peers({selfRelayPeers.len()}): ${selfRelayPeers}
|
|
*------------------------------------------------------------------------------------------*
|
|
| PX peers({selfPxPeers.len()}): ${selfPxPeers}
|
|
*------------------------------------------------------------------------------------------*
|
|
| All peers with protocol support:
|
|
{allPeers(pm)}
|
|
*------------------------------------------------------------------------------------------*""".fmt()
|
|
|
|
if printable.isErr():
|
|
echo "Error while printing statistics: " & printable.error().msg
|
|
else:
|
|
echo printable.get()
|