types

package
v0.20.0 Latest Latest
Warning

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

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

Documentation

Overview

nolint

Index

Constants

View Source
const MaxBondDenominatorPrecision = 8

Maximum amount of decimal points in the decimal representation of rationals used in MsgBeginUnbonding / MsgBeginRedelegate

View Source
const MsgType = "stake"

name to idetify transaction types

Variables

View Source
var MsgCdc *wire.Codec

generic sealed codec to be used throughout sdk

Functions

func AssertInvariants

func AssertInvariants(t *testing.T, msg string,
	pOrig Pool, cOrig []Validator, pMod Pool, vMods []Validator, tokens int64)

AssertInvariants ensures invariants that should always be true are true. nolint: unparam

func ErrBadDelegationAmount

func ErrBadDelegationAmount(codespace sdk.CodespaceType) sdk.Error

func ErrBadDelegatorAddr

func ErrBadDelegatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrBadDenom

func ErrBadDenom(codespace sdk.CodespaceType) sdk.Error

func ErrBadRedelegationDst

func ErrBadRedelegationDst(codespace sdk.CodespaceType) sdk.Error

func ErrBadRemoveValidator

func ErrBadRemoveValidator(codespace sdk.CodespaceType) sdk.Error

func ErrBadSharesAmount

func ErrBadSharesAmount(codespace sdk.CodespaceType) sdk.Error

func ErrBadSharesPercent

func ErrBadSharesPercent(codespace sdk.CodespaceType) sdk.Error

func ErrBadSharesPrecision

func ErrBadSharesPrecision(codespace sdk.CodespaceType) sdk.Error

func ErrBothShareMsgsGiven

func ErrBothShareMsgsGiven(codespace sdk.CodespaceType) sdk.Error

func ErrCommissionHuge

func ErrCommissionHuge(codespace sdk.CodespaceType) sdk.Error

func ErrCommissionNegative

func ErrCommissionNegative(codespace sdk.CodespaceType) sdk.Error

func ErrDelegationValidatorEmpty

func ErrDelegationValidatorEmpty(codespace sdk.CodespaceType) sdk.Error

func ErrDescriptionLength

func ErrDescriptionLength(codespace sdk.CodespaceType, descriptor string, got, max int) sdk.Error

func ErrInsufficientShares

func ErrInsufficientShares(codespace sdk.CodespaceType) sdk.Error

func ErrMissingSignature

func ErrMissingSignature(codespace sdk.CodespaceType) sdk.Error

func ErrNeitherShareMsgsGiven

func ErrNeitherShareMsgsGiven(codespace sdk.CodespaceType) sdk.Error

func ErrNilDelegatorAddr

func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error

func ErrNilValidatorAddr

func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error

validator

func ErrNoDelegation

func ErrNoDelegation(codespace sdk.CodespaceType) sdk.Error

func ErrNoDelegatorForAddress

func ErrNoDelegatorForAddress(codespace sdk.CodespaceType) sdk.Error

func ErrNoRedelegation

func ErrNoRedelegation(codespace sdk.CodespaceType) sdk.Error

func ErrNoUnbondingDelegation

func ErrNoUnbondingDelegation(codespace sdk.CodespaceType) sdk.Error

func ErrNoValidatorFound

func ErrNoValidatorFound(codespace sdk.CodespaceType) sdk.Error

func ErrNotEnoughDelegationShares

func ErrNotEnoughDelegationShares(codespace sdk.CodespaceType, shares string) sdk.Error

func ErrNotMature

func ErrNotMature(codespace sdk.CodespaceType, operation, descriptor string, got, min int64) sdk.Error

func ErrTransitiveRedelegation

func ErrTransitiveRedelegation(codespace sdk.CodespaceType) sdk.Error

func ErrValidatorOwnerExists

func ErrValidatorOwnerExists(codespace sdk.CodespaceType) sdk.Error

func ErrValidatorPubKeyExists

func ErrValidatorPubKeyExists(codespace sdk.CodespaceType) sdk.Error

func ErrValidatorRevoked

func ErrValidatorRevoked(codespace sdk.CodespaceType) sdk.Error

