keeper

package
v0.8.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 25, 2020 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ValOpPk1   = ed25519.GenPrivKey().PubKey()
	ValOpPk2   = ed25519.GenPrivKey().PubKey()
	ValOpPk3   = ed25519.GenPrivKey().PubKey()
	ValOpAddr1 = sdk.ValAddress(ValOpPk1.Address())
	ValOpAddr2 = sdk.ValAddress(ValOpPk2.Address())
	ValOpAddr3 = sdk.ValAddress(ValOpPk3.Address())

	ValConsPk11  = ed25519.GenPrivKey().PubKey()
	ValConsPk12  = ed25519.GenPrivKey().PubKey()
	ValConsPk13  = ed25519.GenPrivKey().PubKey()
	ValConsAddr1 = sdk.ConsAddress(ValConsPk11.Address())
	ValConsAddr2 = sdk.ConsAddress(ValConsPk12.Address())
	ValConsAddr3 = sdk.ConsAddress(ValConsPk13.Address())

	// TODO move to common testing package for all modules
	// test addresses
	TestAddrs = []sdk.AccAddress{
		delAddr1, delAddr2, delAddr3,
		valAccAddr1, valAccAddr2, valAccAddr3,
	}
)

nolint: deadcode unused

Functions

func CreateValidators

func CreateValidators(ctx sdk.Context, sk staking.Keeper, powers []int64)

func MakeTestCodec

func MakeTestCodec() *codec.Codec

func NewQuerier

func NewQuerier(keeper Keeper) sdk.Querier

NewQuerier returns a new querier function

func ValidatorVestingDelegatorTestAccount

func ValidatorVestingDelegatorTestAccount(startTime time.Time) *types.ValidatorVestingAccount

func ValidatorVestingTestAccount

func ValidatorVestingTestAccount() *types.ValidatorVestingAccount

func ValidatorVestingTestAccounts

func ValidatorVestingTestAccounts(numAccounts int) []*types.ValidatorVestingAccount

Types

type Keeper

type Keeper struct {
	// contains filtered or unexported fields
}

Keeper of the validatorvesting store

func CreateTestInput

func CreateTestInput(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context, auth.AccountKeeper, bank.Keeper, staking.Keeper, supply.Keeper, Keeper)

func NewKeeper

NewKeeper creates a new Keeper instance

func (Keeper) AccountIsVesting

func (k Keeper) AccountIsVesting(ctx sdk.Context, addr sdk.AccAddress) bool

AccountIsVesting returns true if all vesting periods is complete and there is no debt

func (Keeper) AddDebt

func (k Keeper) AddDebt(ctx sdk.Context, addr sdk.AccAddress, amount sdk.Coins)

AddDebt adds the input amount to DebtAfterFailedVesting field

func (Keeper) GetAccountFromAuthKeeper

func (k Keeper) GetAccountFromAuthKeeper(ctx sdk.Context, addr sdk.AccAddress) *types.ValidatorVestingAccount

GetAccountFromAuthKeeper returns a ValidatorVestingAccount from the auth keeper

func (Keeper) GetAllAccountKeys

func (k Keeper) GetAllAccountKeys(ctx sdk.Context) (keys [][]byte)

GetAllAccountKeys returns all account keys in the validator vesting keeper.

func (Keeper) GetPeriodEndTimes

func (k Keeper) GetPeriodEndTimes(ctx sdk.Context, addr sdk.AccAddress) []int64

GetPeriodEndTimes returns an array of the times when each period ends

func (Keeper) GetPreviousBlockTime

func (k Keeper) GetPreviousBlockTime(ctx sdk.Context) (blockTime time.Time)

GetPreviousBlockTime get the blocktime for the previous block

func (Keeper) HandleVestingDebt

func (k Keeper) HandleVestingDebt(ctx sdk.Context, addr sdk.AccAddress, blockTime time.Time)

HandleVestingDebt removes coins after a vesting period in which the vesting threshold was not met. Sends/Burns tokens if there is enough spendable tokens, otherwise unbonds all existing tokens.

func (Keeper) IterateAccountKeys

func (k Keeper) IterateAccountKeys(ctx sdk.Context, cb func(accountKey []byte) (stop bool))

IterateAccountKeys iterates over all the stored account keys and performs a callback function

func (Keeper) Logger

func (k Keeper) Logger(ctx sdk.Context) log.Logger

Logger returns a module-specific logger.

func (Keeper) ResetCurrentPeriodProgress

func (k Keeper) ResetCurrentPeriodProgress(ctx sdk.Context, addr sdk.AccAddress)

ResetCurrentPeriodProgress resets CurrentPeriodProgress to zero values

func (Keeper) ResetDebt

func (k Keeper) ResetDebt(ctx sdk.Context, addr sdk.AccAddress)

ResetDebt sets DebtAfterFailedVesting to zero

func (Keeper) SetPreviousBlockTime

func (k Keeper) SetPreviousBlockTime(ctx sdk.Context, blockTime time.Time)

SetPreviousBlockTime set the time of the previous block

func (Keeper) SetValidatorVestingAccountKey

func (k Keeper) SetValidatorVestingAccountKey(ctx sdk.Context, addr sdk.AccAddress)

SetValidatorVestingAccountKey stores the account key in the store. This is useful for when we want to iterate over all ValidatorVestingAcounts, so we can avoid iterating over any other accounts stored in the auth keeper.

func (Keeper) SetVestingProgress

func (k Keeper) SetVestingProgress(ctx sdk.Context, addr sdk.AccAddress, period int, success bool)

SetVestingProgress sets VestingPeriodProgress for the input period

func (Keeper) UpdateMissingSignCount

func (k Keeper) UpdateMissingSignCount(ctx sdk.Context, addr sdk.AccAddress, missedBlock bool)

UpdateMissingSignCount increments the count of blocks missed during the current period

func (Keeper) UpdateVestedCoinsProgress

func (k Keeper) UpdateVestedCoinsProgress(ctx sdk.Context, addr sdk.AccAddress, period int)

UpdateVestedCoinsProgress sets the VestingPeriodProgress variable (0 = coins did not vest for the period, 1 = coins did vest for the period) for the given address and period. If coins did not vest, those coins are added to DebtAfterFailedVesting. Finally, MissingSignCount is reset to [0,0], representing that the next period has started and no blocks have been missed.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL