keeper

package
v0.30.0-dev2 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2019 License: Apache-2.0 Imports: 17 Imported by: 1,429

Documentation

Index

Constants

View Source
const (
	QueryParams              = "params"
	QueryOutstandingRewards  = "outstanding_rewards"
	QueryValidatorCommission = "validator_commission"
	QueryValidatorSlashes    = "validator_slashes"
	QueryDelegationRewards   = "delegation_rewards"

	ParamCommunityTax        = "community_tax"
	ParamBaseProposerReward  = "base_proposer_reward"
	ParamBonusProposerReward = "bonus_proposer_reward"
	ParamWithdrawAddrEnabled = "withdraw_addr_enabled"
)

nolint

View Source
const (
	// default paramspace for params keeper
	DefaultParamspace = "distr"
)

Variables

View Source
var (
	FeePoolKey            = []byte{0x00} // key for global distribution state
	ProposerKey           = []byte{0x01} // key for the proposer operator address
	OutstandingRewardsKey = []byte{0x02} // key for outstanding rewards

	DelegatorWithdrawAddrPrefix          = []byte{0x03} // key for delegator withdraw address
	DelegatorStartingInfoPrefix          = []byte{0x04} // key for delegator starting info
	ValidatorHistoricalRewardsPrefix     = []byte{0x05} // key for historical validators rewards / stake
	ValidatorCurrentRewardsPrefix        = []byte{0x06} // key for current validator rewards
	ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission
	ValidatorSlashEventPrefix            = []byte{0x08} // key for validator slash fraction

	ParamStoreKeyCommunityTax        = []byte("communitytax")
	ParamStoreKeyBaseProposerReward  = []byte("baseproposerreward")
	ParamStoreKeyBonusProposerReward = []byte("bonusproposerreward")
	ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled")
)

keys

Functions

func CreateTestInputAdvanced added in v0.25.0

func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initCoins int64,
	communityTax sdk.Dec) (
	sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, DummyFeeCollectionKeeper)

hogpodge of all sorts of input required for testing

func CreateTestInputDefault added in v0.25.0

func CreateTestInputDefault(t *testing.T, isCheckTx bool, initCoins int64) (
	sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, DummyFeeCollectionKeeper)

test input with default values

func GetDelegatorStartingInfoAddresses added in v0.30.0

func GetDelegatorStartingInfoAddresses(key []byte) (valAddr sdk.ValAddress, delAddr sdk.AccAddress)

gets the addresses from a delegator starting info key

func GetDelegatorStartingInfoKey added in v0.30.0

func GetDelegatorStartingInfoKey(v sdk.ValAddress, d sdk.AccAddress) []byte

gets the key for a delegator's starting info

func GetDelegatorWithdrawAddrKey added in v0.25.0

func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte

gets the key for a delegator's withdraw addr

func GetDelegatorWithdrawInfoAddress added in v0.26.0

func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress)

gets an address from a delegator's withdraw info key

func GetValidatorAccumulatedCommissionAddress added in v0.30.0

func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress)

gets the address from a validator's accumulated commission key

func GetValidatorAccumulatedCommissionKey added in v0.30.0

func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte

gets the key for a validator's current commission

func GetValidatorCurrentRewardsAddress added in v0.30.0

func GetValidatorCurrentRewardsAddress(key []byte) (valAddr sdk.ValAddress)

gets the address from a validator's current rewards key

func GetValidatorCurrentRewardsKey added in v0.30.0

func GetValidatorCurrentRewardsKey(v sdk.ValAddress) []byte

gets the key for a validator's current rewards

func GetValidatorHistoricalRewardsAddressPeriod added in v0.30.0

func GetValidatorHistoricalRewardsAddressPeriod(key []byte) (valAddr sdk.ValAddress, period uint64)

gets the address & period from a validator's historical rewards key

func GetValidatorHistoricalRewardsKey added in v0.30.0

func GetValidatorHistoricalRewardsKey(v sdk.ValAddress, k uint64) []byte

gets the key for a validator's historical rewards

func GetValidatorHistoricalRewardsPrefix added in v0.30.0

