mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2025-01-08 10:41:19 +00:00
5aac06f04e
* begin move * use same import path * imports * regen protos * regen * no rename * generate ssz * gaz * fmt * edit build file * imports * modify * remove generated files * remove protos * edit imports in prysm * beacon chain all builds * edit script * add generated pbs * add replace rules * license for ethereumapis protos * change visibility * fmt * update build files to gaz ignore * use proper form * edit imports * wrap block * revert scripts * revert go mod
55 lines
1.6 KiB
Go
55 lines
1.6 KiB
Go
package debugv1
|
|
|
|
import (
|
|
"context"
|
|
|
|
ethpb "github.com/prysmaticlabs/prysm/proto/eth/v1"
|
|
"go.opencensus.io/trace"
|
|
"google.golang.org/grpc/codes"
|
|
"google.golang.org/grpc/status"
|
|
"google.golang.org/protobuf/types/known/emptypb"
|
|
)
|
|
|
|
// GetBeaconState returns the full beacon state for a given state id.
|
|
func (ds *Server) GetBeaconState(ctx context.Context, req *ethpb.StateRequest) (*ethpb.BeaconStateResponse, error) {
|
|
ctx, span := trace.StartSpan(ctx, "beaconv1.GetBeaconState")
|
|
defer span.End()
|
|
|
|
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
|
|
}
|
|
|
|
func (ds *Server) GetBeaconStateSsz(ctx context.Context, req *ethpb.StateRequest) (*ethpb.BeaconStateSszResponse, error) {
|
|
return nil, status.Error(codes.Unimplemented, "Unimplemented")
|
|
}
|
|
|
|
// ListForkChoiceHeads retrieves the fork choice leaves for the current head.
|
|
func (ds *Server) ListForkChoiceHeads(ctx context.Context, _ *emptypb.Empty) (*ethpb.ForkChoiceHeadsResponse, error) {
|
|
ctx, span := trace.StartSpan(ctx, "debugv1.ListForkChoiceHeads")
|
|
defer span.End()
|
|
|
|
headRoots, headSlots := ds.HeadFetcher.ChainHeads()
|
|
resp := ðpb.ForkChoiceHeadsResponse{
|
|
Data: make([]*ethpb.ForkChoiceHead, len(headRoots)),
|
|
}
|
|
for i := range headRoots {
|
|
resp.Data[i] = ðpb.ForkChoiceHead{
|
|
Root: headRoots[i][:],
|
|
Slot: headSlots[i],
|
|
}
|
|
}
|
|
|
|
return resp, nil
|
|
}
|