keeper

package
v0.25.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2018 License: Apache-2.0 Imports: 15 Imported by: 1,652

Documentation

Index

Constants

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

Variables

View Source
var (
	FeePoolKey               = []byte{0x00} // key for global distribution state
	ValidatorDistInfoKey     = []byte{0x01} // prefix for each key to a validator distribution
	DelegationDistInfoKey    = []byte{0x02} // prefix for each key to a delegation distribution
	DelegatorWithdrawInfoKey = []byte{0x03} // prefix for each key to a delegator withdraw info
	ProposerKey              = []byte{0x04} // key for storing the proposer operator address

	// params store
	ParamStoreKeyCommunityTax        = []byte("communitytax")
	ParamStoreKeyBaseProposerReward  = []byte("baseproposerreward")
	ParamStoreKeyBonusProposerReward = []byte("bonusproposerreward")
)

keys/key-prefixes

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, stake.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, stake.Keeper, DummyFeeCollectionKeeper)

test input with default values

func GetDelegationDistInfoKey added in v0.25.0

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

gets the key for delegator distribution for a validator VALUE: distribution/types.DelegationDistInfo

func GetDelegationDistInfosKey added in v0.25.0

func GetDelegationDistInfosKey(delAddr sdk.AccAddress) []byte

gets the prefix for a delegator's distributions across all validators

func GetDelegatorWithdrawAddrKey added in v0.25.0

func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte

gets the prefix for a delegator's withdraw info

func GetValidatorDistInfoKey added in v0.25.0

func GetValidatorDistInfoKey(operatorAddr sdk.ValAddress) []byte

gets the key for the validator distribution info from address VALUE: distribution/types.ValidatorDistInfo

func MakeTestCodec added in v0.25.0

func MakeTestCodec() *codec.Codec

create a codec used only for testing

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) OnDelegationCreated added in v0.25.0

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

func (Hooks) OnDelegationRemoved added in v0.25.0

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

func (Hooks) OnDelegationSharesModified added in v0.25.0

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

func (Hooks) OnValidatorBeginUnbonding added in v0.25.0

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

func (Hooks) OnValidatorBonded added in v0.25.0

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

func (Hooks) OnValidatorCreated added in v0.25.0

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

nolint

func (Hooks) OnValidatorModified added in v0.25.0

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

func (Hooks) OnValidatorPowerDidChange added in v0.25.0

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

func (Hooks) OnValidatorRemoved added in v0.25.0

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

type Keeper

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

keeper of the stake store

func NewKeeper

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

func (Keeper) AllocateTokens

func (k Keeper) AllocateTokens(ctx sdk.Context, percentVotes sdk.Dec, proposer sdk.ConsAddress)

Allocate fees handles distribution of the collected fees

func (Keeper) CurrentDelegationReward added in v0.25.0

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

current rewards for a single delegation

func (Keeper) CurrentDelegationRewardsAll added in v0.25.0

func (k Keeper) CurrentDelegationRewardsAll(ctx sdk.Context,
	delAddr sdk.AccAddress) types.DecCoins

get all rewards for all delegations of a delegator

func (Keeper) CurrentValidatorRewardsAll added in v0.25.0

func (k Keeper) CurrentValidatorRewardsAll(ctx sdk.Context, operatorAddr sdk.ValAddress) (sdk.Coins, sdk.Error)

get all the validator rewards including the commission

func (Keeper) GetAllDelegationDistInfos added in v0.25.0

func (k Keeper) GetAllDelegationDistInfos(ctx sdk.Context) (ddis []types.DelegationDistInfo)

Get the set of all delegator-distribution-info's with no limits, used during genesis dump

func (Keeper) GetAllDelegatorWithdrawInfos added in v0.25.0

func (k Keeper) GetAllDelegatorWithdrawInfos(ctx sdk.Context) (dwis []types.DelegatorWithdrawInfo)

Get the set of all delegator-withdraw addresses with no limits, used during genesis dump

func (Keeper) GetAllValidatorDistInfos added in v0.25.0

func (k Keeper) GetAllValidatorDistInfos(ctx sdk.Context) (vdis []types.ValidatorDistInfo)

Get the set of all validator-distribution-info's with no limits, used during genesis dump

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) GetDelegationDistInfo added in v0.25.0

