func (s *State) ApplyExit(exit Exit, config *config.Config) error {
	validator := s.ValidatorRegistry[exit.ValidatorIndex]
	if validator.Status != Active {
		return errors.New("validator with exit is not active")
	}

	if s.Slot < exit.Slot {
		return errors.New("exit is not yet valid")
	}

	validatorPub, err := validator.GetPublicKey()
	if err != nil {
		return err
	}

	exitSig, err := bls.DeserializeSignature(exit.Signature)
	if err != nil {
		return err
	}

	valid, err := bls.VerifySig(validatorPub, zeroHash[:], exitSig, bls.DomainExit)
	if err != nil {
		return err
	}

	if !valid {
		return errors.New("signature is not valid")
	}

	err = s.UpdateValidatorStatus(uint32(exit.ValidatorIndex), ActivePendingExit, config)
	if err != nil {
		return err
	}

	return nil
}
// ApplyExit validates and applies an exit.
ApplyExit validates and applies an exit.
// ApplyExit validates and applies an exit .
func (s *State) ApplyExit(exit Exit, config *config.Config) error {
	validator := s.ValidatorRegistry[exit.ValidatorIndex]
	if validator.Status != Active {
		return errors.New("validator with exit is not active")
	}
	if s.Slot < exit.Slot {
		return errors.New("exit is not yet valid")
	}
	validatorPub, err := validator.GetPublicKey()
	if err != nil {
		return err
	}
	exitSig, err := bls.DeserializeSignature(exit.Signature)
	if err != nil {
		return err
	}
	valid, err := bls.VerifySig(validatorPub, zeroHash[:], exitSig, bls.DomainExit)
	if err != nil {
		return err
	}
	if !valid {
		return errors.New("signature is not valid")
	}
	err = s.UpdateValidatorStatus(uint32(exit.ValidatorIndex), ActivePendingExit, config)
	if err != nil {
		return err
	}
	return nil
}
func ( s * State ) ApplyExit ( exit Exit , config * config . Config ) error { validator := s . ValidatorRegistry [ exit . ValidatorIndex ] if validator . Status != Active { return errors . New ( " " ) } if s . Slot < exit . Slot { return errors . New ( " " ) } validatorPub , err := validator . GetPublicKey ( ) if err != nil { return err } exitSig , err := bls . DeserializeSignature ( exit . Signature ) if err != nil { return err } valid , err := bls . VerifySig ( validatorPub , zeroHash [ : ] , exitSig , bls . DomainExit ) if err != nil { return err } if ! valid { return errors . New ( " " ) } err = s . UpdateValidatorStatus ( uint32 ( exit . ValidatorIndex ) , ActivePendingExit , config ) if err != nil { return err } return nil }
ApplyExit validates and applies an exit.
ApplyExit validates and applies an exit .