types

package
v1.5.33 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// TODO: Why can't we just have one string description which can be JSON by convention
	MaxMonikerLength         = 70
	MaxIdentityLength        = 3000
	MaxWebsiteLength         = 140
	MaxSecurityContactLength = 140
	MaxDetailsLength         = 280

	// constant used in flags to indicate that description field should not be updated
	DoNotModifyDesc = "[do-not-modify]"
)
View Source
const (
	EventTypeCompleteUnbonding    = "complete_unbonding"
	EventTypeCompleteRedelegation = "complete_redelegation"
	EventTypeCreateValidator      = "create_validator"
	EventTypeEditValidator        = "edit_validator"
	EventTypeDelegate             = "delegate"
	EventTypeUndelegate           = "undelegate"
	EventTypeRedelegate           = "redelegate"

	AttributeKeyValidator         = "validator"
	AttributeKeyCommissionRate    = "commission_rate"
	AttributeKeyMinSelfDelegation = "min_self_delegation"
	AttributeKeySrcValidator      = "source_validator"
	AttributeKeyDstValidator      = "destination_validator"
	AttributeKeyDelegator         = "delegator"
	AttributeKeyCompletionTime    = "completion_time"
	AttributeValueCategory        = ModuleName
)

staking module event types

View Source
const (
	RouteKey   = "staking"
	StoreKey   = "staking"
	ModuleName = "staking"

	QueryDelegation           = "delegation"
	QueryValidatorDelegations = "validatorDelegations"
	QueryValidators           = "validators"
	QueryValidator            = "validator"
	QueryDelegatorValidators  = "delegatorValidators"
	QueryDelegatorValidator   = "delegatorValidator"
	QueryRedelegations        = "redelegations"
	QueryDelegatorDelegations = "delegatorDelegations"

	QueryOperatorAddressSet = "operatorAddresses"
	QueryParameters         = "parameters"
)
View Source
const (
	// DefaultUnbondingTime reflects three weeks in seconds as the default
	// unbonding time.
	// TODO: Justify our choice of default here.
	DefaultUnbondingTime time.Duration = time.Hour * 24 * 7 * 3

	// Default maximum number of bonded validators
	DefaultMaxValidators uint32 = 100

	// Default maximum entries in a UBD/RED pair
	DefaultMaxEntries uint32 = 9

	// DefaultHistorical entries is 0 since it must only be non-zero for
	// IBC connected chains
	DefaultHistoricalEntries uint32 = 10000
)

Staking params default values

View Source
const (
	NotBondedPoolName = "not_bonded_tokens_pool"
	BondedPoolName    = "bonded_tokens_pool"
)

Variables

View Source
var (
	ErrCommissionUpdateTime          = sdkerrors.Register(StakingCodespace, 1607, "new rate cannot be changed more than once within 24 hours")
	ErrInvalidRequest                = sdkerrors.Register(StakingCodespace, 1608, "invalid request")
	ErrCommissionNegative            = sdkerrors.Register(StakingCodespace, 1609, "commission must be positive")
	ErrCommissionHuge                = sdkerrors.Register(StakingCodespace, 1610, "commission cannot be more than 100%")
	ErrCommissionGTMaxRate           = sdkerrors.Register(StakingCodespace, 1611, "commission change rate cannot be more than the max rate")
	ErrCommissionChangeRateNegative  = sdkerrors.Register(StakingCodespace, 1612, "commission change rate must be positive")
	ErrCommissionChangeRateGTMaxRate = sdkerrors.Register(StakingCodespace, 1613, "commission change rate cannot be more than the max rate")
	ErrDelegatorShareExRateInvalid   = sdkerrors.Register(StakingCodespace, 1614, "cannot delegate to validators with invalid (zero) ex-rate")
	ErrInsufficientShares            = sdkerrors.Register(StakingCodespace, 1615, "insufficient delegation shares")
	ErrUnknowTokenSource             = sdkerrors.Register(StakingCodespace, 1616, "unknown token source bond status")
	ErrInvalidValidatorStatus        = sdkerrors.Register(StakingCodespace, 1617, "invalid validator status")
	ErrBondedTokendFailed            = sdkerrors.Register(StakingCodespace, 1618, "notBondedTokensToBonded failed")
	ErrBondedTokensToNoBondedFailed  = sdkerrors.Register(StakingCodespace, 1619, "BondedTokensToBonded failed")
	ErrNoDelegation                  = sdkerrors.Register(StakingCodespace, 1620, "no delegation")
	ErrBadSharesAmount               = sdkerrors.Register(StakingCodespace, 1621, "invalid shares amount")
	ErrSelfRedelegation              = sdkerrors.Register(StakingCodespace, 1622, "cannot redelegate to the same validator")
	ErrNoValidatorFound              = sdkerrors.Register(StakingCodespace, 1623, "no validator found")
	ErrNotEnoughDelegationShares     = sdkerrors.Register(StakingCodespace, 1624, "not enough delegation shares")
	ErrNoDelegatorForAddress         = sdkerrors.Register(StakingCodespace, 1625, "delegator does not contain delegation")
	ErrMaxUnbondingDelegationEntries = sdkerrors.Register(StakingCodespace, 1626, "too many unbonding delegation entries for (delegator, validator) tuple")
	ErrTinyRedelegationAmount        = sdkerrors.Register(StakingCodespace, 1627, "too few tokens to redelegate (truncates to zero tokens)")
	ErrMaxRedelegationEntries        = sdkerrors.Register(StakingCodespace, 1628, "too many redelegation entries for (delegator, src-validator, dst-validator) tuple")
	ErrTransitiveRedelegation        = sdkerrors.Register(StakingCodespace, 1629, "redelegation to this validator already in progress; first redelegation to this validator must complete before next redelegation")
	ErrBadRedelegationDst            = sdkerrors.Register(StakingCodespace, 1630, "redelegation destination validator not found")
	ErrCdcMarshal                    = sdkerrors.Register(StakingCodespace, 1631, "codec marshal failed")
	ErrCdcUnmarshal                  = sdkerrors.Register(StakingCodespace, 1632, "codec unmarshal failed")

	ErrNoExpectedValidator    = sdkerrors.Register(StakingCodespace, uint32(CodeInvalidValidator), "no expected validator found")
	ErrInvalidTxType          = sdkerrors.Register(StakingCodespace, uint32(CodeInvalidTxType), "invalid tx type")
	ErrInvalidPublicKey       = sdkerrors.Register(StakingCodespace, uint32(CodeInvalidPublicKey), "invalid publickey")
	ErrPubkeyHasBonded        = sdkerrors.Register(StakingCodespace, uint32(1634), "pubkey has bonded with one account")
	ErrInvalidMoniker         = sdkerrors.Register(StakingCodespace, uint32(CodeInvalidParam), "invalid moniker")
	ErrInvalidIdentity        = sdkerrors.Register(StakingCodespace, uint32(1635), "invalid identity")
	ErrInvalidWebsite         = sdkerrors.Register(StakingCodespace, uint32(1636), "invalid website")
	ErrInvalidSecurityContact = sdkerrors.Register(StakingCodespace, uint32(1637), "invalid security contact")
	ErrInvalidDetails         = sdkerrors.Register(StakingCodespace, uint32(1638), "invalid details")
	ErrSetValidatorFailed     = sdkerrors.Register(StakingCodespace, uint32(CodeInternalOperationFailed), "set validator failed")
	ErrInvalidParam           = sdkerrors.Register(StakingCodespace, uint32(1639), "invalid params")
)
View Source
var (
	LastTotalPowerKey     = []byte{0x11}
	LastValidatorPowerKey = []byte{0x12}

	ValidatorsKey             = []byte{0x21}
	ValidatorsByConsAddrKey   = []byte{0x22}
	ValidatorsByPowerIndexKey = []byte{0x23}

	DelegationKey                    = []byte{0x31}
	RedelegationKey                  = []byte{0x32}
	RedelegationByValSrcIndexKey     = []byte{0x33}
	RedelegationByValDstIndexKey     = []byte{0x34}
	UnbondingDelegationKey           = []byte{0x35}
	UnbondingDelegationByValIndexKey = []byte{0x36}

	UnbondingQueueKey    = []byte{0x41}
	RedelegationQueueKey = []byte{0x42}
	ValidatorQueueKey    = []byte{0x43}

	HistoricalInfoKey = []byte{0x50}
)
View Source
var (
	KeyUnbondingTime     = []byte("UnbondingTime")
	KeyMaxValidators     = []byte("MaxValidators")
	KeyMaxEntries        = []byte("KeyMaxEntries")
	KeyBondDenom         = []byte("BondDenom")
	KeyHistoricalEntries = []byte("HistoricalEntries")
)
View Source
var StakingCodec *codec.Codec

Functions

func AddressFromLastValidatorPowerKey

func AddressFromLastValidatorPowerKey(key []byte) []byte

Get the validator operator address from LastValidatorPowerKey

func GetDelegationKey

func GetDelegationKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

func GetDelegationsKey

func GetDelegationsKey(delAddr sdk.AccAddress) []byte

func GetHistoricalInfoKey

func GetHistoricalInfoKey(height int64) []byte

GetHistoricalInfoKey gets the key for the historical info

func GetLastValidatorPowerKey

func GetLastValidatorPowerKey(operator sdk.AccAddress) []byte

get the bonded validator index key for an operator address

func GetREDByValDstIndexKey

func GetREDByValDstIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

gets the index-key for a redelegation, stored by destination-validator-index VALUE: none (key rearrangement used)

func GetREDByValSrcIndexKey

func GetREDByValSrcIndexKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

gets the index-key for a redelegation, stored by source-validator-index VALUE: none (key rearrangement used)

func GetREDKey

func GetREDKey(delAddr sdk.AccAddress, valSrcAddr, valDstAddr sdk.AccAddress) []byte

func GetREDKeyFromValSrcIndexKey

func GetREDKeyFromValSrcIndexKey(indexKey []byte) []byte

GetREDKeyFromValSrcIndexKey rearranges the ValSrcIndexKey to get the REDKey

func GetREDsByDelToValDstIndexKey

