Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func ErrBadDelegationAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrBadDelegationAmount(codespace sdk.CodespaceType) sdk.Error
- func ErrBadDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrBadDenom(codespace sdk.CodespaceType) sdk.Error
- func ErrBadPercentStake(codespace sdk.CodespaceType) sdk.Error
- func ErrBadRedelegationAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrBadRedelegationDst(codespace sdk.CodespaceType) sdk.Error
- func ErrBadRemoveValidator(codespace sdk.CodespaceType) sdk.Error
- func ErrBadSharesAmount(codespace sdk.CodespaceType) sdk.Error
- func ErrBadSharesPercent(codespace sdk.CodespaceType) sdk.Error
- func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrBothShareMsgsGiven(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionChangeRateGTMaxRate(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionChangeRateNegative(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionGTMaxChangeRate(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionGTMaxRate(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionHuge(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionNegative(codespace sdk.CodespaceType) sdk.Error
- func ErrCommissionUpdateTime(codespace sdk.CodespaceType) sdk.Error
- func ErrDelegationValidatorEmpty(codespace sdk.CodespaceType) sdk.Error
- func ErrDescriptionLength(codespace sdk.CodespaceType, descriptor string, got, max int) sdk.Error
- func ErrExistingUnbondingDelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrInSufficientMasterNodeToken(codespace sdk.CodespaceType) sdk.Error
- func ErrInsufficientShares(codespace sdk.CodespaceType) sdk.Error
- func ErrMissingSignature(codespace sdk.CodespaceType) sdk.Error
- func ErrNeitherShareMsgsGiven(codespace sdk.CodespaceType) sdk.Error
- func ErrNilDelegatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNilValidatorAddr(codespace sdk.CodespaceType) sdk.Error
- func ErrNoDelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrNoDelegationFound(codespace sdk.CodespaceType) sdk.Error
- func ErrNoDelegatorForAddress(codespace sdk.CodespaceType) sdk.Error
- func ErrNoRedelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrNoUnbondingDelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrNoValidatorFound(codespace sdk.CodespaceType) sdk.Error
- func ErrNotEnoughDelegationShares(codespace sdk.CodespaceType, shares string) sdk.Error
- func ErrNotMature(codespace sdk.CodespaceType, operation, descriptor string, got, min time.Time) sdk.Error
- func ErrTransitiveRedelegation(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorOwnerExists(codespace sdk.CodespaceType) sdk.Error
- func ErrValidatorPubKeyExists(codespace sdk.CodespaceType) sdk.Error
- func MustMarshalDelegation(cdc *amino.Codec, delegation Delegation) []byte
- func MustMarshalRED(cdc *amino.Codec, red Redelegation) []byte
- func MustMarshalUBD(cdc *amino.Codec, ubd UnbondingDelegation) []byte
- func MustMarshalValidator(cdc *amino.Codec, validator Validator) []byte
- func MustMarshalValidatorDist(cdc *amino.Codec, vdi ValidatorDistInfo) []byte
- func SortABCIValidators(av []abci.Validator) []abci.Validator
- type CodeType
- type Delegation
- func (b Delegation) GetBondShares() types.Dec
- func (b Delegation) GetDelegator() sdk.AccAddress
- func (b Delegation) GetValidator() sdk.AccAddress
- func (b Delegation) HumanReadableString() (string, error)
- func (b Delegation) UpdateDelAccum(currentHeight int64, totalRewardAccum types.Coin, totalShares types.Dec) Delegation
- type Description
- type Params
- type Pool
- type Redelegation
- type SortValidators
- type UnbondingDelegation
- type Validator
- func (v Validator) ABCIValidator() abci.Validator
- func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate
- func (v Validator) ABCIValidatorZero() abci.ValidatorUpdate
- func (v Validator) AddTokensFromDel(pool Pool, amount types.Dec) (Validator, Pool, types.Dec)
- func (v Validator) BondedTokens() types.Dec
- func (v Validator) DelegatorShareExRate() types.Dec
- func (v Validator) Equal(c2 Validator) bool
- func (v Validator) GetABCIPubKey() secp256k1.PubKeySecp256k1
- func (v Validator) GetBondHeight() int64
- func (v Validator) GetDelegatorShares() types.Dec
- func (v Validator) GetMoniker() string
- func (v Validator) GetOwner() sdk.AccAddress
- func (v Validator) GetPower() types.Dec
- func (v Validator) GetPubKey() types.PubKey
- func (v Validator) GetStatus() types.BondStatus
- func (v Validator) HumanReadableString() (string, error)
- func (v Validator) IsDelegatingTokenValid(pool Pool, tokenAMount types.Dec) bool
- func (v Validator) IsUnbonded(ctx sdk.Context) bool
- func (v Validator) RemoveDelShares(pool Pool, delShares types.Dec) (Validator, Pool, types.Dec)
- func (v Validator) RemoveTokens(pool Pool, tokens types.Dec) (Validator, Pool)
- func (v Validator) UpdateStatus(pool Pool, NewStatus types.BondStatus) (Validator, Pool)
- type ValidatorDistInfo
- type Validators
Constants ¶
const DoNotModifyDes = "[do-not-modify]"
const DoNotModifyDesc = "[do-not-modify]"
constant used in flags to indicate that description field should not be updated
Variables ¶
var MaxPartialToken types.Dec = types.NewDec(2) //100/2
Functions ¶
func ErrBadDelegationAddr ¶
func ErrBadDelegationAddr(codespace sdk.CodespaceType) sdk.Error
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 ErrBadRedelegationAddr ¶
func ErrBadRedelegationAddr(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 ErrBadValidatorAddr ¶
func ErrBadValidatorAddr(codespace sdk.CodespaceType) sdk.Error
func ErrBothShareMsgsGiven ¶
func ErrBothShareMsgsGiven(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionChangeRateGTMaxRate ¶
func ErrCommissionChangeRateGTMaxRate(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionChangeRateNegative ¶
func ErrCommissionChangeRateNegative(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionGTMaxChangeRate ¶
func ErrCommissionGTMaxChangeRate(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionGTMaxRate ¶
func ErrCommissionGTMaxRate(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionHuge ¶
func ErrCommissionHuge(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionNegative ¶
func ErrCommissionNegative(codespace sdk.CodespaceType) sdk.Error
func ErrCommissionUpdateTime ¶
func ErrCommissionUpdateTime(codespace sdk.CodespaceType) sdk.Error
func ErrDelegationValidatorEmpty ¶
func ErrDelegationValidatorEmpty(codespace sdk.CodespaceType) sdk.Error
func ErrDescriptionLength ¶
func ErrExistingUnbondingDelegation ¶
func ErrExistingUnbondingDelegation(codespace sdk.CodespaceType) sdk.Error
func ErrInSufficientMasterNodeToken ¶
func ErrInSufficientMasterNodeToken(codespace sdk.CodespaceType) 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
func ErrNoDelegation ¶
func ErrNoDelegation(codespace sdk.CodespaceType) sdk.Error
func ErrNoDelegationFound ¶
func ErrNoDelegationFound(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 ErrTransitiveRedelegation ¶
func ErrTransitiveRedelegation(codespace sdk.CodespaceType) sdk.Error
func ErrValidatorJailed ¶
func ErrValidatorJailed(codespace sdk.CodespaceType) sdk.Error
func ErrValidatorOwnerExists ¶
func ErrValidatorOwnerExists(codespace sdk.CodespaceType) sdk.Error
func ErrValidatorPubKeyExists ¶
func ErrValidatorPubKeyExists(codespace sdk.CodespaceType) sdk.Error
func MustMarshalDelegation ¶
func MustMarshalDelegation(cdc *amino.Codec, delegation Delegation) []byte
aggregates of all delegations, unbondings and redelegations
type DelegationSummary struct { Delegations []Delegation `json:"delegations"` UnbondingDelegations []UnbondingDelegation `json:"unbonding_delegations"` Redelegations []Redelegation `json:"redelegations"` }
return the delegation without fields contained within the key for the store
func MustMarshalRED ¶
func MustMarshalRED(cdc *amino.Codec, red Redelegation) []byte
return the redelegation without fields contained within the key for the store
func MustMarshalUBD ¶
func MustMarshalUBD(cdc *amino.Codec, ubd UnbondingDelegation) []byte
return the unbonding delegation without fields contained within the key for the store
func MustMarshalValidator ¶
return the redelegation without fields contained within the key for the store
func MustMarshalValidatorDist ¶
func MustMarshalValidatorDist( cdc *amino.Codec, vdi ValidatorDistInfo, ) []byte
Types ¶
type CodeType ¶
const ( DefaultCodespace sdk.CodespaceType = "POS" CodeInvalidValidator CodeType = 101 CodeInvalidDelegation CodeType = 102 CodeInvalidInput CodeType = 103 CodeValidatorJailed CodeType = 104 CodeInvalidAddress CodeType = sdk.CodeInvalidAddress 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"` Height int64 `json:"height"` // Last height bond updated RewardAccum types.Coin `json:"reward_accum"` // reward accumulation of this block til withdrawal_height WithdrawalHeight int64 `json:"withdrawal_height` // latest withdrawal height }
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 *amino.Codec, key, value []byte) Delegation
return the delegation without fields contained within the key for the store
func UnmarshalDelegation ¶
func UnmarshalDelegation(cdc *amino.Codec, key, value []byte) (delegation Delegation, err error)
return the delegation without fields contained within the key for the store
func (Delegation) GetBondShares ¶
func (b Delegation) GetBondShares() types.Dec
func (Delegation) GetDelegator ¶
func (b Delegation) GetDelegator() sdk.AccAddress
nolint - for sdk.Delegation
func (Delegation) GetValidator ¶
func (b Delegation) GetValidator() sdk.AccAddress
func (Delegation) HumanReadableString ¶
func (b Delegation) HumanReadableString() (string, error)
Human Friendly pretty printer
func (Delegation) UpdateDelAccum ¶
func (b Delegation) UpdateDelAccum( currentHeight int64, totalRewardAccum types.Coin, totalShares types.Dec, ) Delegation
UpdateDelReward updating reward accumulation
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
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 Params ¶
type Params struct { GoalBonded types.Dec `json:"goal_bonded"` // Goal of percent bonded atoms UnbondingTime time.Duration `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
type Pool ¶
type Pool struct { LooseTokens types.Dec `json:"loose_tokens"` // tokens which are not bonded in a validator BondedTokens types.Dec `json:"bonded_tokens"` // reserve of bonded tokens DateLastCommissionReset int64 `json:"date_last_commission_reset"` // unix timestamp for last commission accounting reset (daily) PrevBondedShares types.Dec `json:"prev_bonded_shares"` // last recorded bonded shares - for fee calculations }
Pool - dynamic parameters of the current state
func MustUnmarshalPool ¶
unmarshal the current pool value from store key or panics
func UnmarshalPool ¶
unmarshal the current pool value from store key
func (Pool) BondedRatio ¶
get the bond ratio of the global state
func (Pool) HumanReadableString ¶
HumanReadableString returns a human readable string representation of a pool.
func (Pool) TokenSupply ¶
Sum total of all staking tokens in the pool
type Redelegation ¶
type Redelegation struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // delegator ValidatorSrcAddr sdk.AccAddress `json:"validator_src_addr"` // validator redelegation source operator addr ValidatorDstAddr sdk.AccAddress `json:"validator_dst_addr"` // validator redelegation destination operator addr CreationHeight int64 `json:"creation_height"` // height which the redelegation took place MinTime time.Time `json:"min_time"` // unix time for redelegation completion InitialBalance types.Coin `json:"initial_balance"` // initial balance when redelegation started Balance types.Coin `json:"balance"` // current balance }
Redelegation reflects a delegation's passive re-delegation queue.
func MustUnmarshalRED ¶
func MustUnmarshalRED(cdc *amino.Codec, key, value []byte) Redelegation
unmarshal a redelegation from a store key and value
func UnmarshalRED ¶
func UnmarshalRED(cdc *amino.Codec, key, value []byte) (red Redelegation, err error)
unmarshal a redelegation from a store key and value
type SortValidators ¶
func (SortValidators) Len ¶
func (av SortValidators) Len() int
func (SortValidators) Less ¶
func (av SortValidators) Less(i, j int) bool
func (SortValidators) Swap ¶
func (av SortValidators) Swap(i, j int)
type UnbondingDelegation ¶
type UnbondingDelegation struct { DelegatorAddr sdk.AccAddress `json:"delegator_addr"` // delegator ValidatorAddr sdk.AccAddress `json:"validator_addr"` // validator unbonding from operator addr CreationHeight int64 `json:"creation_height"` // height which the unbonding took place MinTime time.Time `json:"min_time"` // unix time for unbonding completion /*time.Time*/ InitialBalance types.Coin `json:"initial_balance"` // atoms initially scheduled to receive at completion Balance types.Coin `json:"balance"` // atoms to receive at completion }
UnbondingDelegation reflects a delegation's passive unbonding queue.
func MustUnmarshalUBD ¶
func MustUnmarshalUBD(cdc *amino.Codec, key, value []byte) UnbondingDelegation
unmarshal a unbonding delegation from a store key and value
func UnmarshalUBD ¶
func UnmarshalUBD(cdc *amino.Codec, key, value []byte) (ubd UnbondingDelegation, err error)
unmarshal a unbonding delegation from a store key and value
type Validator ¶
type Validator struct { Owner sdk.AccAddress `json:"owner"` // sender of BondTx - UnbondTx returns here PubKey types.PubKey `json:"pub_key"` // pubkey of validator Revoked bool `json:"revoked"` // has the validator been revoked from bonded status? Status types.BondStatus `json:"status"` // validator status (bonded/unbonding/unbonded) Tokens types.Dec `json:"tokens"` // delegated tokens (incl. self-delegation) CommissionRate types.Dec `json:"commission_rate"` // commision kept by this validator 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 UnbondingHeight int64 `json:"unbonding_height"` // if unbonding, height at which this validator has begun unbonding UnbondingMinTime time.Time `json:"unbonding_time"` // time.Time // if unbonding, min time for the validator to complete unbonding }
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 ¶
unmarshal a redelegation from a store key and value
func NewValidator ¶
func NewValidator(owner sdk.AccAddress, pubKey types.PubKey, description Description) Validator
NewValidator - initialize a new validator
func UnmarshalValidator ¶
func UnmarshalValidator(cdc *amino.Codec, owner sdk.AccAddress, value []byte) (validator Validator, err error)
unmarshal a redelegation from a store key and value
func (Validator) ABCIValidator ¶
func (Validator) ABCIValidatorUpdate ¶ added in v0.2.0
func (v Validator) ABCIValidatorUpdate() abci.ValidatorUpdate
validator which fulfills abci validator interface for use in Tendermint ABCIValidator returns an abci.Validator from a staked validator type.
func (Validator) ABCIValidatorZero ¶
func (v Validator) ABCIValidatorZero() abci.ValidatorUpdate
ABCIValidator returns an abci.Validator from a staked validator type.
func (Validator) AddTokensFromDel ¶
XXX Audit this function further to make sure it's correct add tokens to a validator
func (Validator) BondedTokens ¶
Get the bonded tokens which the validator holds
func (Validator) DelegatorShareExRate ¶
DelegatorShareExRate gets the exchange rate of tokens over delegator shares. UNITS: tokens/delegator-shares
func (Validator) GetABCIPubKey ¶
func (v Validator) GetABCIPubKey() secp256k1.PubKeySecp256k1
func (Validator) GetBondHeight ¶
func (Validator) GetDelegatorShares ¶
func (Validator) GetOwner ¶
func (v Validator) GetOwner() sdk.AccAddress
func (Validator) GetStatus ¶
func (v Validator) GetStatus() types.BondStatus
func (Validator) HumanReadableString ¶
Human Friendly pretty printer
func (Validator) IsDelegatingTokenValid ¶
check if the adding token violate the percent rule or not:
func (Validator) IsUnbonded ¶
Returns if the validator should be considered unbonded
func (Validator) RemoveDelShares ¶
RemoveDelShares removes delegator shares from a validator.
func (Validator) RemoveTokens ¶
removes tokens from a validator
func (Validator) UpdateStatus ¶
UpdateStatus updates the location of the shares within a validator to reflect the new status
type ValidatorDistInfo ¶
type ValidatorDistInfo struct { ValidatorAddr sdk.AccAddress `json:"validator_addr"` // Validator Address RewardAccum types.Coin `json:"reward_accum"` // Block Reward accumulation since BlockHeight, excluding commission Commission types.Coin `json:"commision"` // total commission WithdrawalHeight int64 `json:"withdrawal_height"` // Latest blockheight that performs reward distribution ValidatorReward types.Coin `json:"validator_reward"` // Validator reward accumulation not yet witdrawed }
func MustUnmarshalValidatorDist ¶
func MustUnmarshalValidatorDist( cdc *amino.Codec, value []byte, ) ValidatorDistInfo
func NewValidatorDistInfo ¶
func NewValidatorDistInfo( validatorAddress sdk.AccAddress, currentHeight int64, ) ValidatorDistInfo
NewValidatorDistInfo - return new ValidatorDistInfo
func UnmarshalValidatorDist ¶
func UnmarshalValidatorDist( cdc *amino.Codec, value []byte, ) ( vdi ValidatorDistInfo, err error, )
func (ValidatorDistInfo) HumanReadableString ¶
func (vdi ValidatorDistInfo) HumanReadableString() string