types

package
v0.27.0-rc1 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: Apache-2.0 Imports: 6 Imported by: 3,095

Documentation

Overview

nolint

nolint

Index

Constants

View Source
const MsgRoute = "distr"

name to identify transaction types

Variables

View Source
var MsgCdc *codec.Codec

generic sealed codec to be used throughout module

Functions

func ErrNilDelegatorAddr added in v0.25.0

func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNilValidatorAddr added in v0.25.0

func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNilWithdrawAddr added in v0.25.0

func ErrNilWithdrawAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNoDelegationDistInfo added in v0.25.0

func ErrNoDelegationDistInfo(codespace sdk.CodespaceType) sdk.Error

func ErrNoValidatorDistInfo

func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

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

type CodeType = sdk.CodeType
const (
	DefaultCodespace       sdk.CodespaceType = "DISTR"
	CodeInvalidInput       CodeType          = 103
	CodeNoDistributionInfo CodeType          = 104
)

type DecCoin added in v0.25.0

type DecCoin struct {
	Denom  string  `json:"denom"`
	Amount sdk.Dec `json:"amount"`
}

Coins which can have additional decimal points

func NewDecCoin added in v0.25.0

func NewDecCoin(denom string, amount int64) DecCoin

func NewDecCoinFromCoin added in v0.25.0

func NewDecCoinFromCoin(coin sdk.Coin) DecCoin

func NewDecCoinFromDec added in v0.27.0

func NewDecCoinFromDec(denom string, amount sdk.Dec) DecCoin

func (DecCoin) Minus added in v0.25.0

func (coin DecCoin) Minus(coinB DecCoin) DecCoin

Subtracts amounts of two coins with same denom

func (DecCoin) Plus added in v0.25.0

func (coin DecCoin) Plus(coinB DecCoin) DecCoin

Adds amounts of two coins with same denom

func (DecCoin) TruncateDecimal added in v0.25.0

func (coin DecCoin) TruncateDecimal() (sdk.Coin, DecCoin)

return the decimal coins with trunctated decimals, and return the change

type DecCoins added in v0.25.0

type DecCoins []DecCoin

coins with decimal

func NewDecCoins added in v0.25.0

func NewDecCoins(coins sdk.Coins) DecCoins

func (DecCoins) AmountOf added in v0.25.0

func (coins DecCoins) AmountOf(denom string) sdk.Dec

returns the amount of a denom from deccoins

func (DecCoins) HasNegative added in v0.27.0

func (coins DecCoins) HasNegative() bool

has a negative DecCoin amount

func (DecCoins) Minus added in v0.25.0

func (coins DecCoins) Minus(coinsB DecCoins) DecCoins

Minus subtracts a set of coins from another (adds the inverse)

func (DecCoins) MulDec added in v0.25.0

func (coins DecCoins) MulDec(d sdk.Dec) DecCoins

multiply all the coins by a decimal

func (DecCoins) Negative added in v0.25.0

func (coins DecCoins) Negative() DecCoins

Negative returns a set of coins with all amount negative

func (DecCoins) Plus added in v0.25.0

func (coins DecCoins) Plus(coinsB DecCoins) DecCoins

Plus combines two sets of coins CONTRACT: Plus will never return Coins where one Coin has a 0 amount.

func (DecCoins) QuoDec added in v0.25.0

func (coins DecCoins) QuoDec(d sdk.Dec) DecCoins

divide all the coins by a decimal

func (DecCoins) TruncateDecimal added in v0.25.0

func (coins DecCoins) TruncateDecimal() (sdk.Coins, DecCoins)

return the coins with trunctated decimals, and return the change

type DelegationDistInfo added in v0.25.0

type DelegationDistInfo struct {
	DelegatorAddr           sdk.AccAddress `json:"delegator_addr"`
	ValOperatorAddr         sdk.ValAddress `json:"val_operator_addr"`
	DelPoolWithdrawalHeight int64          `json:"del_pool_withdrawal_height"` // last time this delegation withdrew rewards
}

distribution info for a delegation - used to determine entitled rewards

func NewDelegationDistInfo added in v0.25.0

func NewDelegationDistInfo(delegatorAddr sdk.AccAddress, valOperatorAddr sdk.ValAddress,
	currentHeight int64) DelegationDistInfo

func (DelegationDistInfo) CurrentRewards added in v0.25.0

func (di DelegationDistInfo) CurrentRewards(wc WithdrawContext, vi ValidatorDistInfo,
	totalDelShares, delegatorShares sdk.Dec) DecCoins

get the delegators rewards at this current state,

func (DelegationDistInfo) GetDelAccum added in v0.25.0

func (di DelegationDistInfo) GetDelAccum(height int64, delegatorShares sdk.Dec) sdk.Dec

Get the calculated accum of this delegator at the provided height

func (DelegationDistInfo) WithdrawRewards added in v0.25.0

func (di DelegationDistInfo) WithdrawRewards(wc WithdrawContext, vi ValidatorDistInfo,
	totalDelShares, delegatorShares sdk.Dec) (
	DelegationDistInfo, ValidatorDistInfo, FeePool, DecCoins)

