types

package
v1.5.32 Latest Latest
Warning

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

Go to latest
Published: Sep 15, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventTypeModifyWithdrawAddress = "modify_withdraw_address"
	EventTypeWithdrawCommission    = "withdraw_commission"
	EventTypeWithdrawRewards       = "withdraw_rewards"
	EventTypeFundCommunityPool     = "fund_community_pool"

	AttributeKeyWithdrawAddress = "withdraw_address"
	AttributeValueCategory      = ModuleName
	AttributeKeyValidator       = "validator"
)
View Source
const (
	ModuleName        = "distribution"
	RouteKey          = ModuleName
	DefaultParamspace = ModuleName
)
View Source
const (
	QueryValidatorOutstandingRewards = "validator_outstanding_rewards"
	QueryCommunityPool               = "community_pool"
	QueryWithdrawAddress             = "withdraw_address"
	QueryValidatorCommission         = "validator_commission"
	QueryDelegationRewards           = "delegation_rewards"
	QueryAccountInfo                 = "account_info"
)

Variables

View Source
var (
	ErrInvalidParams               = sdkerrors.Register(string(DefaultCodespace), uint32(CodeErrInvalidParams), "invalid params")
	ErrEmptyDelegationStartingInfo = sdkerrors.Register(string(DefaultCodespace), uint32(CodeEmptyDelegationStartingInfo), "empty delegation starting info")

	ErrNoValidatorExist        = sdkerrors.Register(string(DefaultCodespace), uint32(CodeNoValidatorExist), "no validator exist")
	ErrInternalCdcMarshal      = sdkerrors.Register(string(DefaultCodespace), uint32(CodeCdcMarshalFailed), "cdc marshal failed")
	ErrNoDelegationExist       = sdkerrors.Register(string(DefaultCodespace), uint32(CodeNoDelegationExist), "no delegation exist")
	ErrSetWithdrawAddrDisabled = sdkerrors.Register(string(DefaultCodespace), uint32(CodeSetWithdrawAddressFailed), "set withdraw addresss disabled")
	ErrNoValidatorCommission   = sdkerrors.Register(string(DefaultCodespace), uint32(CodeNoValidatorCommission), "the validator has no commission now")
)
View Source
var (
	FeePoolKey                           = []byte{0x00}
	ProposerKey                          = []byte{001}
	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
)
View Source
var (
	ParamStoreKeyCommunityTax        = []byte("communitytax")
	ParamStoreKeyBaseProposerReward  = []byte("baseproposerreward")
	ParamStoreKeyBonusProposerReward = []byte("bonusproposerreward")
	ParamStoreKeyWithdrawAddrEnabled = []byte("withdrawaddrenabled")
)

Parameter keys

View Source
var DistributionCdc *codec.Codec

Functions

func GetDelegatorStartingInfoKey

func GetDelegatorStartingInfoKey(v sdk.AccAddress, 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 GetValidatorAccumulatedCommissionKey

func GetValidatorAccumulatedCommissionKey(v sdk.AccAddress) []byte

func GetValidatorCurrentRewardsKey

func GetValidatorCurrentRewardsKey(v sdk.AccAddress) []byte

func GetValidatorHistoricalRewardsKey

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

gets the key for a validator's historical rewards

func GetValidatorHistoricalRewardsPrefix

func GetValidatorHistoricalRewardsPrefix(v sdk.AccAddress) []byte

gets the prefix key for a validator's historical rewards

func GetValidatorOutstandingRewardsKey

func GetValidatorOutstandingRewardsKey(valAddr sdk.AccAddress) []byte

gets the outstanding rewards key for a validator

func GetValidatorSlashEventKey

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

gets the key for a validator's slash fraction

func GetValidatorSlashEventKeyPrefix

func GetValidatorSlashEventKeyPrefix(v sdk.AccAddress, height uint64) []byte

gets the prefix key for a validator's slash fraction (ValidatorSlashEventPrefix + height)

func GetValidatorSlashEventPrefix

func GetValidatorSlashEventPrefix(v sdk.AccAddress) []byte

gets the prefix key for a validator's slash fractions

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamKeyTable returns the parameter key table.

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

func ValidateGenesis

func ValidateGenesis(gs GenesisState) error

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = "distribution"

	CodeEmptyDelegationStartingInfo CodeType = 1403

	CodeNoValidatorExist CodeType = 1404

	CodeCdcMarshalFailed CodeType = 1405

	CodeNoDelegationExist CodeType = 1406

	CodeSetWithdrawAddressFailed CodeType = 1407

	CodeNoValidatorDistInfo CodeType = 1408

	CodeNoDelegationDistInfo CodeType = 1409

	CodeNoValidatorCommission CodeType = 1410

	CodeErrInvalidParams CodeType = 1411
)