func (k Keeper) GetDelegationDistInfo(ctx sdk.Context, delAddr sdk.AccAddress,
	valOperatorAddr sdk.ValAddress) (ddi types.DelegationDistInfo)

get the delegator distribution info

func (Keeper) GetDelegatorWithdrawAddr

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

get the delegator withdraw address, return the delegator address if not set

func (Keeper) GetFeePool

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

get the global fee pool distribution info

func (Keeper) GetFeePoolValAccum added in v0.25.0

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

get the total validator accum for the ctx height in the fee pool

func (Keeper) GetPreviousProposerConsAddr

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

set the proposer public key for this block

func (Keeper) GetValidatorAccum added in v0.25.0

func (k Keeper) GetValidatorAccum(ctx sdk.Context, operatorAddr sdk.ValAddress) (sdk.Dec, sdk.Error)

Get the calculated accum of a validator at the current block without affecting the state.

func (Keeper) GetValidatorDistInfo added in v0.25.0

func (k Keeper) GetValidatorDistInfo(ctx sdk.Context,
	operatorAddr sdk.ValAddress) (vdi types.ValidatorDistInfo)

get the validator distribution info

func (Keeper) GetWithdrawContext added in v0.25.0

func (k Keeper) GetWithdrawContext(ctx sdk.Context,
	valOperatorAddr sdk.ValAddress) types.WithdrawContext

get context required for withdraw operations

func (Keeper) HasDelegationDistInfo added in v0.25.0

func (k Keeper) HasDelegationDistInfo(ctx sdk.Context, delAddr sdk.AccAddress,
	valOperatorAddr sdk.ValAddress) (has bool)

check whether a delegator distribution info exists

func (Keeper) HasValidatorDistInfo added in v0.25.0

func (k Keeper) HasValidatorDistInfo(ctx sdk.Context,
	operatorAddr sdk.ValAddress) (exists bool)

check whether a validator has distribution info

func (Keeper) Hooks

func (k Keeper) Hooks() Hooks

New Validator Hooks

func (Keeper) IterateValidatorDistInfos added in v0.25.0

func (k Keeper) IterateValidatorDistInfos(ctx sdk.Context,
	fn func(index int64, distInfo types.ValidatorDistInfo) (stop bool))

iterate over all the validator distribution infos (inefficient, just used to check invariants)

func (Keeper) RemoveDelegationDistInfo added in v0.25.0

func (k Keeper) RemoveDelegationDistInfo(ctx sdk.Context, delAddr sdk.AccAddress,
	valOperatorAddr sdk.ValAddress)

remove a delegator distribution info

func (Keeper) RemoveDelegatorWithdrawAddr added in v0.25.0

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

remove a delegator withdraw info

func (Keeper) RemoveValidatorDistInfo added in v0.25.0

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

remove a validator distribution info

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) SetDelegationDistInfo added in v0.25.0

func (k Keeper) SetDelegationDistInfo(ctx sdk.Context, ddi types.DelegationDistInfo)

set the delegator distribution info

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) SetPreviousProposerConsAddr

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

get the proposer public key for this block

func (Keeper) SetValidatorDistInfo added in v0.25.0

func (k Keeper) SetValidatorDistInfo(ctx sdk.Context, vdi types.ValidatorDistInfo)

set the validator distribution info

func (Keeper) WithdrawDelegationReward added in v0.25.0

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

withdraw all rewards for a single delegation NOTE: This gets called "onDelegationSharesModified", meaning any changes to bonded coins

func (Keeper) WithdrawDelegationRewardsAll added in v0.25.0

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

return all rewards for all delegations of a delegator

func (Keeper) WithdrawToDelegator added in v0.25.0

func (k Keeper) WithdrawToDelegator(ctx sdk.Context, feePool types.FeePool,
	delAddr sdk.AccAddress, amount types.DecCoins)

withdraw all rewards for a single delegation NOTE: This gets called "onDelegationSharesModified", meaning any changes to bonded coins

func (Keeper) WithdrawValidatorRewardsAll added in v0.25.0

func (k Keeper) WithdrawValidatorRewardsAll(ctx sdk.Context, operatorAddr sdk.ValAddress) sdk.Error

withdrawal all the validator rewards including the commission

Jump to

Keyboard shortcuts

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