mirror of
https://github.com/luxfi/node.git
synced 2026-10-30 15:24:05 +00:00
78 lines
3.0 KiB
Go
78 lines
3.0 KiB
Go
// Copyright (C) 2019-2025, Lux Industries Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
|
|
package txs
|
|
|
|
const (
|
|
// Legacy AddDelegatorTx delegators move from pending to current first,
|
|
PrimaryNetworkDelegatorLegacyPendingPriority Priority = iota + 1
|
|
// then primary network validators,
|
|
PrimaryNetworkValidatorPendingPriority
|
|
// then AddPermissionlessDelegatorTx delegators,
|
|
PrimaryNetworkDelegatorPermissionlessPendingPriority
|
|
// then permissionless chain validators,
|
|
ChainPermissionlessValidatorPendingPriority
|
|
// then permissionless chain delegators.
|
|
ChainPermissionlessDelegatorPendingPriority
|
|
// then permissioned chain validators,
|
|
ChainPermissionedValidatorPendingPriority
|
|
|
|
// First permissioned chain validators are removed from the current
|
|
// validator set,
|
|
// Invariant: All permissioned stakers must be removed first because they
|
|
// are removed by the advancement of time. Permissionless stakers
|
|
// are removed with a RewardValidatorTx after time has advanced.
|
|
ChainPermissionedValidatorCurrentPriority
|
|
// then permissionless chain delegators,
|
|
ChainPermissionlessDelegatorCurrentPriority
|
|
// then permissionless chain validators,
|
|
ChainPermissionlessValidatorCurrentPriority
|
|
// then primary network delegators,
|
|
PrimaryNetworkDelegatorCurrentPriority
|
|
// then primary network validators.
|
|
PrimaryNetworkValidatorCurrentPriority
|
|
)
|
|
|
|
var PendingToCurrentPriorities = []Priority{
|
|
PrimaryNetworkDelegatorLegacyPendingPriority: PrimaryNetworkDelegatorCurrentPriority,
|
|
PrimaryNetworkValidatorPendingPriority: PrimaryNetworkValidatorCurrentPriority,
|
|
PrimaryNetworkDelegatorPermissionlessPendingPriority: PrimaryNetworkDelegatorCurrentPriority,
|
|
ChainPermissionlessValidatorPendingPriority: ChainPermissionlessValidatorCurrentPriority,
|
|
ChainPermissionlessDelegatorPendingPriority: ChainPermissionlessDelegatorCurrentPriority,
|
|
ChainPermissionedValidatorPendingPriority: ChainPermissionedValidatorCurrentPriority,
|
|
}
|
|
|
|
type Priority byte
|
|
|
|
func (p Priority) IsValidator() bool {
|
|
return p.IsCurrentValidator() || p.IsPendingValidator()
|
|
}
|
|
|
|
func (p Priority) IsPermissionedValidator() bool {
|
|
return p == ChainPermissionedValidatorCurrentPriority ||
|
|
p == ChainPermissionedValidatorPendingPriority
|
|
}
|
|
|
|
func (p Priority) IsCurrentValidator() bool {
|
|
return p == PrimaryNetworkValidatorCurrentPriority ||
|
|
p == ChainPermissionedValidatorCurrentPriority ||
|
|
p == ChainPermissionlessValidatorCurrentPriority
|
|
}
|
|
|
|
func (p Priority) IsCurrentDelegator() bool {
|
|
return p == PrimaryNetworkDelegatorCurrentPriority ||
|
|
p == ChainPermissionlessDelegatorCurrentPriority
|
|
}
|
|
|
|
func (p Priority) IsPendingValidator() bool {
|
|
return p == PrimaryNetworkValidatorPendingPriority ||
|
|
p == ChainPermissionedValidatorPendingPriority ||
|
|
p == ChainPermissionlessValidatorPendingPriority
|
|
}
|
|
|
|
func (p Priority) IsPendingDelegator() bool {
|
|
return p == PrimaryNetworkDelegatorPermissionlessPendingPriority ||
|
|
p == PrimaryNetworkDelegatorLegacyPendingPriority ||
|
|
p == ChainPermissionlessDelegatorPendingPriority
|
|
}
|