type DelegatorAccountInfo

type DelegatorAccountInfo struct {
	Available  sdk.Coin       `json:"available"`  ///本账户余额
	Delegated  sdk.Coin       `json:"delegated"`  ///本账户所有的抵押数
	Unbonding  sdk.Coin       `json:"unbonding"`  ///当前处于解押时期中的资金总数
	Reward     RewardsAccount `json:"reward"`     ///目前可提取的奖励总数(从上次提取奖励到现在)
	Commission sdk.Coin       `json:"commission"` ///本验证者账户目前可提取的佣金数(从上次提取佣金到现在,不是验证者账户则为0)
}

func NewDelegatorAccountInfo

func NewDelegatorAccountInfo(available, delegated, unbonding, commission sdk.Coin, reward RewardsAccount) DelegatorAccountInfo

type DelegatorStartingInfo

type DelegatorStartingInfo struct {
	PreviousPeriod uint64  `json:"previous_period"`
	Stake          sdk.Dec `json:"stake"`
	Height         uint64  `json:"height"`
}

PreviousPeriod:形成当前StartingInfo的时期;PreviousPeriod = CurrentRewards.Period - 1; Stake: 该委托者拥有的令牌数量; stake = Delegator.Shares * validator.Tokens/validator.Shares Height: 形成当前StartingInfo的区块高度;

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.AccAddress        `json:"validator_address"`
	StartingInfo     DelegatorStartingInfo `json:"starting_info"`
}

StartingInfo 包含上一次操作的时期,比如 抵押或提取奖金; 包含 Delegator拥有的令牌数,即token数量; Height指上一次操作的高度;

type DelegatorWithdrawInfo

type DelegatorWithdrawInfo struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
	WithdrawAddress  sdk.AccAddress `json:"withdraw_address"`
}

type FeePool

type FeePool struct {
	//
	CommunityPool sdk.DecCoin `json:"community_pool"`
}

func InitialFeePool

func InitialFeePool() FeePool

func (FeePool) ValidateGenesis

func (f FeePool) ValidateGenesis() error

type GenesisState

type GenesisState struct {
	Params                          Params                                 `json:"params"`
	FeePool                         FeePool                                `json:"fee_pool"`
	DelegatorWithdrawInfos          []DelegatorWithdrawInfo                `json:"delegator_withdraw_infos"`
	PreviousProposer                sdk.AccAddr                            `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"`
}

func DefaultGenesisState

func DefaultGenesisState(_ []tmtypes.GenesisValidator) GenesisState

get raw genesis raw message for testing

type MsgFundCommunityPool

type MsgFundCommunityPool struct {
	FromAddress sdk.AccAddress `json:"from_address"`
	Amount      sdk.Coin       `json:"amount"`
	Depositor   sdk.AccAddress `json:"depositor"`
}

func NewMsgFundCommunityPool

func NewMsgFundCommunityPool(from sdk.AccAddress, amount sdk.Coin, _, _ uint64, depositor sdk.AccAddress) *MsgFundCommunityPool

func (*MsgFundCommunityPool) Bytes

func (msg *MsgFundCommunityPool) Bytes() []byte

func (*MsgFundCommunityPool) GetFromAddress

func (msg *MsgFundCommunityPool) GetFromAddress() sdk.AccAddress

func (*MsgFundCommunityPool) MsgType

func (msg *MsgFundCommunityPool) MsgType() string

func (*MsgFundCommunityPool) Route

func (msg *MsgFundCommunityPool) Route() string

Route returns the MsgFundCommunityPool message route.

func (*MsgFundCommunityPool) ValidateBasic

func (msg *MsgFundCommunityPool) ValidateBasic() error

ValidateBasic performs basic MsgFundCommunityPool message validation.

type MsgSetWithdrawAddress

type MsgSetWithdrawAddress struct {
	FromAddress      sdk.AccAddress `json:"from_address"`
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
	WithdrawAddress  sdk.AccAddress `json:"withdraw_address"`
}

func NewMsgSetWithdrawAddress

func NewMsgSetWithdrawAddress(from, withdraw, del sdk.AccAddress) *MsgSetWithdrawAddress

func (*MsgSetWithdrawAddress) Bytes

