Documentation ¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func BondCoins(ctx sdk.Context, k Keeper, bond DelegatorBond, candidate Candidate, ...) sdk.Error
- func ErrBadBondingAmount() sdk.Error
- func ErrBadBondingDenom() sdk.Error
- func ErrBadCandidateAddr() sdk.Error
- func ErrBadDelegatorAddr() sdk.Error
- func ErrBadRemoveValidator() sdk.Error
- func ErrBadShares() sdk.Error
- func ErrBadValidatorAddr() sdk.Error
- func ErrBondNotNominated() sdk.Error
- func ErrCandidateEmpty() sdk.Error
- func ErrCandidateExistsAddr() sdk.Error
- func ErrCommissionHuge() sdk.Error
- func ErrCommissionNegative() sdk.Error
- func ErrInsufficientFunds() sdk.Error
- func ErrMissingSignature() sdk.Error
- func ErrNoBondingAcct() sdk.Error
- func ErrNoCandidateForAddress() sdk.Error
- func ErrNoDelegatorForAddress() sdk.Error
- func ErrNotEnoughBondShares(shares string) sdk.Error
- func GetAccUpdateValidatorKey(addr sdk.Address) []byte
- func GetCandidateKey(addr sdk.Address) []byte
- func GetDelegatorBondKey(delegatorAddr, candidateAddr sdk.Address, cdc *wire.Codec) []byte
- func GetDelegatorBondsKey(delegatorAddr sdk.Address, cdc *wire.Codec) []byte
- func GetRecentValidatorKey(addr sdk.Address) []byte
- func GetValidatorKey(addr sdk.Address, power sdk.Rat, cdc *wire.Codec) []byte
- func NewHandler(k Keeper, ck bank.CoinKeeper) sdk.Handler
- func RegisterWire(cdc *wire.Codec)
- func UnbondCoins(ctx sdk.Context, k Keeper, bond DelegatorBond, candidate Candidate, ...) sdk.Error
- type Candidate
- type CandidateStatus
- type Candidates
- type CodeType
- type DelegatorBond
- type Description
- type Keeper
- func (k Keeper) GetCandidate(ctx sdk.Context, addr sdk.Address) (candidate Candidate, found bool)
- func (k Keeper) GetCandidates(ctx sdk.Context, maxRetrieve int16) (candidates Candidates)
- func (k Keeper) GetParams(ctx sdk.Context) (params Params)
- func (k Keeper) GetPool(ctx sdk.Context) (gs Pool)
- func (k Keeper) GetValidators(ctx sdk.Context) (validators []Validator)
- func (k Keeper) IsRecentValidator(ctx sdk.Context, address sdk.Address) bool
- func (k Keeper) Tick(ctx sdk.Context) (change []*abci.Validator, err error)
- type MsgDeclareCandidacy
- func (msg MsgDeclareCandidacy) Get(key interface{}) (value interface{})
- func (msg MsgDeclareCandidacy) GetSignBytes() []byte
- func (msg MsgDeclareCandidacy) GetSigners() []sdk.Address
- func (msg MsgDeclareCandidacy) String() string
- func (msg MsgDeclareCandidacy) Type() string
- func (msg MsgDeclareCandidacy) ValidateBasic() sdk.Error
- type MsgDelegate
- type MsgEditCandidacy
- func (msg MsgEditCandidacy) Get(key interface{}) (value interface{})
- func (msg MsgEditCandidacy) GetSignBytes() []byte
- func (msg MsgEditCandidacy) GetSigners() []sdk.Address
- func (msg MsgEditCandidacy) String() string
- func (msg MsgEditCandidacy) Type() string
- func (msg MsgEditCandidacy) ValidateBasic() sdk.Error
- type MsgUnbond
- type Params
- type Pool
- type Validator
Constants ¶
const ( GasDeclareCandidacy int64 = 20 GasEditCandidacy int64 = 20 GasDelegate int64 = 20 GasUnbond int64 = 20 )
nolint
const MsgType = "stake"
name to idetify transaction types
const StakingToken = "fermion"
XXX remove: think it makes more sense belonging with the Params so we can initialize at genesis - to allow for the same tests we should should make the ValidateBasic() function a return from an initializable function ValidateBasic(bondDenom string) function
Variables ¶
var ( // Keys for store prefixes ParamKey = []byte{0x00} // key for global parameters relating to staking PoolKey = []byte{0x01} // key for global parameters relating to staking CandidatesKey = []byte{0x02} // prefix for each key to a candidate ValidatorsKey = []byte{0x03} // prefix for each key to a validator AccUpdateValidatorsKey = []byte{0x04} // prefix for each key to a validator which is being updated RecentValidatorsKey = []byte{0x04} // prefix for each key to the last updated validator group DelegatorBondKeyPrefix = []byte{0x05} // prefix for each key to a delegator's bond )
nolint
Functions ¶
func BondCoins ¶ added in v0.13.0
func BondCoins(ctx sdk.Context, k Keeper, bond DelegatorBond, candidate Candidate, amount sdk.Coin) sdk.Error
Perform all the actions required to bond tokens to a delegator bond from their account
func ErrBadBondingAmount ¶
func ErrBadBondingDenom ¶
func ErrBadCandidateAddr ¶
func ErrBadDelegatorAddr ¶
func ErrBadRemoveValidator ¶
func ErrBadShares ¶
func ErrBadValidatorAddr ¶
func ErrBondNotNominated ¶
func ErrCandidateEmpty ¶
func ErrCandidateExistsAddr ¶
func ErrCommissionHuge ¶
func ErrCommissionNegative ¶
func ErrInsufficientFunds ¶
func ErrMissingSignature ¶
func ErrNoBondingAcct ¶
func ErrNotEnoughBondShares ¶
func GetAccUpdateValidatorKey ¶
get the key for the accumulated update validators
func GetCandidateKey ¶
get the key for the candidate with address
func GetDelegatorBondKey ¶
get the key for delegator bond with candidate
func GetDelegatorBondsKey ¶
get the prefix for a delegator for all candidates
func GetRecentValidatorKey ¶
get the key for the accumulated update validators
func GetValidatorKey ¶
get the key for the validator used in the power-store
func NewHandler ¶
func NewHandler(k Keeper, ck bank.CoinKeeper) sdk.Handler
Types ¶
type Candidate ¶
type Candidate struct { Status CandidateStatus `json:"status"` // Bonded status Address sdk.Address `json:"owner"` // Sender of BondTx - UnbondTx returns here PubKey crypto.PubKey `json:"pub_key"` // Pubkey of candidate Assets sdk.Rat `json:"assets"` // total shares of a global hold pools Liabilities sdk.Rat `json:"liabilities"` // total shares issued to a candidate's delegators Description Description `json:"description"` // Description terms for the candidate }
Candidate 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 candidate, the candidate is credited with a DelegatorBond 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 NewCandidate ¶
NewCandidate - initialize a new candidate
type CandidateStatus ¶
type CandidateStatus byte
CandidateStatus - status of a validator-candidate
const ( // nolint Bonded CandidateStatus = 0x00 Unbonded CandidateStatus = 0x01 Revoked CandidateStatus = 0x02 )
type CodeType ¶
const ( // Gaia errors reserve 200 ~ 299. CodeInvalidValidator CodeType = 201 CodeInvalidCandidate CodeType = 202 CodeInvalidBond CodeType = 203 CodeInvalidInput CodeType = 204 CodeInternal CodeType = sdk.CodeInternal CodeUnknownRequest CodeType = sdk.CodeUnknownRequest )
type DelegatorBond ¶
type DelegatorBond struct { DelegatorAddr sdk.Address `json:"delegatoraddr"` CandidateAddr sdk.Address `json:"candidate_addr"` }
DelegatorBond 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. TODO better way of managing space
type Description ¶
type Description struct { Moniker string `json:"moniker"` Identity string `json:"identity"` Website string `json:"website"` Details string `json:"details"` }
Description - description fields for a candidate
func NewDescription ¶
func NewDescription(moniker, identity, website, details string) Description
type Keeper ¶
type Keeper struct {
// contains filtered or unexported fields
}
keeper of the staking store
func (Keeper) GetCandidate ¶
get a single candidate
func (Keeper) GetCandidates ¶
func (k Keeper) GetCandidates(ctx sdk.Context, maxRetrieve int16) (candidates Candidates)
Get the set of all candidates, retrieve a maxRetrieve number of records
func (Keeper) GetValidators ¶
get the most recent updated validator set from the Candidates. These bonds are already sorted by Assets from the UpdateVotingPower function which is the only function which is to modify the Assets this function also updaates the most recent validators saved in store
func (Keeper) IsRecentValidator ¶
Is the address provided a part of the most recently saved validator group?
type MsgDeclareCandidacy ¶
type MsgDeclareCandidacy struct { Description CandidateAddr sdk.Address `json:"address"` PubKey crypto.PubKey `json:"pubkey"` Bond sdk.Coin `json:"bond"` }
MsgDeclareCandidacy - struct for unbonding transactions
func NewMsgDeclareCandidacy ¶
func NewMsgDeclareCandidacy(candidateAddr sdk.Address, pubkey crypto.PubKey, bond sdk.Coin, description Description) MsgDeclareCandidacy
func (MsgDeclareCandidacy) Get ¶
func (msg MsgDeclareCandidacy) Get(key interface{}) (value interface{})
func (MsgDeclareCandidacy) GetSignBytes ¶
func (msg MsgDeclareCandidacy) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgDeclareCandidacy) GetSigners ¶
func (msg MsgDeclareCandidacy) GetSigners() []sdk.Address
func (MsgDeclareCandidacy) String ¶
func (msg MsgDeclareCandidacy) String() string
func (MsgDeclareCandidacy) ValidateBasic ¶
func (msg MsgDeclareCandidacy) ValidateBasic() sdk.Error
quick validity check
type MsgDelegate ¶
type MsgDelegate struct { DelegatorAddr sdk.Address `json:"address"` CandidateAddr sdk.Address `json:"address"` Bond sdk.Coin `json:"bond"` }
MsgDelegate - struct for bonding transactions
func NewMsgDelegate ¶
func NewMsgDelegate(delegatorAddr, candidateAddr sdk.Address, bond sdk.Coin) MsgDelegate
func (MsgDelegate) Get ¶
func (msg MsgDelegate) Get(key interface{}) (value interface{})
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.Address
func (MsgDelegate) String ¶
func (msg MsgDelegate) String() string
func (MsgDelegate) ValidateBasic ¶
func (msg MsgDelegate) ValidateBasic() sdk.Error
quick validity check
type MsgEditCandidacy ¶
type MsgEditCandidacy struct { Description CandidateAddr sdk.Address `json:"address"` }
MsgEditCandidacy - struct for editing a candidate
func NewMsgEditCandidacy ¶
func NewMsgEditCandidacy(candidateAddr sdk.Address, description Description) MsgEditCandidacy
func (MsgEditCandidacy) Get ¶
func (msg MsgEditCandidacy) Get(key interface{}) (value interface{})
func (MsgEditCandidacy) GetSignBytes ¶
func (msg MsgEditCandidacy) GetSignBytes() []byte
get the bytes for the message signer to sign on
func (MsgEditCandidacy) GetSigners ¶
func (msg MsgEditCandidacy) GetSigners() []sdk.Address
func (MsgEditCandidacy) String ¶
func (msg MsgEditCandidacy) String() string
func (MsgEditCandidacy) ValidateBasic ¶
func (msg MsgEditCandidacy) ValidateBasic() sdk.Error
quick validity check
type MsgUnbond ¶
type MsgUnbond struct { DelegatorAddr sdk.Address `json:"address"` CandidateAddr sdk.Address `json:"address"` }
MsgUnbond - struct for unbonding transactions
func NewMsgUnbond ¶
func (MsgUnbond) GetSignBytes ¶
get the bytes for the message signer to sign on
func (MsgUnbond) GetSigners ¶
func (MsgUnbond) ValidateBasic ¶
quick validity check
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 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 { TotalSupply int64 `json:"total_supply"` // total supply of all tokens BondedPool int64 `json:"bonded_pool"` // reserve of bonded tokens UnbondedPool int64 `json:"unbonded_pool"` // reserve of unbonded tokens held with candidates 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 }
Pool - dynamic parameters of the current state