Eliminate rpc_types.nim usage. (#3692)
This commit is contained in:
parent
ce143a1078
commit
50f9596108
|
@ -7,7 +7,6 @@ import
|
|||
../version, ../beacon_node, ../sync/sync_manager,
|
||||
../networking/[eth2_network, peer_pool],
|
||||
../spec/datatypes/base,
|
||||
../spec/eth2_apis/rpc_types,
|
||||
./rest_utils
|
||||
|
||||
export rest_utils
|
||||
|
@ -190,18 +189,19 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
$dres.error())
|
||||
dres.get()
|
||||
|
||||
var res: seq[RpcNodePeer]
|
||||
var res: seq[RestNodePeer]
|
||||
for peer in node.network.peers.values():
|
||||
if (peer.connectionState in connectionMask) and
|
||||
(peer.direction in directionMask):
|
||||
let peer = (
|
||||
let peer = RestNodePeer(
|
||||
peer_id: $peer.peerId,
|
||||
enr: if peer.enr.isSome(): peer.enr.get().toURI() else: "",
|
||||
last_seen_p2p_address: getLastSeenAddress(node, peer.peerId),
|
||||
state: peer.connectionState.toString(),
|
||||
direction: peer.direction.toString(),
|
||||
agent: node.network.switch.peerStore.agentBook.get(peer.peerId), # Fields `agent` and `proto` are not
|
||||
proto: node.network.switch.peerStore.protoVersionBook.get(peer.peerId) # part of specification
|
||||
# Fields `agent` and `proto` are not part of specification
|
||||
agent: node.network.switch.peerStore.agentBook.get(peer.peerId),
|
||||
proto: node.network.switch.peerStore.protoVersionBook.get(peer.peerId)
|
||||
)
|
||||
res.add(peer)
|
||||
return RestApiResponse.jsonResponseWMeta(res, (count: uint64(len(res))))
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
# beacon_chain
|
||||
# Copyright (c) 2018-2022 Status Research & Development GmbH
|
||||
# Licensed and distributed under either of
|
||||
# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT).
|
||||
# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0).
|
||||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
{.push raises: [Defect].}
|
||||
|
||||
import ../datatypes/base
|
||||
export base
|
||||
|
||||
type
|
||||
RpcNodePeer* = tuple
|
||||
peer_id: string
|
||||
enr: string
|
||||
last_seen_p2p_address: string
|
||||
state: string
|
||||
direction: string
|
||||
agent: string # This is not part of specification
|
||||
proto: string # This is not part of specification
|
||||
|
||||
RpcSyncInfo* = tuple
|
||||
head_slot: Slot
|
||||
sync_distance: uint64
|
||||
is_syncing: bool
|
|
@ -11,7 +11,7 @@ import std/[options, heapqueue, tables, strutils, sequtils, algorithm]
|
|||
import stew/[results, base10], chronos, chronicles
|
||||
import
|
||||
../spec/datatypes/[phase0, altair],
|
||||
../spec/eth2_apis/rpc_types,
|
||||
../spec/eth2_apis/rest_types,
|
||||
../spec/[helpers, forks],
|
||||
../networking/[peer_pool, peer_scores, eth2_network],
|
||||
../beacon_clock,
|
||||
|
@ -659,12 +659,12 @@ proc start*[A, B](man: SyncManager[A, B]) =
|
|||
## Starts SyncManager's main loop.
|
||||
man.syncFut = man.syncLoop()
|
||||
|
||||
proc getInfo*[A, B](man: SyncManager[A, B]): RpcSyncInfo =
|
||||
proc getInfo*[A, B](man: SyncManager[A, B]): RestSyncInfo =
|
||||
## Returns current synchronization information for RPC call.
|
||||
let wallSlot = man.getLocalWallSlot()
|
||||
let headSlot = man.getLocalHeadSlot()
|
||||
let sync_distance = wallSlot - headSlot
|
||||
(
|
||||
RestSyncInfo(
|
||||
head_slot: headSlot,
|
||||
sync_distance: sync_distance,
|
||||
is_syncing: man.inProgress
|
||||
|
|
|
@ -11,7 +11,6 @@ import std/[options, heapqueue, tables, strutils, sequtils, math, algorithm]
|
|||
import stew/[results, base10], chronos, chronicles
|
||||
import
|
||||
../spec/datatypes/[base, phase0, altair],
|
||||
../spec/eth2_apis/rpc_types,
|
||||
../spec/[helpers, forks],
|
||||
../networking/[peer_pool, eth2_network],
|
||||
../gossip_processing/block_processor,
|
||||
|
|
Loading…
Reference in New Issue