func GetREDsByDelToValDstIndexKey(delAddr sdk.AccAddress, valDstAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating towards a destination validator from a particular delegator

func GetREDsFromValSrcIndexKey

func GetREDsFromValSrcIndexKey(valSrcAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating away from a source validator

func GetREDsKey

func GetREDsKey(delAddr sdk.AccAddress) []byte

gets the prefix keyspace for redelegations from a delegator

func GetREDsToValDstIndexKey

func GetREDsToValDstIndexKey(valDstAddr sdk.AccAddress) []byte

gets the prefix keyspace for all redelegations redelegating towards a destination validator

func GetRedelegationTimeKey

func GetRedelegationTimeKey(timestamp time.Time) []byte

gets the prefix for all unbonding delegations from a delegator

func GetUBDByValIndexKey

func GetUBDByValIndexKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

gets the index-key for an unbonding delegation, stored by validator-index VALUE: none (key rearrangement used)

func GetUBDKey

func GetUBDKey(delAddr sdk.AccAddress, valAddr sdk.AccAddress) []byte

gets the key for an unbonding delegation by delegator and validator addr VALUE: staking/UnbondingDelegation

func GetUBDsByValIndexKey

func GetUBDsByValIndexKey(valAddr sdk.AccAddress) []byte

gets the prefix keyspace for the indexes of unbonding delegations for a validator

func GetUBDsKey

func GetUBDsKey(delAddr sdk.AccAddress) []byte

gets the prefix for all unbonding delegations from a delegator

func GetUnbondingDelegationTimeKey

func GetUnbondingDelegationTimeKey(timestamp time.Time) []byte

gets the prefix for all unbonding delegations from a delegator

func GetValidatorByConsAddrKey

func GetValidatorByConsAddrKey(addr sdk.AccAddress) []byte

func GetValidatorKey

func GetValidatorKey(operatorAddr sdk.AccAddress) []byte

func GetValidatorQueueTimeKey

func GetValidatorQueueTimeKey(timestamp time.Time) []byte

gets the prefix for all unbonding delegations from a delegator

func GetValidatorsByPowerIndexKey

func GetValidatorsByPowerIndexKey(validator Validator) []byte

func ParamKeyTable

func ParamKeyTable() params.KeyTable

ParamTable for staking module

func RegisterCodec

func RegisterCodec(cdc *codec.Codec)

Types

type CodeType

type CodeType = sdk.CodeType
const (
	DefaultCodespace sdk.CodespaceType = "staking"
	StakingCodespace                   = "staking"

	CodeInvalidValidator CodeType = 1601
	CodeInvalidTxType    CodeType = 1602
	CodeInvalidPublicKey CodeType = 1603
	CodeInvalidParam     CodeType = 1604

	CodeInternalOperationFailed CodeType = 1605
	Code

	CodeModuleAccountNotExisted CodeType = 1606
)

type Commission

type Commission struct {
	CommissionRates CommissionRates `json:"commission_rates"`
	UpdateTime      time.Time       `json:"update_time"`
}

func NewCommission

func NewCommission(rate, maxRate, maxChangeRate sdk.Dec) Commission

func NewCommissionWithTime

func NewCommissionWithTime(rate, maxRate, maxChangeRate sdk.Dec, updatedAt time.Time) Commission

NewCommissionWithTime returns an initialized validator commission with a specified update time which should be the current block BFT time.

func (*Commission) Reset

func (m *Commission) Reset()

func (Commission) String

func (m Commission) String() string

func (Commission) ValidateNewRate

func (m Commission) ValidateNewRate(newRate sdk.Dec, blockTime time.Time) error

type CommissionRates

type CommissionRates struct {
	Rate          sdk.Dec `json:"rate"`
	MaxRate       sdk.Dec `json:"max_rate"`
	MaxChangeRate sdk.Dec `json:"max_change_rate"`
}

Rate: 佣金收取率;0-100; maxRate: 佣金最大收取率; maxChangeRate: 每日最大变动百分比

func NewCommissionRates

func NewCommissionRates(rate, maxRate, maxChangeRate sdk.Dec) CommissionRates

func (*CommissionRates) Reset

func (cr *CommissionRates) Reset()

func (CommissionRates) Validate

func (cr CommissionRates) Validate() error

type DVPair

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

与解除绑定相关, 用于存储和获取 到达解绑时间的 Delegator和Validator对;

type DVPairs

type DVPairs struct {
	Pairs []DVPair `json:"pairs"`
}

type DVVTriplet

type DVVTriplet struct {
	DelegatorAddress    sdk.AccAddress `json:"delegator_address"`
	ValidatorSrcAddress sdk.AccAddress `json:"validator_src_address"`
	ValidatorDstAddress sdk.AccAddress `json:"validator_dst_address"`
}

与二次绑定有关;

type DVVTriplets

type DVVTriplets struct {
	Triplets []DVVTriplet `json:"triplets"`
}

type Delegation

type Delegation struct {
	DelegatorAddress sdk.AccAddress `json:"delegator_address"`
	ValidatorAddress sdk.AccAddress `json:"validator_address"`
	Shares           sdk.Dec        `json:"shares"`
}

Shares: 委托者抵押给验证者之后,形成的抵押证明中表现委托者拥有的股权; Shares = validator.DelegatorShares/validator.Tokens * DelegateTokens

func NewDelegation

func NewDelegation(delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress, shares sdk.Dec) Delegation

func (Delegation) GetDelegatorAddr

func (d Delegation) GetDelegatorAddr() sdk.AccAddress

func (Delegation) GetShares

func (d Delegation) GetShares() sdk.Dec

func (Delegation) GetValidatorAddr

func (d Delegation) GetValidatorAddr() sdk.AccAddress

func (Delegation) String

func (d Delegation) String() string

String returns a human readable string representation of a Delegation.

type DelegationResponse

type DelegationResponse struct {
	Delegation
	Balance sdk.Coin `json:"balance" yaml:"balance"`
}

func NewDelegationResp

func NewDelegationResp(
	delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress, shares sdk.Dec, balance sdk.Coin,
) DelegationResponse

NewDelegationResp creates a new DelegationResponse instance

func (DelegationResponse) String

func (d DelegationResponse) String() string

String implements the Stringer interface for DelegationResponse.

type DelegationResponses

type DelegationResponses []DelegationResponse

DelegationResponses is a collection of DelegationResp

type Delegations

type Delegations []Delegation

type Description

type Description struct {
	Moniker         string `json:"moniker"`
	Identity        string `json:"identity"`
	Website         string `json:"website"`
	SecurityContact string `json:"security_contact"`
	Details         string `json:"details"`
}

func NewDescription

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

func (Description) EnsureLength

func (m Description) EnsureLength() (Description, error)

func (*Description) GetDetails

func (m *Description) GetDetails() string

func (*Description) GetIdentity

func (m *Description) GetIdentity() string

func (*Description) GetMoniker

func (m *Description) GetMoniker() string

func (*Description) GetSecurityContact

func (m *Description) GetSecurityContact() string

func (*Description) GetWebsite

func (m *Description) GetWebsite() string

func (*Description) Reset

func (m *Description) Reset()

func (Description) UpdateDescription

func (m Description) UpdateDescription(d2 Description) (Description, error)

type GenesisState

type GenesisState struct {
	Params               Params                `json:"params"`
	LastTotalPower       sdk.Int               `json:"last_total_power"`
	LastValidatorPowers  []LastValidatorPower  `json:"last_validator_powers"`
	Validators           Validators            `json:"validators"`
	Delegations          Delegations           `json:"delegations"`
	UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations"`
	Redelegations        []Redelegation        `json:"redelegations"`
	Exported             bool                  `json:"exported"`
}

params: 相关参数设置;

func DefaultGenesisState

func DefaultGenesisState(_ []tmtypes.GenesisValidator) GenesisState

DefaultGenesisState gets the raw genesis raw message for testing

func NewGenesisState

func NewGenesisState(params Params, validators []Validator, delegations []Delegation) GenesisState

NewGenesisState creates a new GenesisState instanc e

type HistoricalInfo

type HistoricalInfo struct {
	Header types.Header `json:"header"`
	Valset []Validator  `json:"valset"`
}

HistoricalInfo contains the historical information that gets stored at each height.

func NewHistoricalInfo

func NewHistoricalInfo(header types.Header, valSet Validators) HistoricalInfo

NewHistoricalInfo will create a historical information struct from header and valset it will first sort valset before inclusion into historical info

type LastValidatorPower

type LastValidatorPower struct {
	Address sdk.AccAddress `json:"address"`
	Power   int64          `json:"power"`
}

LastValidatorPower required for validator set update logic

type MsgCreateValidator

type MsgCreateValidator struct {
	FromAddress       types.AccAddress `json:"from_address"`
	PublicKey         string           `json:"public_key"`
	Value             types.Coin       `json:"value"`
	ValidatorAddress  types.AccAddress `json:"validator_address"`
	DelegatorAddress  types.AccAddress `json:"delegator_address"`
	MinSelfDelegation types.Int        `json:"min_self_delegation"`
	Commission        CommissionRates  `json:"commission"`
	Description       Description      `json:"description"`
}

func NewMsgCreateValidator

func NewMsgCreateValidator(from types.AccAddress, value types.Coin, minSelfDelegation types.Int, validatorAddr types.AccAddress, delegatorAddr types.AccAddress,
	rate, maxRate, maxChangeRate types.Dec, moniker, identity, website, securityContact, details string, publicKey string) *MsgCreateValidator

func (*MsgCreateValidator) Bytes

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

func (*MsgCreateValidator) GetFromAddress

func (msg *MsgCreateValidator) GetFromAddress() types.AccAddress

func (*MsgCreateValidator) MsgType

func (msg *MsgCreateValidator) MsgType() string

func (*MsgCreateValidator) Route

func (msg *MsgCreateValidator) Route() string

func (*MsgCreateValidator) ValidateBasic

func (msg *MsgCreateValidator) ValidateBasic() error

type MsgDelegate

type MsgDelegate struct {
	FromAddress      types.AccAddress `json:"from_address"`
	DelegatorAddress types.AccAddress `json:"delegator_address"`
	ValidatorAddress types.AccAddress `json:"validator_address"`
	Amount           types.Coin       `json:"amount"`
}

func NewMsgDelegate

func NewMsgDelegate(from types.AccAddress, delegatorAddr types.AccAddress, validatorAddr types.AccAddress,
	amount types.Coin) *MsgDelegate

func (*MsgDelegate) Bytes

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

func (*MsgDelegate) GetFromAddress

func (msg *MsgDelegate) GetFromAddress() types.AccAddress

func (*MsgDelegate) MsgType

func (msg *MsgDelegate) MsgType() string

func (*MsgDelegate) Route

func (msg *MsgDelegate) Route() string

func (*MsgDelegate) ValidateBasic

func (msg *MsgDelegate) ValidateBasic() error

type MsgEditValidator

type MsgEditValidator struct {
	FromAddress       sdk.AccAddress `json:"from_address"`
	Description       Description    `json:"description"`
	ValidatorAddress  sdk.AccAddress `json:"validator_address"`
	CommissionRate    *sdk.Dec       `json:"commission_rate"`
	MinSelfDelegation *sdk.Int       `json:"min_self_delegation"`
}

func NewMsgEditValidator

func NewMsgEditValidator(from sdk.AccAddress, desc Description, commissionRate *sdk.Dec,
	minSelfDelegation *sdk.Int) *MsgEditValidator

func (*MsgEditValidator) Bytes

func (tx *MsgEditValidator) Bytes() []byte

func (*MsgEditValidator) GetFromAddress

func (tx *MsgEditValidator) GetFromAddress() sdk.AccAddress

func (*MsgEditValidator) MsgType

func (tx *MsgEditValidator) MsgType() string

func (*MsgEditValidator) Route

func (tx *MsgEditValidator) Route() string

func (*MsgEditValidator) ValidateBasic

func (tx *MsgEditValidator) ValidateBasic() error

type MsgRedelegate

type MsgRedelegate struct {
	FromAddress         types.AccAddress `json:"from_address"`
	DelegatorAddress    types.AccAddress `json:"delegator_address"`
	ValidatorSrcAddress types.AccAddress `json:"validator_src_address"`
	ValidatorDstAddress types.AccAddress `json:"validator_dst_address"`
	Amount              types.Coin       `json:"amount"`
}

func NewMsgRedelegate

func NewMsgRedelegate(fromAddr types.AccAddress, delegateAddr types.AccAddress, validatorSrcAddr,
	validatorDstAddr types.AccAddress, amount types.Coin) *MsgRedelegate

func (*MsgRedelegate) Bytes

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

func (*MsgRedelegate) GetFromAddress

func (msg *MsgRedelegate) GetFromAddress() types.AccAddress

func (*MsgRedelegate) MsgType

func (msg *MsgRedelegate) MsgType() string

func (*MsgRedelegate) Route

func (msg *MsgRedelegate) Route() string

func (*MsgRedelegate) ValidateBasic

func (msg *MsgRedelegate) ValidateBasic() error

type MsgUndelegate

type MsgUndelegate struct {
	FromAddress      types.AccAddress `json:"from_address"`
	DelegatorAddress types.AccAddress `json:"delegator_address"`
	ValidatorAddress types.AccAddress `json:"validator_address"`
	Amount           types.Coin       `json:"amount"`
}

func NewMsgUndelegate

func NewMsgUndelegate(from types.AccAddress, delegatorAddr, validatorAddr types.AccAddress,
	amount types.Coin) *MsgUndelegate

func (*MsgUndelegate) Bytes

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

func (*MsgUndelegate) GetFromAddress

func (msg *MsgUndelegate) GetFromAddress() types.AccAddress

func (*MsgUndelegate) MsgType

func (msg *MsgUndelegate) MsgType() string

func (*MsgUndelegate) Route

func (msg *MsgUndelegate) Route() string

func (*MsgUndelegate) ValidateBasic

func (msg *MsgUndelegate) ValidateBasic() error

type MultiStakingHooks

type MultiStakingHooks []StakingHooks

combine multiple staking hooks, all hook functions are run in array sequence

func NewMultiStakingHooks

func NewMultiStakingHooks(hooks ...StakingHooks) MultiStakingHooks

func (MultiStakingHooks) AfterDelegationModified

func (h MultiStakingHooks) AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) AfterValidatorBeginUnbonding

func (h MultiStakingHooks) AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) AfterValidatorBonded