Withdraw rewards from delegator. Among many things, it does: * updates validator info's total del accum * calls vi.TakeFeePoolRewards, which:

  • updates validator info's FeePoolWithdrawalHeight, thus setting accum to 0
  • updates fee pool to latest height and total val accum w/ given totalBonded (see comment on TakeFeePoolRewards for more info)

type DelegatorWithdrawInfo

type DelegatorWithdrawInfo struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	WithdrawAddr  sdk.AccAddress `json:"withdraw_addr"`
}

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

type FeeCollectionKeeper interface {
	GetCollectedFees(ctx sdk.Context) sdk.Coins
	ClearCollectedFees(ctx sdk.Context)
}

from ante handler

type FeePool

type FeePool struct {
	TotalValAccum TotalAccum `json:"val_accum"`      // total valdator accum held by validators
	ValPool       DecCoins   `json:"val_pool"`       // funds for all validators which have yet to be withdrawn
	CommunityPool DecCoins   `json:"community_pool"` // pool for community funds yet to be spent
}

global fee pool for distribution

func InitialFeePool

func InitialFeePool() FeePool

zero fee pool

func (FeePool) GetTotalValAccum added in v0.25.0

func (f FeePool) GetTotalValAccum(height int64, totalBondedTokens sdk.Dec) sdk.Dec

get the total validator accum for the fee pool without modifying the state

func (FeePool) UpdateTotalValAccum added in v0.25.0

func (f FeePool) UpdateTotalValAccum(height int64, totalBondedTokens sdk.Dec) FeePool

update total validator accumulation factor NOTE: Do not call this except from ValidatorDistInfo.TakeFeePoolRewards().

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"`
	ValidatorDistInfos     []ValidatorDistInfo     `json:"validator_dist_infos"`
	DelegationDistInfos    []DelegationDistInfo    `json:"delegator_dist_infos"`
	DelegatorWithdrawInfos []DelegatorWithdrawInfo `json:"delegator_withdraw_infos"`
	PreviousProposer       sdk.ConsAddress         `json:"previous_proposer"`
}

GenesisState - all distribution state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func DefaultGenesisWithValidators added in v0.25.0

func DefaultGenesisWithValidators(valAddrs []sdk.ValAddress) GenesisState

default genesis utility function, initialize for starting validator set

func NewGenesisState

func NewGenesisState(feePool FeePool, communityTax, baseProposerReward, bonusProposerReward sdk.Dec,
	vdis []ValidatorDistInfo, ddis []DelegationDistInfo, dwis []DelegatorWithdrawInfo, pp sdk.ConsAddress) GenesisState

type MsgSetWithdrawAddress

type MsgSetWithdrawAddress struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	WithdrawAddr  sdk.AccAddress `json:"delegator_addr"`
}

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 {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}

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 (MsgWithdrawDelegatorReward) ValidateBasic

func (msg MsgWithdrawDelegatorReward) ValidateBasic() sdk.Error

quick validity check

type MsgWithdrawDelegatorRewardsAll added in v0.25.0

type MsgWithdrawDelegatorRewardsAll struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
}

msg struct for delegation withdraw for all of the delegator's delegations

func NewMsgWithdrawDelegatorRewardsAll added in v0.25.0

func NewMsgWithdrawDelegatorRewardsAll(delAddr sdk.AccAddress) MsgWithdrawDelegatorRewardsAll

func (MsgWithdrawDelegatorRewardsAll) GetSignBytes added in v0.25.0

func (msg MsgWithdrawDelegatorRewardsAll) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgWithdrawDelegatorRewardsAll) GetSigners added in v0.25.0

func (msg MsgWithdrawDelegatorRewardsAll) GetSigners() []sdk.AccAddress

Return address that must sign over msg.GetSignBytes()

func (MsgWithdrawDelegatorRewardsAll) Route added in v0.25.0

func (MsgWithdrawDelegatorRewardsAll) Type added in v0.25.0

func (MsgWithdrawDelegatorRewardsAll) ValidateBasic added in v0.25.0

func (msg MsgWithdrawDelegatorRewardsAll) ValidateBasic() sdk.Error

quick validity check

type MsgWithdrawValidatorRewardsAll added in v0.25.0

type MsgWithdrawValidatorRewardsAll struct {
	ValidatorAddr sdk.ValAddress `json:"validator_addr"`
}

msg struct for validator withdraw

func NewMsgWithdrawValidatorRewardsAll added in v0.25.0

func NewMsgWithdrawValidatorRewardsAll(valAddr sdk.ValAddress) MsgWithdrawValidatorRewardsAll

func (MsgWithdrawValidatorRewardsAll) GetSignBytes added in v0.25.0

func (msg MsgWithdrawValidatorRewardsAll) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgWithdrawValidatorRewardsAll) GetSigners added in v0.25.0

func (msg MsgWithdrawValidatorRewardsAll) GetSigners() []sdk.AccAddress

Return address that must sign over msg.GetSignBytes()

func (MsgWithdrawValidatorRewardsAll) Route added in v0.25.0

