keeper

package
v0.32.0 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2019 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryParams                = "params"
	QueryOutstandingRewards    = "outstanding_rewards"
	QueryValidatorCommission   = "validator_commission"
	QueryValidatorSlashes      = "validator_slashes"
	QueryDelegationRewards     = "delegation_rewards"
	QueryDelegatorTotalRewards = "delegator_total_rewards"
	QueryDelegatorValidators   = "delegator_validators"
	QueryWithdrawAddr          = "withdraw_addr"

	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

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

hogpodge of all sorts of input required for testing

func CreateTestInputDefault

func CreateTestInputDefault(t *testing.T, isCheckTx bool, initPower 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

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

func MakeTestCodec() *codec.Codec

create a codec used only for testing

func NewQuerier added in v0.30.0

func NewQuerier(k Keeper) sdk.Querier

func ParamKeyTable added in v0.31.0

func ParamKeyTable() params.KeyTable

type declaration for parameters

Types

type DummyFeeCollectionKeeper

type DummyFeeCollectionKeeper struct{}

__________________________________________________________________________________ fee collection keeper used only for testing

func (DummyFeeCollectionKeeper) ClearCollectedFees

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

func (DummyFeeCollectionKeeper) GetCollectedFees

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

nolint

func (DummyFeeCollectionKeeper) SetCollectedFees

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

type Hooks

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

Wrapper struct

func (Hooks) AfterDelegationModified added in v0.30.0

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

func (Hooks) AfterValidatorBeginUnbonding added in v0.30.0

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

func (Hooks) AfterValidatorBonded added in v0.30.0

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

func (Hooks) AfterValidatorCreated added in v0.30.0

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

nolint

func (Hooks) AfterValidatorRemoved added in v0.30.0

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

func (Hooks) BeforeDelegationCreated added in v0.30.0

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

func (Hooks) BeforeDelegationRemoved added in v0.30.0

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

func (Hooks) BeforeDelegationSharesModified added in v0.30.0

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

func (Hooks) BeforeValidatorModified added in v0.30.0

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

func (Hooks) BeforeValidatorSlashed added in v0.30.0

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 added in v0.30.0

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 added in v0.30.0

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

delete all historical rewards

func (Keeper) DeleteAllValidatorSlashEvents added in v0.30.0

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

delete all slash events

func (Keeper) DeleteDelegatorStartingInfo added in v0.30.0

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

delete the starting info associated with a delegator

func (Keeper) DeleteDelegatorWithdrawAddr added in v0.30.0

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

delete a delegator withdraw addr

func (Keeper) DeleteValidatorAccumulatedCommission added in v0.30.0

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

delete accumulated commission for a validator

func (Keeper) DeleteValidatorCurrentRewards added in v0.30.0

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

delete current rewards for a validator

func (Keeper) DeleteValidatorHistoricalReward added in v0.30.0

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

delete a historical reward

func (Keeper) DeleteValidatorHistoricalRewards added in v0.30.0

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

delete historical rewards for a validator

func (Keeper) DeleteValidatorSlashEvents added in v0.30.0

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 added in v0.30.0

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) GetFeePoolCommunityCoins added in v0.32.0

func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins

get the community coins

func (Keeper) GetOutstandingRewards added in v0.30.0

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

get outstanding rewards

func (Keeper) GetOutstandingRewardsCoins added in v0.32.0

func (k Keeper) GetOutstandingRewardsCoins(ctx sdk.Context) sdk.DecCoins

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 added in v0.30.0

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

get accumulated commission for a validator

func (Keeper) GetValidatorCurrentRewards added in v0.30.0

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

get current rewards for a validator

func (Keeper) GetValidatorHistoricalReferenceCount added in v0.30.0

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

historical reference count (used for testcases)

func (Keeper) GetValidatorHistoricalRewards added in v0.30.0

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 added in v0.30.0

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 added in v0.30.0

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

returns the current WithdrawAddrEnabled nolint: errcheck

func (Keeper) HasDelegatorStartingInfo added in v0.30.0

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 added in v0.30.0

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 added in v0.30.0

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 added in v0.30.0

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

iterate over accumulated commissions

func (Keeper) IterateValidatorCurrentRewards added in v0.30.0

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

iterate over current rewards

func (Keeper) IterateValidatorHistoricalRewards added in v0.30.0

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 added in v0.30.0

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 added in v0.30.0

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

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

nolint: errcheck

func (Keeper) SetBonusProposerReward

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

nolint: errcheck

func (Keeper) SetCommunityTax

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

nolint: errcheck

func (Keeper) SetDelegatorStartingInfo added in v0.30.0

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 added in v0.30.0

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

set accumulated commission for a validator

func (Keeper) SetValidatorCurrentRewards added in v0.30.0

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

set current rewards for a validator

func (Keeper) SetValidatorHistoricalRewards added in v0.30.0

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 added in v0.30.0

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

set slash event for height

func (Keeper) SetWithdrawAddr added in v0.30.0

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 added in v0.30.0

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

withdraw rewards from a delegation

func (Keeper) WithdrawValidatorCommission added in v0.30.0

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 QueryDelegatorParams added in v0.31.0

type QueryDelegatorParams struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
}

params for query 'custom/distr/delegator_total_rewards' and 'custom/distr/delegator_validators'

func NewQueryDelegatorParams added in v0.31.0

func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorWithdrawAddrParams added in v0.31.0

type QueryDelegatorWithdrawAddrParams struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
}

params for query 'custom/distr/withdraw_addr'

func NewQueryDelegatorWithdrawAddrParams added in v0.31.0

func NewQueryDelegatorWithdrawAddrParams(delegatorAddr sdk.AccAddress) QueryDelegatorWithdrawAddrParams

NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams.

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