func (s *State) UpdateValidatorRegistry(c *config.Config) error {
	activeValidatorIndices := GetActiveValidatorIndices(s.ValidatorRegistry)
	totalBalance := s.GetTotalBalance(activeValidatorIndices, c)
	maxBalanceChurn := c.MaxDeposit
	if maxBalanceChurn < (totalBalance / (2 * c.MaxBalanceChurnQuotient)) {
		maxBalanceChurn = totalBalance / (2 * c.MaxBalanceChurnQuotient)
	}

	balanceChurn := uint64(0)
	for idx, validator := range s.ValidatorRegistry {
		index := uint32(idx)
		if validator.Status == PendingActivation && s.ValidatorBalances[index] >= c.MinDeposit {
			balanceChurn += s.GetEffectiveBalance(index, c)
			if balanceChurn > maxBalanceChurn {
				break
			}

			err := s.UpdateValidatorStatus(index, Active, c)
			if err != nil {
				return err
			}
		}
	}

	balanceChurn = 0
	for idx, validator := range s.ValidatorRegistry {
		index := uint32(idx)
		if validator.Status == ActivePendingExit {
			balanceChurn += s.GetEffectiveBalance(index, c)
			if balanceChurn > maxBalanceChurn {
				break
			}

			err := s.UpdateValidatorStatus(index, ExitedWithoutPenalty, c)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
// UpdateValidatorRegistry updates the registry and updates validator pending activation or exit.
UpdateValidatorRegistry updates the registry and updates validator pending activation or exit.
// UpdateValidatorRegistry updates the registry and updates validator pending activation or exit .
func (s *State) UpdateValidatorRegistry(c *config.Config) error {
	activeValidatorIndices := GetActiveValidatorIndices(s.ValidatorRegistry)
	totalBalance := s.GetTotalBalance(activeValidatorIndices, c)
	maxBalanceChurn := c.MaxDeposit
	if maxBalanceChurn < (totalBalance / (2 * c.MaxBalanceChurnQuotient)) {
		maxBalanceChurn = totalBalance / (2 * c.MaxBalanceChurnQuotient)
	}
	balanceChurn := uint64(0)
	for idx, validator := range s.ValidatorRegistry {
		index := uint32(idx)
		if validator.Status == PendingActivation && s.ValidatorBalances[index] >= c.MinDeposit {
			balanceChurn += s.GetEffectiveBalance(index, c)
			if balanceChurn > maxBalanceChurn {
				break
			}
			err := s.UpdateValidatorStatus(index, Active, c)
			if err != nil {
				return err
			}
		}
	}
	balanceChurn = 0
	for idx, validator := range s.ValidatorRegistry {
		index := uint32(idx)
		if validator.Status == ActivePendingExit {
			balanceChurn += s.GetEffectiveBalance(index, c)
			if balanceChurn > maxBalanceChurn {
				break
			}
			err := s.UpdateValidatorStatus(index, ExitedWithoutPenalty, c)
			if err != nil {
				return err
			}
		}
	}
	return nil
}
func ( s * State ) UpdateValidatorRegistry ( c * config . Config ) error { activeValidatorIndices := GetActiveValidatorIndices ( s . ValidatorRegistry ) totalBalance := s . GetTotalBalance ( activeValidatorIndices , c ) maxBalanceChurn := c . MaxDeposit if maxBalanceChurn < ( totalBalance / ( 2 * c . MaxBalanceChurnQuotient ) ) { maxBalanceChurn = totalBalance / ( 2 * c . MaxBalanceChurnQuotient ) } balanceChurn := uint64 ( 0 ) for idx , validator := range s . ValidatorRegistry { index := uint32 ( idx ) if validator . Status == PendingActivation && s . ValidatorBalances [ index ] >= c . MinDeposit { balanceChurn += s . GetEffectiveBalance ( index , c ) if balanceChurn > maxBalanceChurn { break } err := s . UpdateValidatorStatus ( index , Active , c ) if err != nil { return err } } } balanceChurn = 0 for idx , validator := range s . ValidatorRegistry { index := uint32 ( idx ) if validator . Status == ActivePendingExit { balanceChurn += s . GetEffectiveBalance ( index , c ) if balanceChurn > maxBalanceChurn { break } err := s . UpdateValidatorStatus ( index , ExitedWithoutPenalty , c ) if err != nil { return err } } } return nil }
UpdateValidatorRegistry updates the registry and updates validator pending activation or exit.
UpdateValidatorRegistry updates the registry and updates validator pending activation or exit .