Documentation ¶
Index ¶
- Constants
- Variables
- func CanWithdrawInvariant(k Keeper) sdk.Invariant
- func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte
- func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress)
- func GetTestAddrs() ([]sdk.ValAddress, []crypto.PubKey, []sdk.ConsAddress)
- func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress)
- func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte
- func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) sdk.Error
- func MakeTestCodec() *codec.Codec
- func ModuleAccountInvariant(k Keeper) sdk.Invariant
- func NewQuerier(k Keeper) sdk.Querier
- func NewTestDecCoin(i int64, precison int64) sdk.DecCoin
- func NewTestDecCoins(i int64, precison int64) sdk.DecCoins
- func NonNegativeCommissionsInvariant(k Keeper) sdk.Invariant
- func ParamKeyTable() params.KeyTable
- func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
- type Hooks
- func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
- func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
- func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)
- func (h Hooks) AfterValidatorDestroyed(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)
- func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)
- func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)
- type Keeper
- func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64, communityTax sdk.Dec) (sdk.Context, auth.AccountKeeper, bank.Keeper, Keeper, staking.Keeper, ...)
- func CreateTestInputDefault(t *testing.T, isCheckTx bool, initPower int64) (sdk.Context, auth.AccountKeeper, Keeper, staking.Keeper, types.SupplyKeeper)
- func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, ...) Keeper
- func (k Keeper) AllocateTokens(ctx sdk.Context, totalPreviousPower int64, previousProposer sdk.ConsAddress, ...)
- func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.ValidatorI, tokens sdk.DecCoins)
- func (k Keeper) GetCommunityTax(ctx sdk.Context) sdk.Dec
- func (k Keeper) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress
- func (k Keeper) GetDistributionAccount(ctx sdk.Context) exported.ModuleAccountI
- func (k Keeper) GetFeeCollectorName() string
- func (k Keeper) GetFeePool(ctx sdk.Context) (feePool types.FeePool)
- func (k Keeper) GetFeePoolCommunityCoins(ctx sdk.Context) sdk.DecCoins
- func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsAddress)
- func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) (commission types.ValidatorAccumulatedCommission)
- func (k Keeper) GetWithdrawAddrEnabled(ctx sdk.Context) bool
- func (k Keeper) Hooks() Hooks
- func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, ...)
- func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, ...)
- func (k Keeper) Logger(ctx sdk.Context) log.Logger
- func (k Keeper) SetCommunityTax(ctx sdk.Context, percent sdk.Dec)
- func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)
- func (k Keeper) SetFeePool(ctx sdk.Context, feePool types.FeePool)
- func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress)
- func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, ...)
- func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) sdk.Error
- func (k Keeper) SetWithdrawAddrEnabled(ctx sdk.Context, enabled bool)
- func (k Keeper) WithdrawValidatorCommission(ctx sdk.Context, valAddr sdk.ValAddress) (sdk.Coins, sdk.Error)
Constants ¶
const ( // DefaultParamspace for params keeper DefaultParamspace = types.ModuleName )
Variables ¶
var ( FeePoolKey = []byte{0x00} // key for global distribution state ProposerKey = []byte{0x01} // key for the proposer operator address DelegatorWithdrawAddrPrefix = []byte{0x03} // key for delegator withdraw address ValidatorAccumulatedCommissionPrefix = []byte{0x07} // key for accumulated validator commission ParamStoreKeyCommunityTax = []byte("communitytax") ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled") )
Keys for distribution store Items are stored with the following key: values
- 0x01: sdk.ConsAddress
- 0x03<accAddr_Bytes>: sdk.AccAddress
- 0x07<valAddr_Bytes>: ValidatorCurrentRewards
var ( // TODO move to common testing package for all modules // test addresses TestAddrs = []sdk.AccAddress{ delAddr1, delAddr2, delAddr3, delAddr4, valAccAddr1, valAccAddr2, valAccAddr3, valAccAddr4, } )
nolint: deadcode unused
Functions ¶
func CanWithdrawInvariant ¶
CanWithdrawInvariant checks that current commission can be completely withdrawn
func GetDelegatorWithdrawAddrKey ¶
func GetDelegatorWithdrawAddrKey(delAddr sdk.AccAddress) []byte
GetDelegatorWithdrawAddrKey returns the key for a delegator's withdraw addr
func GetDelegatorWithdrawInfoAddress ¶
func GetDelegatorWithdrawInfoAddress(key []byte) (delAddr sdk.AccAddress)
GetDelegatorWithdrawInfoAddress returns an address from a delegator's withdraw info key
func GetTestAddrs ¶
func GetTestAddrs() ([]sdk.ValAddress, []crypto.PubKey, []sdk.ConsAddress)
GetTestAddrs returns valOpAddrs, valConsPks, valConsAddrs for test
func GetValidatorAccumulatedCommissionAddress ¶
func GetValidatorAccumulatedCommissionAddress(key []byte) (valAddr sdk.ValAddress)
GetValidatorAccumulatedCommissionAddress returns the address from a validator's accumulated commission key
func GetValidatorAccumulatedCommissionKey ¶
func GetValidatorAccumulatedCommissionKey(v sdk.ValAddress) []byte
GetValidatorAccumulatedCommissionKey returns the key for a validator's current commission
func HandleCommunityPoolSpendProposal ¶
func HandleCommunityPoolSpendProposal(ctx sdk.Context, k Keeper, p types.CommunityPoolSpendProposal) sdk.Error
HandleCommunityPoolSpendProposal is a handler for executing a passed community spend proposal
func MakeTestCodec ¶
MakeTestCodec creates a codec used only for testing
func ModuleAccountInvariant ¶
ModuleAccountInvariant checks that the coins held by the distr ModuleAccount is consistent with the sum of accumulated commissions
func NewQuerier ¶
NewQuerier creates a querier for distribution REST endpoints
func NewTestDecCoin ¶
NewTestDecCoin returns one dec coin
func NewTestDecCoins ¶
NewTestDecCoins returns dec coins
func NonNegativeCommissionsInvariant ¶
NonNegativeCommissionsInvariant checks that accumulated commissions unwithdrawned fees are never negative
func ParamKeyTable ¶
ParamKeyTable is the type declaration for parameters
func RegisterInvariants ¶
func RegisterInvariants(ir sdk.InvariantRegistry, k Keeper)
RegisterInvariants registers all distribution invariants
Types ¶
type Hooks ¶
type Hooks struct {
// contains filtered or unexported fields
}
Hooks is struct of keepers from other module
func (Hooks) AfterValidatorBeginUnbonding ¶
func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
func (Hooks) AfterValidatorBonded ¶
func (h Hooks) AfterValidatorBonded(_ sdk.Context, _ sdk.ConsAddress, _ sdk.ValAddress)
func (Hooks) AfterValidatorCreated ¶
func (h Hooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.ValAddress)
AfterValidatorCreated initializes validator distribution record
func (Hooks) AfterValidatorDestroyed ¶
func (h Hooks) AfterValidatorDestroyed(ctx sdk.Context, consAddr sdk.ConsAddress, valAddr sdk.ValAddress)
AfterValidatorDestroyed nothing to do
func (Hooks) AfterValidatorRemoved ¶
func (h Hooks) AfterValidatorRemoved(ctx sdk.Context, _ sdk.ConsAddress, valAddr sdk.ValAddress)
AfterValidatorRemoved cleans up for after validator is removed
func (Hooks) BeforeValidatorModified ¶
func (h Hooks) BeforeValidatorModified(_ sdk.Context, _ sdk.ValAddress)
nolint - unused hooks
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
Keeper of the distribution store
func CreateTestInputAdvanced ¶
func CreateTestInputAdvanced(t *testing.T, isCheckTx bool, initPower int64, communityTax sdk.Dec) ( sdk.Context, auth.AccountKeeper, bank.Keeper, Keeper, staking.Keeper, params.Keeper, types.SupplyKeeper)
CreateTestInputAdvanced 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, types.SupplyKeeper)
CreateTestInputDefault test input with default values
func NewKeeper ¶
func NewKeeper(cdc *codec.Codec, key sdk.StoreKey, paramSpace params.Subspace, sk types.StakingKeeper, supplyKeeper types.SupplyKeeper, codespace sdk.CodespaceType, feeCollectorName string, blacklistedAddrs map[string]bool) Keeper
NewKeeper creates a new distribution Keeper instance
func (Keeper) AllocateTokens ¶
func (k Keeper) AllocateTokens(ctx sdk.Context, totalPreviousPower int64, previousProposer sdk.ConsAddress, previousVotes []abci.VoteInfo)
AllocateTokens allocates fees from fee_collector 1. 25% rewards to validators, equally. 2. 75% rewards to validators and candidates, by shares' weight
func (Keeper) AllocateTokensToValidator ¶
func (k Keeper) AllocateTokensToValidator(ctx sdk.Context, val exported.ValidatorI, tokens sdk.DecCoins)
AllocateTokensToValidator allocate tokens to a particular validator, splitting according to commissions
func (Keeper) GetCommunityTax ¶
GetCommunityTax returns the current CommunityTax rate from the global param store nolint: errcheck
func (Keeper) GetDelegatorWithdrawAddr ¶
func (k Keeper) GetDelegatorWithdrawAddr(ctx sdk.Context, delAddr sdk.AccAddress) sdk.AccAddress
GetDelegatorWithdrawAddr returns the delegator withdraw address, defaulting to the delegator address
func (Keeper) GetDistributionAccount ¶
func (k Keeper) GetDistributionAccount(ctx sdk.Context) exported.ModuleAccountI
GetDistributionAccount returns the distribution ModuleAccount
func (Keeper) GetFeeCollectorName ¶
GetFeeCollectorName returns the name of fee_collector
func (Keeper) GetFeePool ¶
GetFeePool returns the global fee pool distribution info
func (Keeper) GetFeePoolCommunityCoins ¶
GetFeePoolCommunityCoins returns the community coins
func (Keeper) GetPreviousProposerConsAddr ¶
func (k Keeper) GetPreviousProposerConsAddr(ctx sdk.Context) (consAddr sdk.ConsAddress)
GetPreviousProposerConsAddr returns the proposer public key for this block
func (Keeper) GetValidatorAccumulatedCommission ¶
func (k Keeper) GetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress) ( commission types.ValidatorAccumulatedCommission)
GetValidatorAccumulatedCommission returns accumulated commission for a validator
func (Keeper) GetWithdrawAddrEnabled ¶
GetWithdrawAddrEnabled returns the current WithdrawAddrEnabled nolint: errcheck
func (Keeper) IterateDelegatorWithdrawAddrs ¶
func (k Keeper) IterateDelegatorWithdrawAddrs(ctx sdk.Context, handler func(del sdk.AccAddress, addr sdk.AccAddress) (stop bool))
IterateDelegatorWithdrawAddrs iterates over delegator withdraw addrs
func (Keeper) IterateValidatorAccumulatedCommissions ¶
func (k Keeper) IterateValidatorAccumulatedCommissions(ctx sdk.Context, handler func(val sdk.ValAddress, commission types.ValidatorAccumulatedCommission) (stop bool))
IterateValidatorAccumulatedCommissions iterates over accumulated commissions
func (Keeper) SetCommunityTax ¶
SetCommunityTax sets the value of community tax nolint: errcheck
func (Keeper) SetDelegatorWithdrawAddr ¶
func (k Keeper) SetDelegatorWithdrawAddr(ctx sdk.Context, delAddr, withdrawAddr sdk.AccAddress)
SetDelegatorWithdrawAddr sets the delegator withdraw address
func (Keeper) SetFeePool ¶
SetFeePool sets the global fee pool distribution info
func (Keeper) SetPreviousProposerConsAddr ¶
func (k Keeper) SetPreviousProposerConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress)
SetPreviousProposerConsAddr sets the proposer public key for this block
func (Keeper) SetValidatorAccumulatedCommission ¶
func (k Keeper) SetValidatorAccumulatedCommission(ctx sdk.Context, val sdk.ValAddress, commission types.ValidatorAccumulatedCommission)
SetValidatorAccumulatedCommission sets accumulated commission for a validator
func (Keeper) SetWithdrawAddr ¶
func (k Keeper) SetWithdrawAddr(ctx sdk.Context, delegatorAddr sdk.AccAddress, withdrawAddr sdk.AccAddress) sdk.Error
SetWithdrawAddr sets a new address that will receive the rewards upon withdrawal
func (Keeper) SetWithdrawAddrEnabled ¶
SetWithdrawAddrEnabled sets the value of enabled nolint: errcheck