2019-06-05 16:26:17 -07:00
|
|
|
package types
|
2019-05-16 08:25:32 -07:00
|
|
|
|
|
|
|
import (
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
"github.com/cosmos/cosmos-sdk/x/auth"
|
2019-06-05 10:42:25 -07:00
|
|
|
"github.com/cosmos/cosmos-sdk/x/staking/exported"
|
2019-05-16 08:25:32 -07:00
|
|
|
)
|
|
|
|
|
2019-06-04 15:06:58 -07:00
|
|
|
// AccountKeeper expected account keeper
|
|
|
|
type AccountKeeper interface {
|
|
|
|
IterateAccounts(ctx sdk.Context, process func(auth.Account) (stop bool))
|
|
|
|
}
|
|
|
|
|
|
|
|
// StakingKeeper expected staking keeper
|
2019-05-16 08:25:32 -07:00
|
|
|
type StakingKeeper interface {
|
2019-06-04 15:06:58 -07:00
|
|
|
// iterate through validators by operator address, execute func for each validator
|
|
|
|
IterateValidators(sdk.Context,
|
2019-06-05 10:42:25 -07:00
|
|
|
func(index int64, validator exported.ValidatorI) (stop bool))
|
2019-06-04 15:06:58 -07:00
|
|
|
|
2019-06-05 10:42:25 -07:00
|
|
|
Validator(sdk.Context, sdk.ValAddress) exported.ValidatorI // get a particular validator by operator address
|
|
|
|
ValidatorByConsAddr(sdk.Context, sdk.ConsAddress) exported.ValidatorI // get a particular validator by consensus address
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// slash the validator and delegators of the validator, specifying offence height, offence power, and slash fraction
|
|
|
|
Slash(sdk.Context, sdk.ConsAddress, int64, int64, sdk.Dec)
|
|
|
|
Jail(sdk.Context, sdk.ConsAddress) // jail a validator
|
|
|
|
Unjail(sdk.Context, sdk.ConsAddress) // unjail a validator
|
|
|
|
|
|
|
|
// Delegation allows for getting a particular delegation for a given validator
|
|
|
|
// and delegator outside the scope of the staking module.
|
2019-06-05 10:42:25 -07:00
|
|
|
Delegation(sdk.Context, sdk.AccAddress, sdk.ValAddress) exported.DelegationI
|
2019-06-04 15:06:58 -07:00
|
|
|
|
|
|
|
// MaxValidators returns the maximum amount of bonded validators
|
|
|
|
MaxValidators(sdk.Context) uint16
|
2019-05-16 08:25:32 -07:00
|
|
|
}
|
|
|
|
|
2019-06-04 15:06:58 -07:00
|
|
|
// StakingHooks event hooks for staking validator object
|
|
|
|
type StakingHooks interface {
|
|
|
|
AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress) // Must be called when a validator is created
|
|
|
|
AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is deleted
|
|
|
|
|
|
|
|
AfterValidatorBonded(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress) // Must be called when a validator is bonded
|
2019-05-16 08:25:32 -07:00
|
|
|
}
|