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