func GetValidatorHistoricalRewardsPrefix(v sdk.ValAddress) []byte

gets the prefix key for a validator's historical rewards

func GetValidatorSlashEventAddressHeight added in v0.30.0

func GetValidatorSlashEventAddressHeight(key []byte) (valAddr sdk.ValAddress, height uint64)

gets the height from a validator's slash event key

func GetValidatorSlashEventKey added in v0.30.0

func GetValidatorSlashEventKey(v sdk.ValAddress, height uint64) []byte

gets the key for a validator's slash fraction

func GetValidatorSlashEventPrefix added in v0.30.0

func GetValidatorSlashEventPrefix(v sdk.ValAddress) []byte

gets the prefix key for a validator's slash fractions

func MakeTestCodec added in v0.25.0

func MakeTestCodec() *codec.Codec

create a codec used only for testing

func NewQuerier

func NewQuerier(k Keeper) sdk.Querier

func ParamTypeTable added in v0.25.0

func ParamTypeTable() params.TypeTable

type declaration for parameters

Types

type DummyFeeCollectionKeeper added in v0.25.0

type DummyFeeCollectionKeeper struct{}

__________________________________________________________________________________ fee collection keeper used only for testing

func (DummyFeeCollectionKeeper) ClearCollectedFees added in v0.25.0

func (fck DummyFeeCollectionKeeper) ClearCollectedFees(_ sdk.Context)

func (DummyFeeCollectionKeeper) GetCollectedFees added in v0.25.0

func (fck DummyFeeCollectionKeeper) GetCollectedFees(_ sdk.Context) sdk.Coins

nolint

func (DummyFeeCollectionKeeper) SetCollectedFees added in v0.25.0

func (fck DummyFeeCollectionKeeper) SetCollectedFees(in sdk.Coins)

type Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified

func (h Hooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorBeginUnbonding

func (h Hooks) AfterValidatorBeginUnbonding(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorBonded

func (h Hooks) AfterValidatorBonded(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorCreated

func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)

nolint

func (Hooks) AfterValidatorPowerDidChange added in v0.30.0

func (h Hooks) AfterValidatorPowerDidChange(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) AfterValidatorRemoved

func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationCreated

func (h Hooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationRemoved

func (h Hooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeDelegationSharesModified

func (h Hooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress)

func (Hooks) BeforeValidatorModified

func (h Hooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.ValAddress)

func (Hooks) BeforeValidatorSlashed

func (h Hooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.ValAddress, fraction sdk.Dec)

type Keeper

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

keeper of the staking store

func NewKeeper

func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, ck types.BankKeeper,
	sk types.StakingKeeper, fck types.FeeCollectionKeeper, codespace sdk.CodespaceType) Keeper

create a new keeper

func (Keeper) AllocateTokens

func (k Keeper) AllocateTokens(ctx sdk.Context, sumPrecommitPower, totalPower int64, proposer sdk.ConsAddress, votes []abci.VoteInfo)

allocate fees handles distribution of the collected fees

func (Keeper) AllocateTokensToValidator

func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val sdk.Validator, tokens sdk.DecCoins)

allocate tokens to a particular validator, splitting according to commission

func (Keeper) DeleteAllValidatorHistoricalRewards

func (k Keeper) DeleteAllValidatorHistoricalRewards(ctx sdk.Context)

delete all historical rewards

func (Keeper) DeleteAllValidatorSlashEvents

func (k Keeper) DeleteAllValidatorSlashEvents(ctx sdk.Context)

delete all slash events

func (Keeper) DeleteDelegatorStartingInfo

func (k Keeper) DeleteDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress)

delete the starting info associated with a delegator

func (Keeper) DeleteDelegatorWithdrawAddr

func (k Keeper) DeleteDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)

delete a delegator withdraw addr

func (Keeper) DeleteValidatorAccumulatedCommission

func (k Keeper) DeleteValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress)

delete accumulated commission for a validator

func (Keeper) DeleteValidatorCurrentRewards

func (k Keeper) DeleteValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress)

delete current rewards for a validator

func (Keeper) DeleteValidatorHistoricalReward