func MustMarshalDelegation

func MustMarshalDelegation(cdc *wire.Codec, delegation Delegation) []byte

return the delegation without fields contained within the key for the store

func MustMarshalRED

func MustMarshalRED(cdc *wire.Codec, red Redelegation) []byte

return the redelegation without fields contained within the key for the store

func MustMarshalUBD

func MustMarshalUBD(cdc *wire.Codec, ubd UnbondingDelegation) []byte

return the unbonding delegation without fields contained within the key for the store

func MustMarshalValidator

func MustMarshalValidator(cdc *wire.Codec, validator Validator) []byte

return the redelegation without fields contained within the key for the store

func OpAddTokens

func OpAddTokens(r *rand.Rand, pool Pool, val Validator) (Pool, Validator, int64, string)

OpAddTokens implements an operation that adds a random number of tokens to a validator.

func OpBondOrUnbond

func OpBondOrUnbond(r *rand.Rand, pool Pool, val Validator) (Pool, Validator, int64, string)

OpBondOrUnbond implements an operation that bonds or unbonds a validator depending on current status. nolint: unparam

func OpRemoveShares

func OpRemoveShares(r *rand.Rand, pool Pool, val Validator) (Pool, Validator, int64, string)

OpRemoveShares implements an operation that removes a random number of shares from a validator.

func RandomSetup

func RandomSetup(r *rand.Rand, numValidators int) (Pool, []Validator)

RandomSetup generates a random staking state.

func RegisterWire

func RegisterWire(cdc *wire.Codec)

Register concrete types on wire codec

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = 4

	CodeInvalidValidator  CodeType = 101
	CodeInvalidDelegation CodeType = 102
	CodeInvalidInput      CodeType = 103
	CodeValidatorJailed   CodeType = 104
	CodeUnauthorized      CodeType = sdk.CodeUnauthorized
	CodeInternal          CodeType = sdk.CodeInternal
	CodeUnknownRequest    CodeType = sdk.CodeUnknownRequest
)

type Delegation

type Delegation struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
	Shares        sdk.Rat        `json:"shares"`
	Height        int64          `json:"height"` // Last height bond updated
}

Delegation represents the bond with tokens held by an account. It is owned by one delegator, and is associated with the voting power of one pubKey.

func MustUnmarshalDelegation

func MustUnmarshalDelegation(cdc *wire.Codec, key, value []byte) Delegation

return the delegation without fields contained within the key for the store

func UnmarshalDelegation

func UnmarshalDelegation(cdc *wire.Codec, key, value []byte) (delegation Delegation, err error)

return the delegation without fields contained within the key for the store

func (Delegation) Equal

func (d Delegation) Equal(d2 Delegation) bool

nolint

func (Delegation) GetBondShares

func (d Delegation) GetBondShares() sdk.Rat

func (Delegation) GetDelegator

func (d Delegation) GetDelegator() sdk.AccAddress

nolint - for sdk.Delegation

func (Delegation) GetValidator

func (d Delegation) GetValidator() sdk.AccAddress

func (Delegation) HumanReadableString

func (d Delegation) HumanReadableString() (string, error)

HumanReadableString returns a human readable string representation of a Delegation. An error is returned if the Delegation's delegator or validator addresses cannot be Bech32 encoded.

type Description

type Description struct {
	Moniker  string `json:"moniker"`  // name
	Identity string `json:"identity"` // optional identity signature (ex. UPort or Keybase)
	Website  string `json:"website"`  // optional website link
	Details  string `json:"details"`  // optional details
}

Description - description fields for a validator

func NewDescription

func NewDescription(moniker, identity, website, details string) Description

NewDescription returns a new Description with the provided values.

func (Description) EnsureLength

func (d Description) EnsureLength() (Description, sdk.Error)

EnsureLength ensures the length of a validator's description.

func (Description) UpdateDescription

func (d Description) UpdateDescription(d2 Description) (Description, sdk.Error)

UpdateDescription updates the fields of a given description. An error is returned if the resulting description contains an invalid length.

type GenesisState

