mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 02:31:19 +00:00
e22258caa9
* GetValidators in progress * in progress * completed implementation of GetValidators + some tests * typo * completed tests for GetValidators * GetValidator * GetValidatorBalances * register * more tests and e2e fix * middleware cleanup * remove struct * handle all ignored * test fixes * more test fixes * even more test fixes * remove unused structs * docs * fix validator count test * build fix * add length checks * lint fix --------- Co-authored-by: james-prysm <90280386+james-prysm@users.noreply.github.com>
37 lines
1.3 KiB
Go
37 lines
1.3 KiB
Go
package helpers
|
|
|
|
import (
|
|
"errors"
|
|
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/rpc/lookup"
|
|
"github.com/prysmaticlabs/prysm/v4/beacon-chain/state/stategen"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// PrepareStateFetchGRPCError returns an appropriate gRPC error based on the supplied argument.
|
|
// The argument error should be a result of fetching state.
|
|
func PrepareStateFetchGRPCError(err error) error {
|
|
if errors.Is(err, stategen.ErrNoDataForSlot) {
|
|
return status.Errorf(codes.NotFound, "lacking historical data needed to fulfill request")
|
|
}
|
|
if stateNotFoundErr, ok := err.(*lookup.StateNotFoundError); ok {
|
|
return status.Errorf(codes.NotFound, "State not found: %v", stateNotFoundErr)
|
|
}
|
|
if parseErr, ok := err.(*lookup.StateIdParseError); ok {
|
|
return status.Errorf(codes.InvalidArgument, "Invalid state ID: %v", parseErr)
|
|
}
|
|
return status.Errorf(codes.Internal, "Invalid state ID: %v", err)
|
|
}
|
|
|
|
// IndexedVerificationFailure represents a collection of verification failures.
|
|
type IndexedVerificationFailure struct {
|
|
Failures []*SingleIndexedVerificationFailure `json:"failures"`
|
|
}
|
|
|
|
// SingleIndexedVerificationFailure represents an issue when verifying a single indexed object e.g. an item in an array.
|
|
type SingleIndexedVerificationFailure struct {
|
|
Index int `json:"index"`
|
|
Message string `json:"message"`
|
|
}
|