Skip to content

Commit

Permalink
Address review comment.
Browse files Browse the repository at this point in the history
  • Loading branch information
cheatfate committed Feb 13, 2022
1 parent b8b7753 commit b379a87
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions beacon_chain/rpc/rest_beacon_api.nim
Original file line number Diff line number Diff line change
Expand Up @@ -757,22 +757,9 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError,
$res.error())
var forked = ForkedSignedBeaconBlock(res.get())

case forked.kind
of BeaconBlockFork.Phase0:
let epoch = forked.phase0Data.message.slot.epoch()
if not((epoch < node.dag.cfg.ALTAIR_FORK_EPOCH) and
(epoch < node.dag.cfg.BELLATRIX_FORK_EPOCH)):
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)
of BeaconBlockFork.Altair:
let epoch = forked.altairData.message.slot.epoch()
if not((epoch >= node.dag.cfg.ALTAIR_FORK_EPOCH) and
(epoch < node.dag.cfg.BELLATRIX_FORK_EPOCH)):
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)
of BeaconBlockFork.Bellatrix:
let epoch = forked.bellatrixData.message.slot.epoch()
if not(epoch >= node.dag.cfg.BELLATRIX_FORK_EPOCH):
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)
if forked.kind != node.dag.cfg.blockForkAtEpoch(
getForkedBlockField(forked, slot).epoch):
return RestApiResponse.jsonError(Http400, InvalidBlockObjectError)

withBlck(forked):
blck.root = hash_tree_root(blck.message)
Expand Down

0 comments on commit b379a87

Please sign in to comment.