status-lib/status/signals/peerstats.nim
Iuri Matias 2bb5df3c5f
feat: wakuv2 connectivity and peer management (#17)
* wakuv2 connectivity and peer management

* feat: wakuv2 light client (#15)

Co-authored-by: Richard Ramos <info@richardramos.me>
2021-09-30 14:56:22 -04:00

15 lines
444 B
Nim

import json
import base
import signal_type
type PeerStatsSignal* = ref object of Signal
peers*: seq[string]
proc fromEvent*(T: type PeerStatsSignal, jsonSignal: JsonNode): PeerStatsSignal =
result = PeerStatsSignal()
result.signalType = SignalType.PeerStats
if jsonSignal["event"].kind != JNull:
for (node, protocols) in jsonSignal["event"]["peers"].pairs():
if protocols.getElems.len != 0:
result.peers.add(node)