removed 2 buggy RPC API endpoints - there are 2 well functioning ones in validator_api.nim anyway (#1867)

This commit is contained in:
Viktor Kirilov 2020-10-15 15:26:59 +03:00 committed by GitHub
parent bcd9088114
commit 4e73d10f86
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 47 deletions

View File

@ -719,44 +719,6 @@ proc installBeaconApiHandlers(rpcServer: RpcServer, node: BeaconNode) =
raise newException(CatchableError,
"Please specify one of " & astToStr(x) & " or " & astToStr(y))
template jsonResult(x: auto): auto =
StringOfJson(Json.encode(x))
rpcServer.rpc("getBeaconBlock") do (slot: Option[Slot],
root: Option[Eth2Digest]) -> StringOfJson:
requireOneOf(slot, root)
var blockHash: Eth2Digest
if root.isSome:
blockHash = root.get
else:
let foundRef = node.chainDag.getBlockByPreciseSlot(slot.get)
if foundRef != nil:
blockHash = foundRef.root
else:
return StringOfJson("null")
let dbBlock = node.db.getBlock(blockHash)
if dbBlock.isSome:
return jsonResult(dbBlock.get)
else:
return StringOfJson("null")
rpcServer.rpc("getBeaconState") do (slot: Option[Slot],
root: Option[Eth2Digest]) -> StringOfJson:
requireOneOf(slot, root)
if slot.isSome:
# TODO sanity check slot so that it doesn't cause excessive rewinding
let blk = node.chainDag.head.atSlot(slot.get)
node.chainDag.withState(node.chainDag.tmpState, blk):
return jsonResult(state)
else:
let tmp = BeaconStateRef() # TODO use tmpState - but load the entire StateData!
let state = node.db.getState(root.get, tmp[], noRollback)
if state:
return jsonResult(tmp[])
else:
return StringOfJson("null")
rpcServer.rpc("getNetworkPeerId") do () -> string:
return $publicKey(node.network)

View File

@ -63,13 +63,8 @@ proc get_v1_config_fork_schedule(): seq[tuple[epoch: uint64, version: Version]]
proc get_v1_debug_beacon_states_stateId(stateId: string): BeaconState
# TODO: delete old stuff
# https://github.com/ethereum/eth2.0-APIs/blob/master/apis/beacon/basic.md
#
proc getBeaconHead(): Slot
proc getBeaconBlock(slot = none(Slot), root = none(Eth2Digest)): BeaconBlock
proc getBeaconState(slot = none(Slot), root = none(Eth2Digest)): BeaconState
proc getNetworkPeerId()
proc getNetworkPeers()
proc getNetworkEnr()

View File

@ -42,10 +42,6 @@ curl -d '{"jsonrpc":"2.0","id":"id","method":"getChainHead","params":[] }' -H 'C
### getSyncing
### getBeaconBlock
### getBeaconState
### getNetworkPeerId
### getNetworkPeers