func (h MultiStakingHooks) AfterValidatorBonded(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) AfterValidatorCreated

func (h MultiStakingHooks) AfterValidatorCreated(ctx sdk.Context, valAddr sdk.AccAddress)

nolint

func (MultiStakingHooks) AfterValidatorRemoved

func (h MultiStakingHooks) AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) BeforeDelegationCreated

func (h MultiStakingHooks) BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) BeforeDelegationRemoved

func (h MultiStakingHooks) BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) BeforeDelegationSharesModified

func (h MultiStakingHooks) BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)

func (MultiStakingHooks) BeforeValidatorModified

func (h MultiStakingHooks) BeforeValidatorModified(ctx sdk.Context, valAddr sdk.AccAddress)

func (MultiStakingHooks) BeforeValidatorSlashed

func (h MultiStakingHooks) BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.AccAddress, fraction sdk.Dec)

type Params

type Params struct {
	UnbondingTime     time.Duration `json:"unbonding_time"`
	MaxValidators     uint32        `json:"max_validators"`
	MaxEntries        uint32        `json:"max_entries"`
	HistoricalEntries uint32        `json:"historical_entries"`
	BondDenom         string        `json:"bond_denom"`
}

func DefaultParams

func DefaultParams() Params

DefaultParams returns a default set of parameters.

