mirror of
https://github.com/status-im/nimbus-eth2.git
synced 2025-01-25 05:49:26 +00:00
3d7bee8502
This refactoring puts the JSON-RPC and REST APIs on more equal footing by renaming and moving things around, creating a separation between client and server, and documenting what they are - the aim is to have a simple-to-use base to start from when developing API clients, as well as make it easier to navigate the code when looking for the legacy JSON-RPC interface vs the new REST API. * move REST client, serialization and supporting types to spec/eth2_apis * REST stuff now starts with `rest_`, JSON-RPC stuff starts with `rpc_`, more or less * simplify imports such that there's a simple module to import for both server and client * map REST type and proc names to yaml spec more closely - in particular, reuse operation and type names in `rest_types` to make comparisons against spec more easy * cleaner separation between client and server modules - modules common between server and client such as `rest_types` and serialization move to the spec folder - this allows the client to be built with less knowledge about server internals
34 lines
1.2 KiB
Nim
34 lines
1.2 KiB
Nim
# beacon_chain
|
|
# Copyright (c) 2018-2021 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
|
|
std/sequtils,
|
|
json_rpc/servers/httpserver,
|
|
chronicles,
|
|
../version, ../beacon_node_common,
|
|
../networking/[eth2_network, peer_pool],
|
|
../spec/datatypes/phase0,
|
|
../spec/[digest, presets],
|
|
./rpc_utils
|
|
|
|
logScope: topics = "debugapi"
|
|
|
|
type
|
|
RpcServer = RpcHttpServer
|
|
|
|
proc installDebugApiHandlers*(rpcServer: RpcServer, node: BeaconNode) {.
|
|
raises: [Exception].} = # TODO fix json-rpc
|
|
rpcServer.rpc("get_v1_debug_beacon_states_stateId") do (
|
|
stateId: string) -> phase0.BeaconState:
|
|
withStateForStateId(stateId):
|
|
return stateData.data.hbsPhase0.data
|
|
|
|
rpcServer.rpc("get_v1_debug_beacon_heads") do () -> seq[tuple[root: Eth2Digest, slot: Slot]]:
|
|
return node.dag.heads.mapIt((it.root, it.slot))
|