Documentation
¶
Index ¶
Constants ¶
const (
DefaultStatusCheckTick = 6 * time.Hour
)
Variables ¶
var UnconditionalJoinPolicy = &unconditionalJoinPolicy{}
UnconditionalJoinPolicy is a policy that doesn't enforce any conditions for joining the sortition pool.
Functions ¶
func MonitorPool ¶
func MonitorPool( ctx context.Context, logger log.StandardLogger, chain Chain, tick time.Duration, policy JoinPolicy, ) error
MonitorPool periodically checks the status of the operator in the sortition pool. If the operator is supposed to be in the sortition pool but is not there yet, the function attempts to add the operator to the pool. If the operator is already in the pool and its status is no longer up to date, the function attempts to update the operator's status in the pool.
Types ¶
type BetaOperatorPolicy ¶
type BetaOperatorPolicy struct {
// contains filtered or unexported fields
}
BetaOperatorPolicy is a JoinPolicy implementation checking chaosnet and beta operator status. If chaosnet has been deactivated, the operator is allowed to join the pool. If chaosnet is active and the operator is beta operator, the operator is allowed to join the pool. If chaosnet is active and the operator is not beta operator, the operator is not allowed to join the pool.
func NewBetaOperatorPolicy ¶
func NewBetaOperatorPolicy( chain Chain, logger log.StandardLogger, ) *BetaOperatorPolicy
func (*BetaOperatorPolicy) ShouldJoin ¶
func (bop *BetaOperatorPolicy) ShouldJoin() bool
type Chain ¶
type Chain interface { // OperatorToStakingProvider returns the staking provider address for the // operator. If the staking provider has not been registered for the // operator, the returned address is empty and the boolean flag is set to // false. If the staking provider has been registered, the address is not // empty and the boolean flag indicates true. OperatorToStakingProvider() (chain.Address, bool, error) // EligibleStake returns the current value of the staking provider's // eligible stake. Eligible stake is defined as the currently authorized // stake minus the pending authorization decrease. Eligible stake // is what is used for operator's weight in the sortition pool. // If the authorized stake minus the pending authorization decrease // is below the minimum authorization, eligible stake is 0. EligibleStake(stakingProvider chain.Address) (*big.Int, error) // IsPoolLocked returns true if the sortition pool is locked and no state // changes are allowed. IsPoolLocked() (bool, error) // IsOperatorInPool returns true if the operator is registered in // the sortition pool. IsOperatorInPool() (bool, error) // IsOperatorUpToDate checks if the operator's authorized stake is in sync // with operator's weight in the sortition pool. // If the operator's authorized stake is not in sync with sortition pool // weight, function returns false. // If the operator is not in the sortition pool and their authorized stake // is non-zero, function returns false. IsOperatorUpToDate() (bool, error) // JoinSortitionPool executes a transaction to have the operator join the // sortition pool. JoinSortitionPool() error // UpdateOperatorStatus executes a transaction to update the operator's // state in the sortition pool. UpdateOperatorStatus() error // IsEligibleForRewards checks whether the operator is eligible for rewards // or not. IsEligibleForRewards() (bool, error) // Checks whether the operator is able to restore their eligibility for // rewards right away. CanRestoreRewardEligibility() (bool, error) // Restores reward eligibility for the operator. RestoreRewardEligibility() error // Returns true if the chaosnet phase is active, false otherwise. IsChaosnetActive() (bool, error) // Returns true if operator is a beta operator, false otherwise. // Chaosnet status does not matter. IsBetaOperator() (bool, error) // GetOperatorID returns the operator ID for the given operator address. GetOperatorID(operatorAddress chain.Address) (chain.OperatorID, error) }
Chain handle for interaction with the sortition pool contracts.
type ConjunctionPolicy ¶
type ConjunctionPolicy struct {
// contains filtered or unexported fields
}
ConjunctionPolicy is a JoinPolicy implementation requiring all the provided policies to pass before allowing to join the sortition pool.
func NewConjunctionPolicy ¶
func NewConjunctionPolicy( policies ...JoinPolicy, ) *ConjunctionPolicy
func (*ConjunctionPolicy) ShouldJoin ¶
func (cp *ConjunctionPolicy) ShouldJoin() bool
type JoinPolicy ¶
type JoinPolicy interface { // ShouldJoin indicates whether the joining condition is fulfilled and // the client should join the pool. ShouldJoin() bool }
JoinPolicy determines how the client is supposed to join the sortition pool. The policy can encapsulate special conditions that the client wants to fulfill before joining the sortition pool.