func NewParams

func NewParams(unbondingTime time.Duration, maxValidators, maxEntries, historicalEntries uint32, bondDenom string) Params

func (*Params) ParamSetPairs

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

type QueryBondsParams

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

func NewQueryBondsParams

func NewQueryBondsParams(delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress) QueryBondsParams

type QueryDelegatorParams

type QueryDelegatorParams struct {
	DelegatorAddr sdk.AccAddress
}

func NewQueryDelegatorParams

func NewQueryDelegatorParams(delegatorAddr sdk.AccAddress) QueryDelegatorParams

type QueryOperatorAddressesParams

type QueryOperatorAddressesParams struct {
	ConsAddresses []sdk.AccAddr `json:"cons_addresses"`
}

func NewQueryOperatorAddressParams

func NewQueryOperatorAddressParams(operatorAddress ...sdk.AccAddr) QueryOperatorAddressesParams

type QueryRedelegationParams

type QueryRedelegationParams struct {
	DelegatorAddr    sdk.AccAddress
	SrcValidatorAddr sdk.AccAddress
	DstValidatorAddr sdk.AccAddress
}

defines the params for the following queries: - 'custom/staking/redelegation'

func NewQueryRedelegationParams

func NewQueryRedelegationParams(delegatorAddr sdk.AccAddress,
	srcValidatorAddr, dstValidatorAddr sdk.AccAddress) QueryRedelegationParams

