Skip to content

Commit

Permalink
Eliminate rpc_types.nim usage. (status-im#3692)
Browse files Browse the repository at this point in the history
  • Loading branch information
cheatfate authored Jun 2, 2022
1 parent ce143a1 commit 50f9596
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 35 deletions.
10 changes: 5 additions & 5 deletions beacon_chain/rpc/rest_node_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))))
Expand Down
26 changes: 0 additions & 26 deletions beacon_chain/spec/eth2_apis/rpc_types.nim

This file was deleted.

6 changes: 3 additions & 3 deletions beacon_chain/sync/sync_manager.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion beacon_chain/sync/sync_queue.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 50f9596

Please sign in to comment.