types

package
v0.28.0 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2018 License: Apache-2.0 Imports: 6 Imported by: 0

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

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 ErrNoValidatorDistInfo

func ErrNoValidatorDistInfo(codespace sdk.CodespaceType) sdk.Error

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Register concrete types on codec codec

func ValidateGenesis added in v0.28.0

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 CodeType

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

type DecCoin

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

Coins which can have additional decimal points

func NewDecCoin

func NewDecCoin(denom string, amount int64) DecCoin

func NewDecCoinFromCoin

func NewDecCoinFromCoin(coin sdk.Coin) DecCoin

func NewDecCoinFromDec added in v0.27.0

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

func (DecCoin) Minus

func (coin DecCoin) Minus(coinB DecCoin) DecCoin

Subtracts amounts of two coins with same denom

func (DecCoin) Plus

func (coin DecCoin) Plus(coinB DecCoin) DecCoin

Adds amounts of two coins with same denom

func (DecCoin) TruncateDecimal

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

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

type DecCoins

type DecCoins []DecCoin

coins with decimal

func NewDecCoins

func NewDecCoins(coins sdk.Coins) DecCoins

func (DecCoins) AmountOf

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) IsZero added in v0.27.1

func (coins DecCoins) IsZero() bool

return whether all coins are zero

func (DecCoins) Minus

func (coins DecCoins) Minus(coinsB DecCoins) DecCoins

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

func (DecCoins) MulDec

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

multiply all the coins by a decimal

func (DecCoins) Negative

func (coins DecCoins) Negative() DecCoins

Negative returns a set of coins with all amount negative

func (DecCoins) Plus

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

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

divide all the coins by a decimal

func (DecCoins) TruncateDecimal

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

return the coins with trunctated decimals, and return the change

type DelegationDistInfo

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

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

func (DelegationDistInfo) CurrentRewards

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

get the delegators rewards at this current state,

func (DelegationDistInfo) GetDelAccum

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

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

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

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

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

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

func (FeePool) ValidateGenesis added in v0.28.0

func (f FeePool) ValidateGenesis() error

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"`
	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

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:"withdraw_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

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

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

func NewMsgWithdrawDelegatorRewardsAll

func NewMsgWithdrawDelegatorRewardsAll(delAddr sdk.AccAddress) MsgWithdrawDelegatorRewardsAll

func (MsgWithdrawDelegatorRewardsAll) GetSignBytes

func (msg MsgWithdrawDelegatorRewardsAll) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgWithdrawDelegatorRewardsAll) GetSigners

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

Return address that must sign over msg.GetSignBytes()

func (MsgWithdrawDelegatorRewardsAll) Route

func (MsgWithdrawDelegatorRewardsAll) Type

func (MsgWithdrawDelegatorRewardsAll) ValidateBasic

func (msg MsgWithdrawDelegatorRewardsAll) ValidateBasic() sdk.Error

quick validity check

type MsgWithdrawValidatorRewardsAll

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

msg struct for validator withdraw

func NewMsgWithdrawValidatorRewardsAll

func NewMsgWithdrawValidatorRewardsAll(valAddr sdk.ValAddress) MsgWithdrawValidatorRewardsAll

func (MsgWithdrawValidatorRewardsAll) GetSignBytes

func (msg MsgWithdrawValidatorRewardsAll) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgWithdrawValidatorRewardsAll) GetSigners

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

Return address that must sign over msg.GetSignBytes()

func (MsgWithdrawValidatorRewardsAll) Route

func (MsgWithdrawValidatorRewardsAll) Type

func (MsgWithdrawValidatorRewardsAll) ValidateBasic

func (msg MsgWithdrawValidatorRewardsAll) ValidateBasic() sdk.Error

quick validity check

type StakeKeeper

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

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

total accumulation tracker

func NewTotalAccum

func NewTotalAccum(height int64) TotalAccum

func (TotalAccum) GetAccum

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

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

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

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

func (ValidatorDistInfo) CurrentCommissionRewards

func (vi ValidatorDistInfo) CurrentCommissionRewards(
	wc WithdrawContext) DecCoins

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

func (ValidatorDistInfo) CurrentPoolRewards

func (vi ValidatorDistInfo) CurrentPoolRewards(
	wc WithdrawContext) DecCoins

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

func (ValidatorDistInfo) GetTotalDelAccum

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

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

Get the validator accum at the provided height

func (ValidatorDistInfo) TakeFeePoolRewards

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

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

update total delegator accumululation

func (ValidatorDistInfo) WithdrawCommission

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

withdraw commission rewards

type WithdrawContext

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

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