type QueryValidatorParams

type QueryValidatorParams struct {
	ValidatorAddr sdk.AccAddress `json:"validator_addr"`
}

func NewQueryValidatorParams

func NewQueryValidatorParams(validatorAddr sdk.AccAddress) QueryValidatorParams

type QueryValidatorsParams

type QueryValidatorsParams struct {
	Page, Limit int
	Status      string
}

QueryValidatorsParams defines the params for the following queries: - 'custom/staking/validators'

func NewQueryValidatorsParams

func NewQueryValidatorsParams(page, limit int, status string) QueryValidatorsParams

type Redelegation

type Redelegation struct {
	DelegatorAddress    sdk.AccAddress      `json:"delegator_address"`
	ValidatorSrcAddress sdk.AccAddress      `json:"validator_src_address"`
	ValidatorDstAddress sdk.AccAddress      `json:"validator_dst_address"`
	Entries             []RedelegationEntry `json:"entries"`
}

表示一个 特定的委托者 从SrcVal 更换绑定到 DstVal 的时间列表;

func NewRedelegation

func NewRedelegation(delegatorAddr sdk.AccAddress, validatorSrcAddr, validatorDstAddr sdk.AccAddress,
	creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec) Redelegation

func (*Redelegation) AddEntry

func (red *Redelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int, sharesDst sdk.Dec)

AddEntry - append entry to the unbonding delegation

func (*Redelegation) RemoveEntry

func (red *Redelegation) RemoveEntry(i int64)

RemoveEntry - remove entry at index i to the unbonding delegation

func (Redelegation) String

func (red Redelegation) String() string

String returns a human readable string representation of a Redelegation.

type RedelegationEntry

type RedelegationEntry struct {
	CreationHeight int64     `json:"creation_height"`
	CompletionTime time.Time `json:"completion_time"`
	InitialBalance sdk.Int   `json:"initial_balance"`
	SharesDst      sdk.Dec   `json:"shares_dst"`
}

CreationHeight: 创建的高度 CompletionTime: 完成时间 InitialBalance: 二次抵押的Token数量 SharesDst: 二次抵押的shares数量;由Token数量计算得来;

func NewRedelegationEntry

func NewRedelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int, sharesDst sdk.Dec) RedelegationEntry

func (RedelegationEntry) IsMature

func (e RedelegationEntry) IsMature(currentTime time.Time) bool

IsMature - is the current entry mature

type RedelegationEntryResponse

type RedelegationEntryResponse struct {
	RedelegationEntry
	Balance sdk.Int `json:"balance"`
}

RedelegationEntryResponse is equivalent to a RedelegationEntry except that it contains a balance in addition to shares which is more suitable for clients responses.

func NewRedelegationEntryResponse

func NewRedelegationEntryResponse(
	creationHeight int64, completionTime time.Time, sharesDst sdk.Dec, initialBalance, balance sdk.Int) RedelegationEntryResponse

NewRedelegationEntryResponse creates a new RedelegationEntryResponse instance.

type RedelegationResponse

type RedelegationResponse struct {
	Redelegation
	Entries []RedelegationEntryResponse `json:"entries" yaml:"entries"`
}

RedelegationResponse is equivalent to a Redelegation except that its entries contain a balance in addition to shares which is more suitable for clients responses.

func NewRedelegationResponse

func NewRedelegationResponse(
	delegatorAddr sdk.AccAddress, validatorSrc, validatorDst sdk.AccAddress, entries []RedelegationEntryResponse,
) RedelegationResponse

NewRedelegationResponse crates a new RedelegationEntryResponse instance.

type RedelegationResponses

type RedelegationResponses []RedelegationResponse

RedelegationResponses are a collection of RedelegationResp

func (RedelegationResponses) String

func (r RedelegationResponses) String() (out string)

type Redelegations

type Redelegations []Redelegation

Redelegations are a collection of Redelegation

func (Redelegations) String

func (d Redelegations) String() (out string)

type StakingHooks

type StakingHooks interface {
	AfterValidatorCreated(ctx sdk.Context, valAddr sdk.AccAddress)
	BeforeValidatorModified(ctx sdk.Context, valAddr sdk.AccAddress)
	AfterValidatorRemoved(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress)

	AfterValidatorBonded(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress)
	AfterValidatorBeginUnbonding(ctx sdk.Context, consAddr sdk.AccAddress, valAddr sdk.AccAddress) // Must be called when a validator begins unbonding

	BeforeDelegationCreated(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)        // Must be called when a delegation is created
	BeforeDelegationSharesModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress) // Must be called when a delegation's shares are modified
	BeforeDelegationRemoved(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)        // Must be called when a delegation is removed
	AfterDelegationModified(ctx sdk.Context, delAddr sdk.AccAddress, valAddr sdk.AccAddress)
	BeforeValidatorSlashed(ctx sdk.Context, valAddr sdk.AccAddress, fraction sdk.Dec)
}

StakingHooks event hooks for staking validator object

type UnbondingDelegation

type UnbondingDelegation struct {
	DelegatorAddress sdk.AccAddress             `json:"delegator_address"`
	ValidatorAddress sdk.AccAddress             `json:"validator_address"`
	Entries          []UnbondingDelegationEntry `json:"entries"`
}

需要解绑的 Delegator和Validator对; 一对 Delegator和Validator可能有多次解绑,用Entries标志;

func MustUnmarshalUBD

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

unmarshal a unbonding delegation from a store value

func NewUnbondingDelegation

func NewUnbondingDelegation(
	delegatorAddr sdk.AccAddress, validatorAddr sdk.AccAddress,
	creationHeight int64, minTime time.Time, balance sdk.Int,
) UnbondingDelegation

NewUnbondingDelegation - create a new unbonding delegation object

func UnmarshalUBD

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

unmarshal a unbonding delegation from a store value

func (*UnbondingDelegation) AddEntry

func (ubd *UnbondingDelegation) AddEntry(creationHeight int64, minTime time.Time, balance sdk.Int)

AddEntry - append entry to the unbonding delegation

func (*UnbondingDelegation) RemoveEntry

func (ubd *UnbondingDelegation) RemoveEntry(i int64)

RemoveEntry - remove entry at index i to the unbonding delegation

type UnbondingDelegationEntry

type UnbondingDelegationEntry struct {
	CreationHeight int64     `json:"creation_height"`
	CompletionTime time.Time `json:"completion_time"`
	InitialBalance sdk.Int   `json:"initial_balance"`
	Balance        sdk.Int   `json:"balance"`
}

CreationHeight: 创建时间 CompletionTime: 完成时间 InitialBalance: 与惩罚有关 Balance: Unbonding的Token数量;

func NewUnbondingDelegationEntry

func NewUnbondingDelegationEntry(creationHeight int64, completionTime time.Time, balance sdk.Int) UnbondingDelegationEntry

func (UnbondingDelegationEntry) IsMature

func (e UnbondingDelegationEntry) IsMature(currentTime time.Time) bool

IsMature - is the current entry mature

type Validator

type Validator struct {
	OperatorAddress   sdk.AccAddress `json:"operator_address"`
	ConsensusKey      string         `json:"pub_key"`
	ConsensusAddress  string         `json:"consensus_address"`
	Jailed            bool           `json:"jailed"`
	Tokens            sdk.Int        `json:"tokens"`
	Status            sdk.BondStatus `json:"status"`
	DelegatorShares   sdk.Dec        `json:"delegator_shares"`
	Description       Description    `json:"description"`
	UnbondingHeight   int64          `json:"unbonding_height"`
	UnbondingTime     time.Time      `json:"unbonding_time"`
	BondedHeight      int64          `json:"bonded_height"`
	Commission        Commission     `json:"commission"`
	MinSelfDelegation sdk.Int        `json:"min_self_delegation"`
}

func DefaultValidators

func DefaultValidators(validators []tmtypes.GenesisValidator) []Validator

func NewValidator

func NewValidator(operator sdk.AccAddress, pubKey string, description Description) (Validator, error)

crypto pubKey

func (Validator) ABCIValidatorUpdate

func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate

ABCIValidatorUpdate returns an abci.ValidatorUpdate from a staking validator types with the full validator power

func (Validator) ABCIValidatorUpdateZero

