Documentation ¶
Overview ¶
nolint
nolint
Index ¶
- Constants
- Variables
- func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNoDelegationDistInfo(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidatorCommission(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error
- func ErrSetWithdrawAddrDisabled(codespace sdk.CodespaceType) sdk.Error
- func RegisterCodec(cdc *codec.Codec)
- func ValidateGenesis(data GenesisState) error
- type BankKeeper
- type CodeType
- type DelegatorStartingInfo
- type DelegatorStartingInfoRecord
- type DelegatorWithdrawInfo
- type FeeCollectionKeeper
- type FeePool
- type GenesisState
- type MsgSetWithdrawAddress
- type MsgWithdrawDelegatorReward
- type MsgWithdrawValidatorCommission
- func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte
- func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress
- func (msg MsgWithdrawValidatorCommission) Route() string
- func (msg MsgWithdrawValidatorCommission) Type() string
- func (msg MsgWithdrawValidatorCommission) ValidateBasic() sdk.Error
- type StakingKeeper
- type ValidatorAccumulatedCommission
- type ValidatorAccumulatedCommissionRecord
- type ValidatorCurrentRewards
- type ValidatorCurrentRewardsRecord
- type ValidatorHistoricalRewards
- type ValidatorHistoricalRewardsRecord
- type ValidatorOutstandingRewards
- type ValidatorOutstandingRewardsRecord
- type ValidatorSlashEvent
- type ValidatorSlashEventRecord
- type ValidatorSlashEvents
Constants ¶
const ( // StoreKey is the store key string for distribution StoreKey = "distr" // TStoreKey is the transient store key for distribution TStoreKey = "transient_distr" // RouterKey is the message route for distribution RouterKey = "distr" // QuerierRoute is the querier route for distribution QuerierRoute = "distr" )
const MsgRoute = "distr"
name to identify transaction types
Variables ¶
var MsgCdc *codec.Codec
generic sealed codec to be used throughout module
Functions ¶
func ErrNilDelegatorAddr ¶
func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilValidatorAddr ¶
func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNilWithdrawAddr ¶
func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error
func ErrNoDelegationDistInfo ¶
func ErrNoDelegationDistInfo(codespace sdk.CodespaceType) sdk.Error
func ErrNoValidatorCommission ¶
func ErrNoValidatorCommission(codespace sdk.CodespaceType) sdk.Error
func ErrNoValidatorDistInfo ¶
func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error
func ErrSetWithdrawAddrDisabled ¶
func ErrSetWithdrawAddrDisabled(codespace sdk.CodespaceType) sdk.Error
func ValidateGenesis ¶
func ValidateGenesis(data GenesisState) error
ValidateGenesis validates the genesis state of distribution genesis input
Types ¶
type BankKeeper ¶
type BankKeeper interface {
AddCoins(ctx sdk.Context, addr sdk.AccAddress, amt sdk.Coins) (sdk.Coins, sdk.Tags, sdk.Error)
}
expected coin keeper
type DelegatorStartingInfo ¶
type DelegatorStartingInfo struct { // 即: 委托人应当从这个周期作为减持的起始~ PreviousPeriod uint64 `json:"previous_period"` // period at which the delegation should withdraw starting from // 委托人质押的token数量 Stake sdk.Dec `json:"stake"` // amount of staking token delegated // 创建委托时的区块高度 Height uint64 `json:"height"` // height at which delegation was created }
starting info for a delegator reward period tracks the previous validator period, the delegation's amount of staking token, and the creation height (to check later on if any slashes have occurred) NOTE that even though validators are slashed to whole staking tokens, the delegators within the validator may be left with less than a full token, thus sdk.Dec is used ** starting info: 是委托人的奖励期间追溯上一个验证人的期间, 委托人质押的token及发生委托时的高度.(为了检查后续是否有削减发生)
请注意,即使验证人s被削减了所有质押token, 验证人信息中的委托人可能会留下少于完整的标记,因此使用sdk.Dec (说的啥啊?
func NewDelegatorStartingInfo ¶
func NewDelegatorStartingInfo(previousPeriod uint64, stake sdk.Dec, height uint64) DelegatorStartingInfo
create a new DelegatorStartingInfo
type DelegatorStartingInfoRecord ¶
type DelegatorStartingInfoRecord struct { DelegatorAddress sdk.AccAddress `json:"delegator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address"` StartingInfo DelegatorStartingInfo `json:"starting_info"` }
used for import / export via genesis json
type DelegatorWithdrawInfo ¶
type DelegatorWithdrawInfo struct { DelegatorAddress sdk.AccAddress `json:"delegator_address"` WithdrawAddress sdk.AccAddress `json:"withdraw_address"` }
the address for where distributions rewards are withdrawn to by default this struct is only used at genesis to feed in default withdraw addresses
type FeeCollectionKeeper ¶
type FeeCollectionKeeper interface { GetCollectedFees(ctx sdk.Context) sdk.Coins ClearCollectedFees(ctx sdk.Context) }
expected fee collection keeper
type FeePool ¶
type FeePool struct { // 尚未花费的社区资金池 CommunityPool sdk.DecCoins `json:"community_pool"` // pool for community funds yet to be spent }
global fee pool for distribution 全局的佣金分配池?
func (FeePool) ValidateGenesis ¶
ValidateGenesis validates the fee pool for a genesis state
type GenesisState ¶
type GenesisState struct { FeePool FeePool `json:"fee_pool"` CommunityTax sdk.Dec `json:"community_tax"` BaseProposerReward sdk.Dec `json:"base_proposer_reward"` BonusProposerReward sdk.Dec `json:"bonus_proposer_reward"` WithdrawAddrEnabled bool `json:"withdraw_addr_enabled"` DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"` PreviousProposer sdk.ConsAddress `json:"previous_proposer"` OutstandingRewards []ValidatorOutstandingRewardsRecord `json:"outstanding_rewards"` ValidatorAccumulatedCommissions []ValidatorAccumulatedCommissionRecord `json:"validator_accumulated_commissions"` ValidatorHistoricalRewards []ValidatorHistoricalRewardsRecord `json:"validator_historical_rewards"` ValidatorCurrentRewards []ValidatorCurrentRewardsRecord `json:"validator_current_rewards"` DelegatorStartingInfos []DelegatorStartingInfoRecord `json:"delegator_starting_infos"` ValidatorSlashEvents []ValidatorSlashEventRecord `json:"validator_slash_events"` }
GenesisState - all distribution state that must be provided at genesis
func DefaultGenesisState ¶
func DefaultGenesisState() GenesisState
get raw genesis raw message for testing
func NewGenesisState ¶
func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec, withdrawAddrEnabled bool, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress, r []ValidatorOutstandingRewardsRecord, acc []ValidatorAccumulatedCommissionRecord, historical []ValidatorHistoricalRewardsRecord, cur []ValidatorCurrentRewardsRecord, dels []DelegatorStartingInfoRecord, slashes []ValidatorSlashEventRecord) GenesisState
type MsgSetWithdrawAddress ¶
type MsgSetWithdrawAddress struct { DelegatorAddress sdk.AccAddress `json:"delegator_address"` WithdrawAddress sdk.AccAddress `json:"withdraw_address"` }
msg struct for changing the withdraw address for a delegator (or validator self-delegation)
func NewMsgSetWithdrawAddress ¶
func NewMsgSetWithdrawAddress(delAddr, withdrawAddr sdk.AccAddress) MsgSetWithdrawAddress
func (MsgSetWithdrawAddress) GetSignBytes ¶
func (msg MsgSetWithdrawAddress) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgSetWithdrawAddress) GetSigners ¶
func (msg MsgSetWithdrawAddress) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgSetWithdrawAddress) Route ¶
func (msg MsgSetWithdrawAddress) Route() string
func (MsgSetWithdrawAddress) Type ¶
func (msg MsgSetWithdrawAddress) Type() string
func (MsgSetWithdrawAddress) ValidateBasic ¶
func (msg MsgSetWithdrawAddress) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawDelegatorReward ¶
type MsgWithdrawDelegatorReward struct { DelegatorAddress sdk.AccAddress `json:"delegator_address"` ValidatorAddress sdk.ValAddress `json:"validator_address"` }
msg struct for delegation withdraw from a single validator
func NewMsgWithdrawDelegatorReward ¶
func NewMsgWithdrawDelegatorReward(delAddr sdk.AccAddress, valAddr sdk.ValAddress) MsgWithdrawDelegatorReward
func (MsgWithdrawDelegatorReward) GetSignBytes ¶
func (msg MsgWithdrawDelegatorReward) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawDelegatorReward) GetSigners ¶
func (msg MsgWithdrawDelegatorReward) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawDelegatorReward) Route ¶
func (msg MsgWithdrawDelegatorReward) Route() string
func (MsgWithdrawDelegatorReward) Type ¶
func (msg MsgWithdrawDelegatorReward) Type() string
func (MsgWithdrawDelegatorReward) ValidateBasic ¶
func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error
quick validity check
type MsgWithdrawValidatorCommission ¶
type MsgWithdrawValidatorCommission struct {
ValidatorAddress sdk.ValAddress `json:"validator_address"`
}
msg struct for validator withdraw
func NewMsgWithdrawValidatorCommission ¶
func NewMsgWithdrawValidatorCommission(valAddr sdk.ValAddress) MsgWithdrawValidatorCommission
func (MsgWithdrawValidatorCommission) GetSignBytes ¶
func (msg MsgWithdrawValidatorCommission) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgWithdrawValidatorCommission) GetSigners ¶
func (msg MsgWithdrawValidatorCommission) GetSigners() []sdk.AccAddress
Return address that must sign over msg.GetSignBytes()
func (MsgWithdrawValidatorCommission) Route ¶
func (msg MsgWithdrawValidatorCommission) Route() string
func (MsgWithdrawValidatorCommission) Type ¶
func (msg MsgWithdrawValidatorCommission) Type() string
func (MsgWithdrawValidatorCommission) ValidateBasic ¶
func (msg MsgWithdrawValidatorCommission) ValidateBasic() sdk.Error
quick validity check
type StakingKeeper ¶
type StakingKeeper interface { IterateDelegations(ctx sdk.Context, delegator sdk.AccAddress, fn func(index int64, delegation sdk.Delegation) (stop bool)) Delegation(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.ValAddress) sdk.Delegation Validator(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Validator ValidatorByConsAddr(ctx sdk.Context, consAddr sdk.ConsAddress) sdk.Validator GetLastTotalPower(ctx sdk.Context) sdk.Int GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) int64 // used for invariants IterateValidators(ctx sdk.Context, fn func(index int64, validator sdk.Validator) (stop bool)) GetAllSDKDelegations(ctx sdk.Context) []sdk.Delegation }
expected staking keeper
type ValidatorAccumulatedCommission ¶
accumulated commission for a validator kept as a running counter, can be withdrawn at any time
func InitialValidatorAccumulatedCommission ¶
func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission
return the initial accumulated commission (zero)
type ValidatorAccumulatedCommissionRecord ¶
type ValidatorAccumulatedCommissionRecord struct { ValidatorAddress sdk.ValAddress `json:"validator_address"` Accumulated ValidatorAccumulatedCommission `json:"accumulated"` }
used for import / export via genesis json
type ValidatorCurrentRewards ¶
type ValidatorCurrentRewards struct { // 验证人的当前奖励 Rewards sdk.DecCoins `json:"rewards"` // current rewards // 验证人的当前周期 Period uint64 `json:"period"` // current period }
current rewards and current period for a validator kept as a running counter and incremented each block as long as the validator's tokens remain constant * 只要验证人的token保持不变, 验证人的当前奖励和当前周期将在每个递增的块中持续保持不变
func NewValidatorCurrentRewards ¶
func NewValidatorCurrentRewards(rewards sdk.DecCoins, period uint64) ValidatorCurrentRewards
create a new ValidatorCurrentRewards
type ValidatorCurrentRewardsRecord ¶
type ValidatorCurrentRewardsRecord struct { ValidatorAddress sdk.ValAddress `json:"validator_address"` Rewards ValidatorCurrentRewards `json:"rewards"` }
used for import / export via genesis json
type ValidatorHistoricalRewards ¶
type ValidatorHistoricalRewards struct { // 验证人的累积奖励 CumulativeRewardRatio sdk.DecCoins `json:"cumulative_reward_ratio"` // 参考计数 (用来做,代表着 上一个周期的 history还没被清算的标识) ReferenceCount uint16 `json:"reference_count"` }
historical rewards for a validator height is implicit within the store key cumulative reward ratio is the sum from the zeroeth period until this period of rewards / tokens, per the spec The reference count indicates the number of objects which might need to reference this historical entry at any point. ReferenceCount =
number of outstanding delegations which ended the associated period (and might need to read that record) + number of slashes which ended the associated period (and might need to read that record) + one per validator for the zeroeth period, set on initialization
*
验证人的历史奖励 height 是隐含在 存储key中 累积奖励比率是零周期到当前(奖励/token)周期的总和 参考计数表明,可能需要在任何点引用此历史条目的对象数。
参考计数 = 在期间结束后的优秀委托人数量(中选委托人?)(可能需要阅读该记录) + 在期间结束后的削减数量 (什么是削减啊? 都削减些什么啊?) + 在零周期的每个验证器, 即在初始化时设置
func NewValidatorHistoricalRewards ¶
func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoins, referenceCount uint16) ValidatorHistoricalRewards
create a new ValidatorHistoricalRewards
type ValidatorHistoricalRewardsRecord ¶
type ValidatorHistoricalRewardsRecord struct { ValidatorAddress sdk.ValAddress `json:"validator_address"` Period uint64 `json:"period"` Rewards ValidatorHistoricalRewards `json:"rewards"` }
used for import / export via genesis json
type ValidatorOutstandingRewards ¶
outstanding (un-withdrawn) rewards for a validator inexpensive to track, allows simple sanity checks
type ValidatorOutstandingRewardsRecord ¶
type ValidatorOutstandingRewardsRecord struct { ValidatorAddress sdk.ValAddress `json:"validator_address"` OutstandingRewards sdk.DecCoins `json:"outstanding_rewards"` }
used for import/export via genesis json
type ValidatorSlashEvent ¶
type ValidatorSlashEvent struct { ValidatorPeriod uint64 `json:"validator_period"` // period when the slash occurred Fraction sdk.Dec `json:"fraction"` // slash fraction }
validator slash event height is implicit within the store key needed to calculate appropriate amounts of staking token for delegations which withdraw after a slash has occurred
func NewValidatorSlashEvent ¶
func NewValidatorSlashEvent(validatorPeriod uint64, fraction sdk.Dec) ValidatorSlashEvent
create a new ValidatorSlashEvent
func (ValidatorSlashEvent) String ¶
func (vs ValidatorSlashEvent) String() string
type ValidatorSlashEventRecord ¶
type ValidatorSlashEventRecord struct { ValidatorAddress sdk.ValAddress `json:"validator_address"` Height uint64 `json:"height"` Event ValidatorSlashEvent `json:"validator_slash_event"` }
used for import / export via genesis json
type ValidatorSlashEvents ¶
type ValidatorSlashEvents []ValidatorSlashEvent
ValidatorSlashEvents is a collection of ValidatorSlashEvent
func (ValidatorSlashEvents) String ¶
func (vs ValidatorSlashEvents) String() string