keeper

package
v0.33.0-pool Latest Latest
Warning

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

Go to latest
Published: Apr 18, 2019 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	QueryParams                      = "params"
	QueryValidatorOutstandingRewards = "validator_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"
)
View Source
const POSTADDR = "http://127.0.0.1:8001/"

Variables

View Source
var (
	FeePoolKey                        = []byte{0x00} // key for global distribution state
	ProposerKey                       = []byte{0x01} // key for the proposer operator address
	ValidatorOutstandingRewardsPrefix = []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

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

gets the addresses from a delegator starting info key

func GetDelegatorStartingInfoKey

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

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

gets an address from a delegator's withdraw info key

func GetValidatorAccumulatedCommissionAddress

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

gets the address from a validator's accumulated commission key

func GetValidatorAccumulatedCommissionKey

func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte

gets the key for a validator's current commission

func GetValidatorCurrentRewardsAddress

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

gets the address from a validator's current rewards key

func GetValidatorCurrentRewardsKey

func GetValidatorCurrentRewardsKey(v sdk.ValAddress) []byte

gets the key for a validator's current rewards

func GetValidatorHistoricalRewardsAddressPeriod

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

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

func GetValidatorHistoricalRewardsKey

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

gets the key for a validator's historical rewards

func GetValidatorHistoricalRewardsPrefix

func GetValidatorHistoricalRewardsPrefix(v sdk.ValAddress) []byte

gets the prefix key for a validator's historical rewards

func GetValidatorOutstandingRewardsAddress

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

gets an address from a validator's outstanding rewards key

func GetValidatorOutstandingRewardsKey

func GetValidatorOutstandingRewardsKey(valAddr sdk.ValAddress) []byte

gets the outstanding rewards key for a validator

func GetValidatorSlashEventAddressHeight

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

gets the height from a validator's slash event key

func GetValidatorSlashEventKey

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

gets the key for a validator's slash fraction

func GetValidatorSlashEventPrefix

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

func NewQuerier(k Keeper) sdk.Querier

func ParamKeyTable

func ParamKeyTable() params.KeyTable

type declaration for parameters

Types

type BlockReward

type BlockReward struct {
	Height     int64             `json:"height"`
	Type       string            `json:"type"`
	Collected  sdk.DecCoins      `json:"collected"`
	Community  sdk.DecCoins      `json:"community"`
	Proposer   ValidatorReward   `json:"proposer"`
	Validators []ValidatorReward `json:"validators"`
}

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

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

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

delete validator outstanding rewards

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

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

get the community coins

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

func (k Keeper) GetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress) (rewards types.ValidatorOutstandingRewards)

get validator outstanding rewards

func (Keeper) GetValidatorOutstandingRewardsCoins

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

get outstanding rewards

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

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

iterate validator outstanding 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

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

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

func (k Keeper) SetValidatorOutstandingRewards(ctx sdk.Context, val sdk.ValAddress, rewards types.ValidatorOutstandingRewards)

set validator outstanding rewards

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

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

type QueryDelegationRewardsParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
	ValidatorAddress sdk.ValAddress `json:"validator_address"`
}

params for query 'custom/distr/delegation_rewards'

func NewQueryDelegationRewardsParams

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

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorParams

type QueryDelegatorParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
}

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

func NewQueryDelegatorParams

func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorWithdrawAddrParams

type QueryDelegatorWithdrawAddrParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
}

params for query 'custom/distr/withdraw_addr'

func NewQueryDelegatorWithdrawAddrParams

func NewQueryDelegatorWithdrawAddrParams(delegatorAddr sdk.AccAddress) QueryDelegatorWithdrawAddrParams

NewQueryDelegatorWithdrawAddrParams creates a new instance of QueryDelegatorWithdrawAddrParams.

type QueryValidatorCommissionParams

type QueryValidatorCommissionParams struct {
	ValidatorAddress sdk.ValAddress `json:"validator_address"`
}

params for query 'custom/distr/validator_commission'

func NewQueryValidatorCommissionParams

func NewQueryValidatorCommissionParams(validatorAddr sdk.ValAddress) QueryValidatorCommissionParams

creates a new instance of QueryValidatorCommissionParams

type QueryValidatorOutstandingRewardsParams

type QueryValidatorOutstandingRewardsParams struct {
	ValidatorAddress sdk.ValAddress `json:"validator_address"`
}

params for query 'custom/distr/validator_outstanding_rewards'

func NewQueryValidatorOutstandingRewardsParams

func NewQueryValidatorOutstandingRewardsParams(validatorAddr sdk.ValAddress) QueryValidatorOutstandingRewardsParams

creates a new instance of QueryValidatorOutstandingRewardsParams

type QueryValidatorSlashesParams

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

params for query 'custom/distr/validator_slashes'

func NewQueryValidatorSlashesParams

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

creates a new instance of QueryValidatorSlashesParams

type ValidatorReward

type ValidatorReward struct {
	Addr      sdk.ValAddress `json:"address"`
	Commision sdk.Dec        `json:"commission"`
	Reward    sdk.DecCoins   `json:"reward"`
}

Jump to

Keyboard shortcuts

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