func (k Keeper) DeleteValidatorHistoricalReward(ctx sdk.Context, val sdk.ValAddress, period uint64)

delete a historical reward

func (Keeper) DeleteValidatorHistoricalRewards

func (k Keeper) DeleteValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress)

delete historical rewards for a validator

func (Keeper) DeleteValidatorSlashEvents

func (k Keeper) DeleteValidatorSlashEvents(ctx sdk.Context, val sdk.ValAddress)

delete slash events for a particular validator

func (Keeper) GetBaseProposerReward

func (k Keeper) GetBaseProposerReward(ctx sdk.Context) sdk.Dec

returns the current BaseProposerReward rate from the global param store nolint: errcheck

func (Keeper) GetBonusProposerReward

func (k Keeper) GetBonusProposerReward(ctx sdk.Context) sdk.Dec

returns the current BaseProposerReward rate from the global param store nolint: errcheck

func (Keeper) GetCommunityTax

func (k Keeper) GetCommunityTax(ctx sdk.Context) sdk.Dec

returns the current CommunityTax rate from the global param store nolint: errcheck

func (Keeper) GetDelegatorStartingInfo

func (k Keeper) GetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) (period types.DelegatorStartingInfo)

get the starting info associated with a delegator

func (Keeper) GetDelegatorWithdrawAddr

func (k Keeper) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress

get the delegator withdraw address, defaulting to the delegator address

func (Keeper) GetFeePool

func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool)

get the global fee pool distribution info

func (Keeper) GetOutstandingRewards added in v0.30.0

func (k Keeper) GetOutstandingRewards(ctx sdk.Context) (rewards types.OutstandingRewards)

get outstanding rewards

func (Keeper) GetPreviousProposerConsAddr

func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsAddress)

get the proposer public key for this block

func (Keeper) GetValidatorAccumulatedCommission

func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) (commission types.ValidatorAccumulatedCommission)

get accumulated commission for a validator

func (Keeper) GetValidatorCurrentRewards

func (k Keeper) GetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorCurrentRewards)

get current rewards for a validator

func (Keeper) GetValidatorHistoricalReferenceCount

func (k Keeper) GetValidatorHistoricalReferenceCount(ctx sdk.Context) (count uint64)

historical reference count (used for testcases)

func (Keeper) GetValidatorHistoricalRewards

func (k Keeper) GetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64) (rewards types.ValidatorHistoricalRewards)

get historical rewards for a particular period

func (Keeper) GetValidatorSlashEvent

func (k Keeper) GetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height uint64) (event types.ValidatorSlashEvent, found bool)

get slash event for height

func (Keeper) GetWithdrawAddrEnabled

func (k Keeper) GetWithdrawAddrEnabled(ctx sdk.Context) bool

returns the current WithdrawAddrEnabled nolint: errcheck

func (Keeper) HasDelegatorStartingInfo

func (k Keeper) HasDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress) bool

check existence of the starting info associated with a delegator

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

Create new distribution hooks

func (Keeper) IterateDelegatorStartingInfos

func (k Keeper) IterateDelegatorStartingInfos(ctx sdk.Context, handler func(val sdk.ValAddress, del sdk.AccAddress, info types.DelegatorStartingInfo) (stop bool))

iterate over delegator starting infos

func (Keeper) IterateDelegatorWithdrawAddrs

func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool))

iterate over delegator withdraw addrs

func (Keeper) IterateValidatorAccumulatedCommissions

func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler func(val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool))

iterate over accumulated commissions

func (Keeper) IterateValidatorCurrentRewards

func (k Keeper) IterateValidatorCurrentRewards(ctx sdk.Context, handler func(val sdk.ValAddress, rewards types.ValidatorCurrentRewards) (stop bool))

iterate over current rewards

func (Keeper) IterateValidatorHistoricalRewards

func (k Keeper) IterateValidatorHistoricalRewards(ctx sdk.Context, handler func(val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards) (stop bool))

iterate over historical rewards

func (Keeper) IterateValidatorSlashEvents

func (k Keeper) IterateValidatorSlashEvents(ctx sdk.Context, handler func(val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent) (stop bool))