func (msg *MsgSetWithdrawAddress) Bytes() []byte

func (*MsgSetWithdrawAddress) GetFromAddress

func (msg *MsgSetWithdrawAddress) GetFromAddress() sdk.AccAddress

func (*MsgSetWithdrawAddress) MsgType

func (msg *MsgSetWithdrawAddress) MsgType() string

func (*MsgSetWithdrawAddress) Route

func (msg *MsgSetWithdrawAddress) Route() string

func (*MsgSetWithdrawAddress) ValidateBasic

func (msg *MsgSetWithdrawAddress) ValidateBasic() error

type MsgWithdrawDelegatorReward

type MsgWithdrawDelegatorReward struct {
	FromAddress      sdk.AccAddress `json:"from_address"`
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
	ValidatorAddress sdk.AccAddress `json:"validator_address"`
}

func NewMsgWithdrawDelegatorReward

func NewMsgWithdrawDelegatorReward(from, val, del sdk.AccAddress) *MsgWithdrawDelegatorReward

func (*MsgWithdrawDelegatorReward) Bytes

func (msg *MsgWithdrawDelegatorReward) Bytes() []byte

func (*MsgWithdrawDelegatorReward) GetFromAddress

func (msg *MsgWithdrawDelegatorReward) GetFromAddress() sdk.AccAddress

func (*MsgWithdrawDelegatorReward) MsgType

func (msg *MsgWithdrawDelegatorReward) MsgType() string

func (*MsgWithdrawDelegatorReward) Route

func (msg *MsgWithdrawDelegatorReward) Route() string

func (*MsgWithdrawDelegatorReward) ValidateBasic

func (msg *MsgWithdrawDelegatorReward) ValidateBasic() error

type MsgWithdrawValidatorCommission

type MsgWithdrawValidatorCommission struct {
	FromAddress      sdk.AccAddress `json:"from_address"`
	ValidatorAddress sdk.AccAddress `json:"validator_address"`
}

func NewMsgWithdrawValidatorCommission

func NewMsgWithdrawValidatorCommission(from, val sdk.AccAddress) *MsgWithdrawValidatorCommission

func (*MsgWithdrawValidatorCommission) Bytes

func (msg *MsgWithdrawValidatorCommission) Bytes() []byte

func (*MsgWithdrawValidatorCommission) GetFromAddress

func (msg *MsgWithdrawValidatorCommission) GetFromAddress() sdk.AccAddress

func (*MsgWithdrawValidatorCommission) MsgType

func (msg *MsgWithdrawValidatorCommission) MsgType() string

func (*MsgWithdrawValidatorCommission) Route

func (*MsgWithdrawValidatorCommission) ValidateBasic

func (msg *MsgWithdrawValidatorCommission) ValidateBasic() error

type Params

type Params struct {
	CommunityTax        sdk.Dec `json:"community_tax"`
	BaseProposerReward  sdk.Dec `json:"base_proposer_reward"`
	BonusProposerReward sdk.Dec `json:"bounse_proposer_reward"`
	WithdrawAddrEnabled bool    `json:"withdraw_addr_enable"`
}

CommunityTax : 增发货币 流向社区的百分比 BaseProposerReward: 基础提块奖励百分比 BonusProposerReward: 绑定提案奖励百分比 WithdrawAddrEnabled: 是否能更改提起奖金地址

func DefaultParams

func DefaultParams() Params

func (*Params) ParamSetPairs

func (p *Params) ParamSetPairs() params.ParamSetPairs

func (Params) ValidateBasic

func (p Params) ValidateBasic() error

type QueryDelegationRewardsParams

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

params for query 'custom/distr/delegation_rewards'

func NewQueryDelegationRewardsParams

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

creates a new instance of QueryDelegationRewardsParams

type QueryDelegatorBalanceParams

type QueryDelegatorBalanceParams struct {
	AccountAddress sdk.AccAddress `json:"account_address" yaml:"account_address"`
}

func NewQueryDelegatorBalanceParams

func NewQueryDelegatorBalanceParams(accountAddr sdk.AccAddress) QueryDelegatorBalanceParams

type QueryDelegatorParams

type QueryDelegatorParams struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address" yaml:"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" yaml:"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.AccAddress `json:"validator_address" yaml:"validator_address"`
}

params for query 'custom/distr/validator_commission'

func NewQueryValidatorCommissionParams

func NewQueryValidatorCommissionParams(validatorAddr sdk.AccAddress) QueryValidatorCommissionParams