type GenesisState struct {
	Pool       Pool         `json:"pool"`
	Params     Params       `json:"params"`
	Validators []Validator  `json:"validators"`
	Bonds      []Delegation `json:"bonds"`
}

GenesisState - all staking state that must be provided at genesis

func DefaultGenesisState

func DefaultGenesisState() GenesisState

get raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(pool Pool, params Params, validators []Validator, bonds []Delegation) GenesisState

type MsgBeginRedelegate

type MsgBeginRedelegate struct {
	DelegatorAddr    sdk.AccAddress `json:"delegator_addr"`
	ValidatorSrcAddr sdk.AccAddress `json:"validator_src_addr"`
	ValidatorDstAddr sdk.AccAddress `json:"validator_dst_addr"`
	SharesAmount     sdk.Rat        `json:"shares_amount"`
}

MsgDelegate - struct for bonding transactions

func NewMsgBeginRedelegate

func NewMsgBeginRedelegate(delegatorAddr, validatorSrcAddr,
	validatorDstAddr sdk.AccAddress, sharesAmount sdk.Rat) MsgBeginRedelegate

func (MsgBeginRedelegate) GetSignBytes

func (msg MsgBeginRedelegate) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgBeginRedelegate) GetSigners

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

func (MsgBeginRedelegate) Type

func (msg MsgBeginRedelegate) Type() string

nolint

func (MsgBeginRedelegate) ValidateBasic

func (msg MsgBeginRedelegate) ValidateBasic() sdk.Error

quick validity check

type MsgBeginUnbonding

type MsgBeginUnbonding struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
	SharesAmount  sdk.Rat        `json:"shares_amount"`
}

MsgBeginUnbonding - struct for unbonding transactions

func NewMsgBeginUnbonding

func NewMsgBeginUnbonding(delegatorAddr, validatorAddr sdk.AccAddress, sharesAmount sdk.Rat) MsgBeginUnbonding

func (MsgBeginUnbonding) GetSignBytes

func (msg MsgBeginUnbonding) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgBeginUnbonding) GetSigners

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

func (MsgBeginUnbonding) Type

func (msg MsgBeginUnbonding) Type() string

nolint

func (MsgBeginUnbonding) ValidateBasic

func (msg MsgBeginUnbonding) ValidateBasic() sdk.Error

quick validity check

type MsgCompleteRedelegate

type MsgCompleteRedelegate struct {
	DelegatorAddr    sdk.AccAddress `json:"delegator_addr"`
	ValidatorSrcAddr sdk.AccAddress `json:"validator_source_addr"`
	ValidatorDstAddr sdk.AccAddress `json:"validator_destination_addr"`
}

MsgDelegate - struct for bonding transactions

func NewMsgCompleteRedelegate

func NewMsgCompleteRedelegate(delegatorAddr, validatorSrcAddr,
	validatorDstAddr sdk.AccAddress) MsgCompleteRedelegate

func (MsgCompleteRedelegate) GetSignBytes

func (msg MsgCompleteRedelegate) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgCompleteRedelegate) GetSigners

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

func (MsgCompleteRedelegate) Type

func (msg MsgCompleteRedelegate) Type() string

nolint

func (MsgCompleteRedelegate) ValidateBasic

func (msg MsgCompleteRedelegate) ValidateBasic() sdk.Error

quick validity check

type MsgCompleteUnbonding

type MsgCompleteUnbonding struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
}

MsgCompleteUnbonding - struct for unbonding transactions

func NewMsgCompleteUnbonding

func NewMsgCompleteUnbonding(delegatorAddr, validatorAddr sdk.AccAddress) MsgCompleteUnbonding

func (MsgCompleteUnbonding) GetSignBytes

func (msg MsgCompleteUnbonding) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgCompleteUnbonding) GetSigners

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

func (MsgCompleteUnbonding) Type

func (msg MsgCompleteUnbonding) Type() string

nolint

func (MsgCompleteUnbonding) ValidateBasic

func (msg MsgCompleteUnbonding) ValidateBasic() sdk.Error

quick validity check

type MsgCreateValidator

type MsgCreateValidator struct {
	Description
	ValidatorAddr  sdk.AccAddress `json:"address"`
	PubKey         crypto.PubKey  `json:"pubkey"`
	SelfDelegation sdk.Coin       `json:"self_delegation"`
}

MsgCreateValidator - struct for unbonding transactions

func NewMsgCreateValidator

func NewMsgCreateValidator(validatorAddr sdk.AccAddress, pubkey crypto.PubKey,
	selfDelegation sdk.Coin, description Description) MsgCreateValidator

func (MsgCreateValidator) GetSignBytes

func (msg MsgCreateValidator) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgCreateValidator) GetSigners

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

func (MsgCreateValidator) Type

func (msg MsgCreateValidator) Type() string

nolint

func (MsgCreateValidator) ValidateBasic

func (msg MsgCreateValidator) ValidateBasic() sdk.Error

quick validity check

type MsgDelegate

type MsgDelegate struct {
	DelegatorAddr sdk.AccAddress `json:"delegator_addr"`
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
	Bond          sdk.Coin       `json:"bond"`
}

MsgDelegate - struct for bonding transactions

func NewMsgDelegate

func NewMsgDelegate(delegatorAddr, validatorAddr sdk.AccAddress, bond sdk.Coin) MsgDelegate

func (MsgDelegate) GetSignBytes

func (msg MsgDelegate) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgDelegate) GetSigners

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

func (MsgDelegate) Type

func (msg MsgDelegate) Type() string

nolint

func (MsgDelegate) ValidateBasic

func (msg MsgDelegate) ValidateBasic() sdk.Error

quick validity check

type MsgEditValidator

type MsgEditValidator struct {
	Description
	ValidatorAddr sdk.AccAddress `json:"address"`
}

MsgEditValidator - struct for editing a validator

func NewMsgEditValidator

func NewMsgEditValidator(validatorAddr sdk.AccAddress, description Description) MsgEditValidator

func (MsgEditValidator) GetSignBytes

func (msg MsgEditValidator) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgEditValidator) GetSigners

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

func (MsgEditValidator) Type

func (msg MsgEditValidator) Type() string

nolint

func (MsgEditValidator) ValidateBasic

func (msg MsgEditValidator) ValidateBasic() sdk.Error

quick validity check

type Operation

type Operation func(r *rand.Rand, pool Pool, c Validator) (Pool, Validator, int64, string)

Operation reflects any operation that transforms staking state. It takes in a RNG instance, pool, validator and returns an updated pool, updated validator, delta tokens, and descriptive message.

func RandomOperation

func RandomOperation(r *rand.Rand) Operation

RandomOperation returns a random staking operation.

type Params

type Params struct {
	InflationRateChange sdk.Rat `json:"inflation_rate_change"` // maximum annual change in inflation rate
	InflationMax        sdk.Rat `json:"inflation_max"`         // maximum inflation rate
	InflationMin        sdk.Rat `json:"inflation_min"`         // minimum inflation rate
	GoalBonded          sdk.Rat `json:"goal_bonded"`           // Goal of percent bonded atoms

	UnbondingTime int64 `json:"unbonding_time"`

	MaxValidators uint16 `json:"max_validators"` // maximum number of validators
	BondDenom     string `json:"bond_denom"`     // bondable coin denomination
}

Params defines the high level settings for staking

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func (Params) Equal

func (p Params) Equal(p2 Params) bool

Equal returns a boolean determining if two Param types are identical.

type Pool

type Pool struct {
	LooseTokens       int64   `json:"loose_tokens"`        // tokens not associated with any validator
	UnbondedTokens    int64   `json:"unbonded_tokens"`     // reserve of unbonded tokens held with validators
	UnbondingTokens   int64   `json:"unbonding_tokens"`    // tokens moving from bonded to unbonded pool
	BondedTokens      int64   `json:"bonded_tokens"`       // reserve of bonded tokens
	UnbondedShares    sdk.Rat `json:"unbonded_shares"`     // sum of all shares distributed for the Unbonded Pool
	UnbondingShares   sdk.Rat `json:"unbonding_shares"`    // shares moving from Bonded to Unbonded Pool
	BondedShares      sdk.Rat `json:"bonded_shares"`       // sum of all shares distributed for the Bonded Pool
	InflationLastTime int64   `json:"inflation_last_time"` // block which the last inflation was processed // TODO make time
	Inflation         sdk.Rat `json:"inflation"`           // current annual inflation rate

	DateLastCommissionReset int64 `json:"date_last_commission_reset"` // unix timestamp for last commission accounting reset (daily)

	// Fee Related
	PrevBondedShares sdk.Rat `json:"prev_bonded_shares"` // last recorded bonded shares - for fee calculations
}

Pool - dynamic parameters of the current state

func InitialPool

func InitialPool() Pool

initial pool for testing

func (Pool) BondedRatio

func (p Pool) BondedRatio() sdk.Rat

get the bond ratio of the global state

func (Pool) BondedShareExRate

func (p Pool) BondedShareExRate() sdk.Rat

get the exchange rate of bonded token per issued share

func (Pool) Equal

func (p Pool) Equal(p2 Pool) bool

nolint

func (Pool) TokenSupply

func (p Pool) TokenSupply() int64

Sum total of all staking tokens in the pool

func (Pool) UnbondedShareExRate

func (p Pool) UnbondedShareExRate() sdk.Rat

get the exchange rate of unbonded tokens held in validators per issued share

func (Pool) UnbondingShareExRate

func (p Pool) UnbondingShareExRate() sdk.Rat

get the exchange rate of unbonding tokens held in validators per issued share

type PoolShares

type PoolShares struct {
	Status sdk.BondStatus `json:"status"`
	Amount sdk.Rat        `json:"amount"`
}

PoolShares reflects the shares of a validator in a pool.

func NewBondedShares

func NewBondedShares(amount sdk.Rat) PoolShares

NewBondedShares returns a new PoolSahres with a specified bonding amount.

func NewUnbondedShares

func NewUnbondedShares(amount sdk.Rat) PoolShares

NewUnbondedShares returns a new PoolShares with a specified unbonded amount.

func NewUnbondingShares

func NewUnbondingShares(amount sdk.Rat) PoolShares

NewUnbondingShares returns a new PoolShares with a specified unbonding amount.

func (PoolShares) Bonded

func (s PoolShares) Bonded() sdk.Rat

Bonded returns amount of bonded shares.

func (PoolShares) Equal

func (s PoolShares) Equal(s2 PoolShares) bool

Equal returns a boolean determining of two PoolShares are identical.

func (PoolShares) ToBonded

func (s PoolShares) ToBonded(p Pool) PoolShares

ToBonded the equivalent amount of pool shares if the shares were bonded.

func (PoolShares) ToUnbonded

func (s PoolShares) ToUnbonded(p Pool) PoolShares

ToUnbonded returns the equivalent amount of pool shares if the shares were unbonded.

func (PoolShares) ToUnbonding

func (s PoolShares) ToUnbonding(p Pool) PoolShares

ToUnbonding returns the equivalent amount of pool shares if the shares were unbonding.

func (PoolShares) Tokens

func (s PoolShares) Tokens(p Pool) sdk.Rat

Tokens returns the equivalent amount of tokens contained by the pool shares for a given pool.

func (PoolShares) Unbonded

func (s PoolShares) Unbonded() sdk.Rat

Unbonded returns the amount of unbonded shares.

func (PoolShares) Unbonding

func (s PoolShares) Unbonding() sdk.Rat

Unbonding returns the amount of unbonding shares.

type Redelegation

type Redelegation struct {
	DelegatorAddr    sdk.AccAddress `json:"delegator_addr"`     // delegator
	ValidatorSrcAddr sdk.AccAddress `json:"validator_src_addr"` // validator redelegation source owner addr
	ValidatorDstAddr sdk.AccAddress `json:"validator_dst_addr"` // validator redelegation destination owner addr
	CreationHeight   int64          `json:"creation_height"`    // height which the redelegation took place
	MinTime          int64          `json:"min_time"`           // unix time for redelegation completion
	InitialBalance   sdk.Coin       `json:"initial_balance"`    // initial balance when redelegation started
	Balance          sdk.Coin       `json:"balance"`            // current balance
	SharesSrc        sdk.Rat        `json:"shares_src"`         // amount of source shares redelegating
	SharesDst        sdk.Rat        `json:"shares_dst"`         // amount of destination shares redelegating
}

Redelegation reflects a delegation's passive re-delegation queue.

func MustUnmarshalRED

func MustUnmarshalRED(cdc *wire.Codec, key, value []byte) Redelegation

unmarshal a redelegation from a store key and value

func UnmarshalRED

func UnmarshalRED(cdc *wire.Codec, key, value []byte) (red Redelegation, err error)

unmarshal a redelegation from a store key and value

func (Redelegation) Equal

func (d Redelegation) Equal(d2 Redelegation) bool

nolint

func (Redelegation) HumanReadableString

func (d Redelegation) HumanReadableString() (string, error)

HumanReadableString returns a human readable string representation of a Redelegation. An error is returned if the UnbondingDelegation's delegator or validator addresses cannot be Bech32 encoded.

type UnbondingDelegation

type UnbondingDelegation struct {
	DelegatorAddr  sdk.AccAddress `json:"delegator_addr"`  // delegator
	ValidatorAddr  sdk.AccAddress `json:"validator_addr"`  // validator unbonding from owner addr
	CreationHeight int64          `json:"creation_height"` // height which the unbonding took place
	MinTime        int64          `json:"min_time"`        // unix time for unbonding completion
	InitialBalance sdk.Coin       `json:"initial_balance"` // atoms initially scheduled to receive at completion
	Balance        sdk.Coin       `json:"balance"`         // atoms to receive at completion
}

UnbondingDelegation reflects a delegation's passive unbonding queue.

func MustUnmarshalUBD

func MustUnmarshalUBD(cdc *wire.Codec, key, value []byte) UnbondingDelegation

unmarshal a unbonding delegation from a store key and value

func UnmarshalUBD

func UnmarshalUBD(cdc *wire.Codec, key, value []byte) (ubd UnbondingDelegation, err error)

unmarshal a unbonding delegation from a store key and value

func (UnbondingDelegation) Equal

nolint

func (UnbondingDelegation) HumanReadableString

func (d UnbondingDelegation) HumanReadableString() (string, error)

HumanReadableString returns a human readable string representation of an UnbondingDelegation. An error is returned if the UnbondingDelegation's delegator or validator addresses cannot be Bech32 encoded.

type Validator

type Validator struct {
	Owner   sdk.AccAddress `json:"owner"`   // sender of BondTx - UnbondTx returns here
	PubKey  crypto.PubKey  `json:"pub_key"` // pubkey of validator
	Revoked bool           `json:"revoked"` // has the validator been revoked from bonded status?

	PoolShares      PoolShares `json:"pool_shares"`      // total shares for tokens held in the pool
	DelegatorShares sdk.Rat    `json:"delegator_shares"` // total shares issued to a validator's delegators

	Description        Description `json:"description"`           // description terms for the validator
	BondHeight         int64       `json:"bond_height"`           // earliest height as a bonded validator
	BondIntraTxCounter int16       `json:"bond_intra_tx_counter"` // block-local tx index of validator change
	ProposerRewardPool sdk.Coins   `json:"proposer_reward_pool"`  // XXX reward pool collected from being the proposer

	Commission            sdk.Rat `json:"commission"`              // XXX the commission rate of fees charged to any delegators
	CommissionMax         sdk.Rat `json:"commission_max"`          // XXX maximum commission rate which this validator can ever charge
	CommissionChangeRate  sdk.Rat `json:"commission_change_rate"`  // XXX maximum daily increase of the validator commission
	CommissionChangeToday sdk.Rat `json:"commission_change_today"` // XXX commission rate change today, reset each day (UTC time)

	// fee related
	PrevBondedShares sdk.Rat `json:"prev_bonded_shares"` // total shares of a global hold pools
}

Validator defines the total amount of bond shares and their exchange rate to coins. Accumulation of interest is modelled as an in increase in the exchange rate, and slashing as a decrease. When coins are delegated to this validator, the validator is credited with a Delegation whose number of bond shares is based on the amount of coins delegated divided by the current exchange rate. Voting power can be calculated as total bonds multiplied by exchange rate.

func MustUnmarshalValidator

func MustUnmarshalValidator(cdc *wire.Codec, ownerAddr, value []byte) Validator

unmarshal a redelegation from a store key and value

func NewValidator

func NewValidator(owner sdk.AccAddress, pubKey crypto.PubKey, description Description) Validator

NewValidator - initialize a new validator

func UnmarshalValidator

func UnmarshalValidator(cdc *wire.Codec, ownerAddr, value []byte) (validator Validator, err error)

unmarshal a redelegation from a store key and value

func (Validator) ABCIValidator

func (v Validator) ABCIValidator() abci.Validator

ABCIValidator returns an abci.Validator from a staked validator type.

func (Validator) ABCIValidatorZero

func (v Validator) ABCIValidatorZero() abci.Validator

ABCIValidatorZero returns an abci.Validator from a staked validator type with with zero power used for validator updates.

func (Validator) AddTokensFromDel

func (v Validator) AddTokensFromDel(pool Pool, amount int64) (Validator, Pool, sdk.Rat)

AddTokensFromDel adds tokens to a validator

func (Validator) DelegatorShareExRate

func (v Validator) DelegatorShareExRate(pool Pool) sdk.Rat

DelegatorShareExRate gets the exchange rate of tokens over delegator shares. UNITS: eq-val-bonded-shares/delegator-shares

func (Validator) Equal

func (v Validator) Equal(c2 Validator) bool

only the vitals - does not check bond height of IntraTxCounter

func (Validator) EquivalentBondedShares

func (v Validator) EquivalentBondedShares(pool Pool) (eqBondedShares sdk.Rat)

EquivalentBondedShares ...

TODO: Remove should only be tokens get the power or potential power for a validator if bonded, the power is the BondedShares if not bonded, the power is the amount of bonded shares which the the validator would have it was bonded.

func (Validator) GetBondHeight

func (v Validator) GetBondHeight() int64

func (Validator) GetDelegatorShares

func (v Validator) GetDelegatorShares() sdk.Rat

func (Validator) GetMoniker

func (v Validator) GetMoniker() string

func (Validator) GetOwner

func (v Validator) GetOwner() sdk.AccAddress

func (Validator) GetPower

func (v Validator) GetPower() sdk.Rat

func (Validator) GetPubKey

func (v Validator) GetPubKey() crypto.PubKey

func (Validator) GetRevoked

func (v Validator) GetRevoked() bool

nolint - for sdk.Validator

func (Validator) GetStatus

func (v Validator) GetStatus() sdk.BondStatus

func (Validator) HumanReadableString

func (v Validator) HumanReadableString() (string, error)

HumanReadableString returns a human readable string representation of a validator. An error is returned if the owner or the owner's public key cannot be converted to Bech32 format.

func (Validator) RemoveDelShares

func (v Validator) RemoveDelShares(pool Pool, delShares sdk.Rat) (Validator, Pool, int64)

RemoveDelShares removes delegator shares from a validator.

NOTE: This function assumes the shares have already been updated for the validator status.

func (Validator) RemovePoolShares

func (v Validator) RemovePoolShares(pool Pool, poolShares sdk.Rat) (Validator, Pool, int64)

RemovePoolShares removes pool shares from a validator. It returns corresponding tokens, which could be burned (e.g. when slashing a validator) or redistributed elsewhere.

func (Validator) Status

func (v Validator) Status() sdk.BondStatus

Status returns the validator's bond status inferred from the pool shares.

func (Validator) UpdateStatus

func (v Validator) UpdateStatus(pool Pool, NewStatus sdk.BondStatus) (Validator, Pool)

UpdateStatus updates the location of the shares within a validator if it's bond status has changed.

Jump to

Keyboard shortcuts

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