mirror of
https://gitlab.com/pulsechaincom/prysm-pulse.git
synced 2024-12-31 23:41:22 +00:00
38 lines
1.1 KiB
Go
38 lines
1.1 KiB
Go
|
package validator
|
||
|
|
||
|
import (
|
||
|
"context"
|
||
|
|
||
|
ptypes "github.com/gogo/protobuf/types"
|
||
|
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1"
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/exit"
|
||
|
"github.com/prysmaticlabs/prysm/beacon-chain/core/feed"
|
||
|
opfeed "github.com/prysmaticlabs/prysm/beacon-chain/core/feed/operation"
|
||
|
"google.golang.org/grpc/codes"
|
||
|
"google.golang.org/grpc/status"
|
||
|
)
|
||
|
|
||
|
// ProposeExit proposes an exit for a validator.
|
||
|
func (vs *Server) ProposeExit(ctx context.Context, req *ethpb.SignedVoluntaryExit) (*ptypes.Empty, error) {
|
||
|
s, err := vs.HeadFetcher.HeadState(ctx)
|
||
|
if err != nil {
|
||
|
return nil, status.Errorf(codes.Internal, "Could not get head state: %v", err)
|
||
|
}
|
||
|
|
||
|
// Confirm the validator is eligible to exit with the parameters provided.
|
||
|
err = exit.ValidateVoluntaryExit(s, vs.GenesisTime, req)
|
||
|
if err != nil {
|
||
|
return nil, status.Error(codes.InvalidArgument, err.Error())
|
||
|
}
|
||
|
|
||
|
// Send the voluntary exit to the operation feed.
|
||
|
vs.OperationNotifier.OperationFeed().Send(&feed.Event{
|
||
|
Type: opfeed.ExitReceived,
|
||
|
Data: &opfeed.ExitReceivedData{
|
||
|
Exit: req,
|
||
|
},
|
||
|
})
|
||
|
|
||
|
return nil, nil
|
||
|
}
|