Fix /api/eth/v1/node/peer_count response.

This commit is contained in:
cheatfate 2021-04-04 01:41:46 +03:00 committed by zah
parent 5885068c63
commit 55cbb82ab5
1 changed files with 7 additions and 1 deletions

View File

@ -17,6 +17,12 @@ type
ConnectionStateSet* = set[ConnectionState]
PeerTypeSet* = set[PeerType]
RestNodePeerCountTuple* = tuple
disconnected: uint64
connecting: uint64
connected: uint64
disconnecting: uint64
proc validateState(states: seq[PeerStateKind]): Result[ConnectionStateSet,
cstring] =
var res: set[ConnectionState]
@ -195,7 +201,7 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
return RestApiResponse.jsonResponse(res)
router.api(MethodGet, "/api/eth/v1/node/peer_count") do () -> RestApiResponse:
var res: NodePeerCountTuple
var res: RestNodePeerCountTuple
for item in node.network.peers.values():
case item.connectionState
of Connecting: