Address issue #5758. (#5762)

This commit is contained in:
Eugene Kabanov 2024-01-20 01:34:11 +02:00 committed by GitHub
parent 3ff9b69bf1
commit 10dbd773c7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 15 additions and 11 deletions

View File

@ -44,6 +44,19 @@ proc validateBeaconApiQueries*(key: string, value: string): int =
else:
1
const
AllValidatorFilterKinds = {
ValidatorFilterKind.PendingInitialized,
ValidatorFilterKind.PendingQueued,
ValidatorFilterKind.ActiveOngoing,
ValidatorFilterKind.ActiveExiting,
ValidatorFilterKind.ActiveSlashed,
ValidatorFilterKind.ExitedUnslashed,
ValidatorFilterKind.ExitedSlashed,
ValidatorFilterKind.WithdrawalPossible,
ValidatorFilterKind.WithdrawalDone
}
proc validateFilter(filters: seq[ValidatorFilter]): Result[ValidatorFilter,
cstring] =
var res: ValidatorFilter
@ -51,17 +64,8 @@ proc validateFilter(filters: seq[ValidatorFilter]): Result[ValidatorFilter,
if res * item != {}:
return err("Validator status must be unique")
res.incl(item)
if res == {}:
res = {ValidatorFilterKind.PendingInitialized,
ValidatorFilterKind.PendingQueued,
ValidatorFilterKind.ActiveOngoing,
ValidatorFilterKind.ActiveExiting,
ValidatorFilterKind.ActiveSlashed,
ValidatorFilterKind.ExitedUnslashed,
ValidatorFilterKind.ExitedSlashed,
ValidatorFilterKind.WithdrawalPossible,
ValidatorFilterKind.WithdrawalDone}
return ok(AllValidatorFilterKinds)
ok(res)
proc getStatus(validator: Validator,
@ -413,7 +417,7 @@ proc installBeaconApiHandlers*(router: var RestRouter, node: BeaconNode) =
Http400, InvalidRequestBodyError, $error)
let
ids = request.ids.valueOr: @[]
filter = request.status.valueOr: {}
filter = request.status.valueOr: AllValidatorFilterKinds
(ids, filter)
sid = state_id.valueOr:
return RestApiResponse.jsonError(Http400, InvalidStateIdValueError,