types

package
v0.25.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 24, 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

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 = 6
	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 (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) 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 multiple

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"`
	WithdrawalHeight int64          `json:"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) WithdrawRewards

func (di DelegationDistInfo) WithdrawRewards(fp FeePool, vi ValidatorDistInfo,
	height int64, totalBonded, vdTokens, totalDelShares, delegatorShares,
	commissionRate 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
	Pool          DecCoins   `json:"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) 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().

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

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) 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

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) UpdateForNewHeight

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

update total validator 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:"global_withdrawal_height"` // last height this validator withdrew from the global pool
	Pool                    DecCoins `json:"pool"`                     // rewards owed to delegators, commission has already been charged (includes proposer reward)
	PoolCommission          DecCoins `json:"pool_commission"`          // commission collected by this validator (pending withdrawal)

	DelAccum TotalAccum `json:"del_accum"` // total proposer pool accumulation factor held by delegators
}

distribution info for a particular validator

func NewValidatorDistInfo

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

func (ValidatorDistInfo) TakeFeePoolRewards

func (vi ValidatorDistInfo) TakeFeePoolRewards(fp FeePool, height int64, totalBonded, vdTokens,
	commissionRate sdk.Dec) (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(fp FeePool, height int64,
	totalBonded, vdTokens, commissionRate sdk.Dec) (vio ValidatorDistInfo, fpo FeePool, withdrawn DecCoins)

withdraw commission rewards

Jump to

Keyboard shortcuts

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