func (MsgWithdrawValidatorRewardsAll) Type added in v0.25.0

func (MsgWithdrawValidatorRewardsAll) ValidateBasic added in v0.25.0

func (msg MsgWithdrawValidatorRewardsAll) ValidateBasic() sdk.Error

quick validity check

type StakeKeeper added in v0.25.0

type StakeKeeper 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
	TotalPower(ctx sdk.Context) sdk.Dec
	GetLastTotalPower(ctx sdk.Context) sdk.Int
	GetLastValidatorPower(ctx sdk.Context, valAddr sdk.ValAddress) sdk.Int
}

expected stake keeper

type TotalAccum added in v0.25.0

type TotalAccum struct {
	UpdateHeight int64   `json:"update_height"`
	Accum        sdk.Dec `json:"accum"`
}

total accumulation tracker

func NewTotalAccum added in v0.25.0

func NewTotalAccum(height int64) TotalAccum

func (TotalAccum) GetAccum added in v0.25.0

func (ta TotalAccum) GetAccum(height int64, accumCreatedPerBlock sdk.Dec) sdk.Dec

get total accumulation factor for the given height CONTRACT: height should be greater than the old height

func (TotalAccum) UpdateForNewHeight added in v0.25.0

func (ta TotalAccum) UpdateForNewHeight(height int64, accumCreatedPerBlock sdk.Dec) TotalAccum

update total accumulation factor for the new height CONTRACT: height should be greater than the old height

type ValidatorDistInfo added in v0.25.0

type ValidatorDistInfo struct {
	OperatorAddr sdk.ValAddress `json:"operator_addr"`

	FeePoolWithdrawalHeight int64 `json:"fee_pool_withdrawal_height"` // last height this validator withdrew from the global pool

	DelAccum      TotalAccum `json:"del_accum"`      // total accumulation factor held by delegators
	DelPool       DecCoins   `json:"del_pool"`       // rewards owed to delegators, commission has already been charged (includes proposer reward)
	ValCommission DecCoins   `json:"val_commission"` // commission collected by this validator (pending withdrawal)
}

distribution info for a particular validator

func NewValidatorDistInfo added in v0.25.0

func NewValidatorDistInfo(operatorAddr sdk.ValAddress, currentHeight int64) ValidatorDistInfo

func (ValidatorDistInfo) CurrentCommissionRewards added in v0.25.0

func (vi ValidatorDistInfo) CurrentCommissionRewards(
	wc WithdrawContext) DecCoins

get the validator's commission pool rewards at this current state,

func (ValidatorDistInfo) CurrentPoolRewards added in v0.25.0

func (vi ValidatorDistInfo) CurrentPoolRewards(
	wc WithdrawContext) DecCoins

get the validator's pool rewards at this current state,

func (ValidatorDistInfo) GetTotalDelAccum added in v0.25.0

func (vi ValidatorDistInfo) GetTotalDelAccum(height int64, totalDelShares sdk.Dec) sdk.Dec

Get the total delegator accum within this validator at the provided height

func (ValidatorDistInfo) GetValAccum added in v0.25.0

func (vi ValidatorDistInfo) GetValAccum(height int64, valTokens sdk.Dec) sdk.Dec

Get the validator accum at the provided height

func (ValidatorDistInfo) TakeFeePoolRewards added in v0.25.0

func (vi ValidatorDistInfo) TakeFeePoolRewards(wc WithdrawContext) (
	ValidatorDistInfo, FeePool)

Move any available accumulated fees in the FeePool to the validator's pool - updates validator info's FeePoolWithdrawalHeight, thus setting accum to 0 - updates fee pool to latest height and total val accum w/ given totalBonded This is the only way to update the FeePool's validator TotalAccum. NOTE: This algorithm works as long as TakeFeePoolRewards is called after every power change. - called in ValidationDistInfo.WithdrawCommission - called in DelegationDistInfo.WithdrawRewards NOTE: When a delegator unbonds, say, onDelegationSharesModified ->

WithdrawDelegationReward -> WithdrawRewards

func (ValidatorDistInfo) UpdateTotalDelAccum added in v0.25.0

func (vi ValidatorDistInfo) UpdateTotalDelAccum(height int64, totalDelShares sdk.Dec) ValidatorDistInfo

update total delegator accumululation

func (ValidatorDistInfo) WithdrawCommission added in v0.25.0

func (vi ValidatorDistInfo) WithdrawCommission(wc WithdrawContext) (
	vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins)

withdraw commission rewards

type WithdrawContext added in v0.25.0

type WithdrawContext struct {
	FeePool        FeePool
	Height         int64   // block height
	TotalPower     sdk.Dec // total bonded tokens in the network
	ValPower       sdk.Dec // validator's bonded tokens
	CommissionRate sdk.Dec // validator commission rate
}

common parameters used in withdraws from validators

func NewWithdrawContext added in v0.25.0

func NewWithdrawContext(feePool FeePool, height int64, totalPower,
	valPower, commissionRate sdk.Dec) WithdrawContext

Jump to

Keyboard shortcuts

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