mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-05 17:22:18 +00:00
190d862552
* Return status.Errorf instead of plain errors from gRPC functions * return plain errors from helper functions * change errors to lowercase in node * correct test expectations * extracted StateFetcher * StateFetcher tests * extract beacon state creation option and fix state tests * add comment to StateFetcher * register the server * implement grpc function * test ToProto * gRPC function test with mock state fetcher * reduce visibility of packages * add missing error assertion * removed unused code * overwrite config name * gzl * Fix service fields * rename StateFetcher to Provider * Update beacon-chain/state/stateV0/state_trie.go Co-authored-by: Raul Jordan <raul@prysmaticlabs.com> * adjust code to new v0 interfaces * interface/struct naming changes Co-authored-by: prylabs-bulldozer[bot] <58059840+prylabs-bulldozer[bot]@users.noreply.github.com> Co-authored-by: Raul Jordan <raul@prysmaticlabs.com>
34 lines
1017 B
Go
34 lines
1017 B
Go
package debugv1
|
|
|
|
import (
|
|
"context"
|
|
|
|
ptypes "github.com/gogo/protobuf/types"
|
|
"github.com/pkg/errors"
|
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
)
|
|
|
|
// GetBeaconState returns the full beacon state for a given state id.
|
|
func (ds *Server) GetBeaconState(ctx context.Context, req *ethpb.StateRequest) (*ethpb.BeaconStateResponse, error) {
|
|
state, err := ds.StateFetcher.State(ctx, req.StateId)
|
|
if err != nil {
|
|
return nil, status.Errorf(codes.Internal, "could not get state: %v", err)
|
|
}
|
|
|
|
protoState, err := state.ToProto()
|
|
if err != nil {
|
|
return nil, status.Errorf(codes.Internal, "could not convert state to proto: %v", err)
|
|
}
|
|
|
|
return ðpb.BeaconStateResponse{
|
|
Data: protoState,
|
|
}, nil
|
|
}
|
|
|
|
// ListForkChoiceHeads retrieves the fork choice leaves for the current head.
|
|
func (ds *Server) ListForkChoiceHeads(ctx context.Context, _ *ptypes.Empty) (*ethpb.ForkChoiceHeadsResponse, error) {
|
|
return nil, errors.New("unimplemented")
|
|
}
|