Fix /api/eth/v1/node/peers arguments handling.
Fix maximum Epoch handling.
This commit is contained in:
parent
23b2e663f1
commit
c56cb0a485
|
@ -487,7 +487,11 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
if repoch.isErr():
|
||||
return RestApiResponse.jsonError(Http400, "Invalid epoch value",
|
||||
$repoch.error())
|
||||
some(repoch.get())
|
||||
let res = repoch.get()
|
||||
if res > MaxEpoch:
|
||||
return RestApiResponse.jsonError(Http400, "Requesting epoch for " &
|
||||
"which slot would overflow")
|
||||
some(res)
|
||||
else:
|
||||
none[Epoch]()
|
||||
let vindex =
|
||||
|
|
|
@ -157,15 +157,15 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
)
|
||||
|
||||
router.api(MethodGet, "/api/eth/v1/node/peers") do (
|
||||
states: seq[PeerStateKind],
|
||||
directions: seq[PeerDirectKind]) -> RestApiResponse:
|
||||
state: seq[PeerStateKind],
|
||||
direction: seq[PeerDirectKind]) -> RestApiResponse:
|
||||
let connectionMask =
|
||||
block:
|
||||
if states.isErr():
|
||||
if state.isErr():
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
"Invalid state value(s)",
|
||||
$states.error())
|
||||
let sres = validateState(states.get())
|
||||
$state.error())
|
||||
let sres = validateState(state.get())
|
||||
if sres.isErr():
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
"Invalid state value(s)",
|
||||
|
@ -173,11 +173,11 @@ proc installNodeApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
sres.get()
|
||||
let directionMask =
|
||||
block:
|
||||
if directions.isErr():
|
||||
if direction.isErr():
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
"Invalid direction value(s)",
|
||||
$directions.error())
|
||||
let dres = validateDirection(directions.get())
|
||||
$direction.error())
|
||||
let dres = validateDirection(direction.get())
|
||||
if dres.isErr():
|
||||
return RestApiResponse.jsonError(Http400,
|
||||
"Invalid direction value(s)",
|
||||
|
|
|
@ -59,7 +59,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
return RestApiResponse.jsonError(Http400, "Incorrect epoch value",
|
||||
$epoch.error())
|
||||
let res = epoch.get()
|
||||
if res >= MaxEpoch:
|
||||
if res > MaxEpoch:
|
||||
return RestApiResponse.jsonError(Http400, "Requesting epoch for " &
|
||||
"which slot would overflow")
|
||||
res
|
||||
|
@ -129,7 +129,7 @@ proc installValidatorApiHandlers*(router: var RestRouter, node: BeaconNode) =
|
|||
return RestApiResponse.jsonError(Http400, "Incorrect epoch value",
|
||||
$epoch.error())
|
||||
let res = epoch.get()
|
||||
if res >= MaxEpoch:
|
||||
if res > MaxEpoch:
|
||||
return RestApiResponse.jsonError(Http400, "Requesting epoch for " &
|
||||
"which slot would overflow")
|
||||
res
|
||||
|
|
Loading…
Reference in New Issue