func (v Validator) ABCIValidatorUpdateZero() abci.ValidatorUpdate

ABCIValidatorUpdateZero returns an abci.ValidatorUpdate from a staking validator types with zero power used for validator updates.

func (Validator) AddTokensFromDel

func (v Validator) AddTokensFromDel(amount sdk.Int) (Validator, sdk.Dec)

AddTokensFromDel adds tokens to a validator

func (Validator) BondedTokens

func (v Validator) BondedTokens() sdk.Int

get the bonded tokens which the validator holds

func (Validator) ConsensusPower

func (v Validator) ConsensusPower() int64

get the consensus-engine power a reduction of 10^6 from validator tokens is applied

func (Validator) GetBondedTokens

func (v Validator) GetBondedTokens() sdk.Int

func (Validator) GetCommission

func (v Validator) GetCommission() sdk.Dec

func (Validator) GetConsAddr

func (v Validator) GetConsAddr() sdk.AccAddress

func (Validator) GetConsAddress

func (v Validator) GetConsAddress() sdk.AccAddress

func (Validator) GetConsPubKey

func (v Validator) GetConsPubKey() crypto.PubKey

func (Validator) GetConsensusPower

func (v Validator) GetConsensusPower() int64

func (Validator) GetDelegatorShares

func (v Validator) GetDelegatorShares() sdk.Dec

func (Validator) GetMinSelfDelegation

func (v Validator) GetMinSelfDelegation() sdk.Int

func (Validator) GetMoniker

func (v Validator) GetMoniker() string

func (Validator) GetOperator

func (v Validator) GetOperator() sdk.AccAddress

func (Validator) GetStatus

func (v Validator) GetStatus() sdk.BondStatus

func (Validator) GetTokens

func (v Validator) GetTokens() sdk.Int

func (Validator) InvalidExRate

func (v Validator) InvalidExRate() bool

In some situations, the exchange rate becomes invalid, e.g. if Validator loses all tokens due to slashing. In this case, make all future delegations invalid.

func (Validator) IsBonded

func (v Validator) IsBonded() bool

IsBonded checks if the validator status equals Bonded

func (Validator) IsJailed

func (v Validator) IsJailed() bool

nolint - for ValidatorI

func (Validator) IsUnbonded

func (v Validator) IsUnbonded() bool

IsUnbonded checks if the validator status equals Unbonded

func (Validator) IsUnbonding

func (v Validator) IsUnbonding() bool

IsUnbonding checks if the validator status equals Unbonding

func (Validator) PotentialConsensusPower

func (v Validator) PotentialConsensusPower() int64

potential consensus-engine power

func (Validator) RemoveDelShares

func (v Validator) RemoveDelShares(delShares sdk.Dec) (Validator, sdk.Int)

RemoveDelShares removes delegator shares from a validator. NOTE: because token fractions are left in the valiadator,

the exchange rate of future shares of this validator can increase.

func (Validator) RemoveTokens

func (v Validator) RemoveTokens(tokens sdk.Int) Validator

RemoveTokens removes tokens from a validator

func (Validator) SetInitialCommission

func (v Validator) SetInitialCommission(commission Commission) (Validator, error)

func (Validator) SharesFromTokens

func (v Validator) SharesFromTokens(amt sdk.Int) (sdk.Dec, error)

SharesFromTokens returns the shares of a delegation given a bond amount. It returns an error if the validator has no tokens.

func (Validator) SharesFromTokensTruncated

func (v Validator) SharesFromTokensTruncated(amt sdk.Int) (sdk.Dec, error)

func (Validator) TokensFromShares

func (v Validator) TokensFromShares(shares sdk.Dec) sdk.Dec

calculate the token worth of provided shares

func (Validator) TokensFromSharesRoundUp

func (v Validator) TokensFromSharesRoundUp(shares sdk.Dec) sdk.Dec

TokensFromSharesRoundUp returns the token worth of provided shares, rounded up.

func (Validator) TokensFromSharesTruncated

func (v Validator) TokensFromSharesTruncated(shares sdk.Dec) sdk.Dec

calculate the token worth of provided shares, truncated

func (Validator) UpdateStatus

func (v Validator) UpdateStatus(newStatus sdk.BondStatus) Validator

UpdateStatus updates the location of the shares within a validator to reflect the new status

type ValidatorOperatorAddressResponse

type ValidatorOperatorAddressResponse struct {
	ConsAddress     string `json:"cons_address"`
	OperatorAddress string `json:"operator_address"`
	Found           bool   `json:"found"`
}

func NewValidatorOperatorAddressResponse

func NewValidatorOperatorAddressResponse(consAddr, addr string, found bool) ValidatorOperatorAddressResponse

type Validators

type Validators []Validator

Validators is a collection of Validator

func (Validators) Len

func (v Validators) Len() int

Implements sort interface

func (Validators) Less

func (v Validators) Less(i, j int) bool

Implements sort interface

func (Validators) Sort

func (v Validators) Sort()

Sort Validators sorts validator array in ascending operator address order

func (Validators) Swap

func (v Validators) Swap(i, j int)

Implements sort interface

Jump to

Keyboard shortcuts

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