creates a new instance of QueryValidatorCommissionParams

type QueryValidatorOutstandingRewardsParams

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

params for query 'custom/distr/validator_outstanding_rewards'

func NewQueryValidatorOutstandingRewardsParams

func NewQueryValidatorOutstandingRewardsParams(validatorAddr sdk.AccAddress) QueryValidatorOutstandingRewardsParams

creates a new instance of QueryValidatorOutstandingRewardsParams

type RewardAccount

type RewardAccount struct {
	Amount  sdk.Coin `json:"amount"`
	Address string   `json:"address"`
}

type RewardsAccount

type RewardsAccount struct {
	sdk.Coin
	Validator []RewardAccount `json:"validator"`
}

func NewRewardsAccount

func NewRewardsAccount(amount sdk.Coin, validators []RewardAccount) RewardsAccount

type ValidatorAccumulatedCommission

type ValidatorAccumulatedCommission struct {
	Commission sdk.DecCoin `json:"commission"`
}

验证者的佣金

func InitialValidatorAccumulatedCommission

func InitialValidatorAccumulatedCommission() ValidatorAccumulatedCommission

return the initial accumulated commission (zero)

type ValidatorAccumulatedCommissionRecord

type ValidatorAccumulatedCommissionRecord struct {
	ValidatorAddress sdk.AccAddress                 `json:"validator_address"`
	Accumulated      ValidatorAccumulatedCommission `json:"accumulated"`
}

Accumulated 代表这个validator所拥有的佣金;

type ValidatorCurrentRewards

type ValidatorCurrentRewards struct {
	Rewards sdk.DecCoin `json:"rewards"`
	Period  uint64      `json:"period"`
}

Period: 时期; Rewards: 奖金数量;累积值;每次的提取奖金操作会更新Period; 每次+1;

func NewValidatorCurrentRewards

func NewValidatorCurrentRewards(rewards sdk.DecCoin, period uint64) ValidatorCurrentRewards

type ValidatorCurrentRewardsRecord

type ValidatorCurrentRewardsRecord struct {
	ValidatorAddress sdk.AccAddress          `json:"validator_address"`
	Rewards          ValidatorCurrentRewards `json:"rewards"`
}

ValidatorCurrentRewardsRecord 包含一个Period 时期,其中的Rewards 只代表 这个时期到目前的块高度为止,所积累的奖金数;

type ValidatorHistoricalRewards

type ValidatorHistoricalRewards struct {
	CumulativeRewardRatio sdk.DecCoin `json:"cumulative_reward_ratio"`
	ReferenceCount        uint32      `json:"reference_count"`
}

以validator地址 和 period时期 作为key来存储;表示到某个时期为止,这个validator所获得的所有奖金; CumulativeRewardRatio: 累积的奖金数(表示的是每一个token所拥有的奖金数;)

func NewValidatorHistoricalRewards

func NewValidatorHistoricalRewards(cumulativeRewardRatio sdk.DecCoin, referenceCount uint32) ValidatorHistoricalRewards

type ValidatorHistoricalRewardsRecord

type ValidatorHistoricalRewardsRecord struct {
	ValidatorAddress sdk.AccAddress             `json:"validator_address"`
	Period           uint64                     `json:"period"`
	Rewards          ValidatorHistoricalRewards `json:"rewards"`
}

Rewards 指代 到当前这个时期为止,一个Token所拥有的价值;

type ValidatorOutstandingRewards

type ValidatorOutstandingRewards struct {
	Rewards sdk.DecCoin `json:"rewards"`
}

validator总的获得的奖金数;包括佣金,奖金

type ValidatorOutstandingRewardsRecord

type ValidatorOutstandingRewardsRecord struct {
	ValidatorAddress   sdk.AccAddress `json:"validator_address"`
	OutstandingRewards sdk.DecCoin    `json:"outstanding_rewards"`
}

OutstandingRewards 代表这个Validator所拥有的所有奖金;

type ValidatorSlashEvent

type ValidatorSlashEvent struct {
	ValidatorPeriod uint64  `json:"validator_period"`
	Fraction        sdk.Dec `json:"fraction"`
}

惩罚

type ValidatorSlashEventRecord

type ValidatorSlashEventRecord struct {
	ValidatorAddress sdk.AccAddress      `json:"validator_address"`
	Height           uint64              `json:"height"`
	Period           uint64              `json:"period"`
	Event            ValidatorSlashEvent `json:"event"`
}

Jump to

Keyboard shortcuts

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