iterate over all slash events

func (Keeper) IterateValidatorSlashEventsBetween

func (k Keeper) IterateValidatorSlashEventsBetween(ctx sdk.Context, val sdk.ValAddress, startingHeight uint64, endingHeight uint64,
	handler func(height uint64, event types.ValidatorSlashEvent) (stop bool))

iterate over slash events between heights, inclusive

func (Keeper) SetBaseProposerReward added in v0.25.0

func (k Keeper) SetBaseProposerReward(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetBonusProposerReward added in v0.25.0

func (k Keeper) SetBonusProposerReward(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetCommunityTax added in v0.25.0

func (k Keeper) SetCommunityTax(ctx sdk.Context, percent sdk.Dec)

nolint: errcheck

func (Keeper) SetDelegatorStartingInfo

func (k Keeper) SetDelegatorStartingInfo(ctx sdk.Context, val sdk.ValAddress, del sdk.AccAddress, period types.DelegatorStartingInfo)

set the starting info associated with a delegator

func (Keeper) SetDelegatorWithdrawAddr

func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)

set the delegator withdraw address

func (Keeper) SetFeePool

func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool)

set the global fee pool distribution info

func (Keeper) SetOutstandingRewards added in v0.30.0

func (k Keeper) SetOutstandingRewards(ctx sdk.Context, rewards types.OutstandingRewards)

set outstanding rewards

func (Keeper) SetPreviousProposerConsAddr

func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress)

set the proposer public key for this block

func (Keeper) SetValidatorAccumulatedCommission

func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, commission types.ValidatorAccumulatedCommission)

set accumulated commission for a validator

func (Keeper) SetValidatorCurrentRewards

func (k Keeper) SetValidatorCurrentRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorCurrentRewards)

set current rewards for a validator

func (Keeper) SetValidatorHistoricalRewards

func (k Keeper) SetValidatorHistoricalRewards(ctx sdk.Context, val sdk.ValAddress, period uint64, rewards types.ValidatorHistoricalRewards)

set historical rewards for a particular period

func (Keeper) SetValidatorSlashEvent

func (k Keeper) SetValidatorSlashEvent(ctx sdk.Context, val sdk.ValAddress, height uint64, event types.ValidatorSlashEvent)

set slash event for height

func (Keeper) SetWithdrawAddr

func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) sdk.Error

set withdraw address

func (Keeper) SetWithdrawAddrEnabled added in v0.30.0

func (k Keeper) SetWithdrawAddrEnabled(ctx sdk.Context, enabled bool)

nolint: errcheck

func (Keeper) WithdrawDelegationRewards

func (k Keeper) WithdrawDelegationRewards(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Error

withdraw rewards from a delegation

func (Keeper) WithdrawValidatorCommission

func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Error

withdraw validator commission

type QueryDelegationRewardsParams added in v0.30.0

type QueryDelegationRewardsParams struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}

params for query 'custom/distr/delegation_rewards'

func NewQueryDelegationRewardsParams added in v0.30.0

func NewQueryDelegationRewardsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.ValAddress) QueryDelegationRewardsParams

creates a new instance of QueryDelegationRewardsParams

type QueryValidatorCommissionParams added in v0.30.0

type QueryValidatorCommissionParams struct {
	ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}

params for query 'custom/distr/validator_commission'

func NewQueryValidatorCommissionParams added in v0.30.0

func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValidatorCommissionParams

creates a new instance of QueryValidatorCommissionParams

type QueryValidatorSlashesParams added in v0.30.0

type QueryValidatorSlashesParams struct {
	ValidatorAddr  sdk.ValAddress `json:"validator_addr"`
	StartingHeight uint64         `json:"starting_height"`
	EndingHeight   uint64         `json:"ending_height"`
}

params for query 'custom/distr/validator_slashes'

func NewQueryValidatorSlashesParams added in v0.30.0

func NewQueryValidatorSlashesParams(validatorAddr sdk.ValAddress, startingHeight uint64, endingHeight uint64) QueryValidatorSlashesParams

creates a new instance of QueryValidatorSlashesParams

Jump to

Keyboard shortcuts

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