Documentation
¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func ErrBadRemoveValidator() error
- func ErrBadValidatorAddr() error
- func ErrBondNotNominated() error
- func ErrCandidateExistsAddr() error
- func ErrInsufficientFunds() error
- func ErrMissingSignature() error
- func ErrNoCandidateForAddress() error
- func ErrNoDelegatorForAddress() error
- func GetCandidateKey(pubKey crypto.PubKey) []byte
- func GetDelegatorBondKey(delegator sdk.Actor, candidate crypto.PubKey) []byte
- func GetDelegatorBondKeyPrefix(delegator sdk.Actor) []byte
- func GetDelegatorBondsKey(delegator sdk.Actor) []byte
- func Name() string
- func NewTxDeclareCandidacy(bond coin.Coin, pubKey crypto.PubKey, description Description) sdk.Tx
- func NewTxDelegate(bond coin.Coin, pubKey crypto.PubKey) sdk.Tx
- func NewTxEditCandidacy(pubKey crypto.PubKey, description Description) sdk.Tx
- func NewTxUnbond(shares uint64, pubKey crypto.PubKey) sdk.Tx
- func UpdateValidatorSet(store state.SimpleDB) (change []*abci.Validator, err error)
- type BondUpdate
- type Candidate
- type Candidates
- type DelegatorBond
- type Description
- type Handler
- func (Handler) AssertDispatcher()
- func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error)
- func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, dispatch sdk.Deliver) (res sdk.DeliverResult, err error)
- func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, value string, ...) (log string, err error)
- func (Handler) Name() string
- type Params
- type TxDeclareCandidacy
- type TxDelegate
- type TxEditCandidacy
- type TxUnbond
- type Validator
- type Validators
Constants ¶
const ( ByteTxDeclareCandidacy = 0x55 ByteTxEditCandidacy = 0x56 ByteTxDelegate = 0x57 ByteTxUnbond = 0x58 TypeTxDeclareCandidacy = stakingModuleName + "/declareCandidacy" TypeTxEditCandidacy = stakingModuleName + "/editCandidacy" TypeTxDelegate = stakingModuleName + "/delegate" TypeTxUnbond = stakingModuleName + "/unbond" )
register the tx type with its validation logic make sure to use the name of the handler as the prefix in the tx type, so it gets routed properly
Variables ¶
var ( // Keys for store prefixes CandidatesPubKeysKey = []byte{0x01} // key for all candidates' pubkeys ParamKey = []byte{0x02} // key for global parameters relating to staking // Key prefixes CandidateKeyPrefix = []byte{0x03} // prefix for each key to a candidate DelegatorBondKeyPrefix = []byte{0x04} // prefix for each key to a delegator's bond DelegatorBondsKeyPrefix = []byte{0x05} // prefix for each key to a delegator's bond )
nolint
Functions ¶
func ErrBadRemoveValidator ¶ added in v0.4.0
func ErrBadRemoveValidator() error
func ErrBadValidatorAddr ¶ added in v0.4.0
func ErrBadValidatorAddr() error
func ErrBondNotNominated ¶ added in v0.4.0
func ErrBondNotNominated() error
func ErrCandidateExistsAddr ¶ added in v0.4.0
func ErrCandidateExistsAddr() error
func ErrInsufficientFunds ¶ added in v0.4.0
func ErrInsufficientFunds() error
func ErrMissingSignature ¶ added in v0.4.0
func ErrMissingSignature() error
func ErrNoCandidateForAddress ¶ added in v0.4.0
func ErrNoCandidateForAddress() error
func ErrNoDelegatorForAddress ¶ added in v0.4.0
func ErrNoDelegatorForAddress() error
func GetCandidateKey ¶ added in v0.4.0
GetCandidateKey - get the key for the candidate with pubKey
func GetDelegatorBondKey ¶ added in v0.4.0
GetDelegatorBondKey - get the key for delegator bond with candidate
func GetDelegatorBondKeyPrefix ¶ added in v0.4.0
GetDelegatorBondKeyPrefix - get the prefix for a delegator for all candidates
func GetDelegatorBondsKey ¶ added in v0.4.0
GetDelegatorBondsKey - get the key for list of all the delegator's bonds
func NewTxDeclareCandidacy ¶ added in v0.4.0
NewTxDeclareCandidacy - new TxDeclareCandidacy
func NewTxDelegate ¶ added in v0.4.0
NewTxDelegate - new TxDelegate
func NewTxEditCandidacy ¶ added in v0.4.0
func NewTxEditCandidacy(pubKey crypto.PubKey, description Description) sdk.Tx
NewTxEditCandidacy - new TxEditCandidacy
func NewTxUnbond ¶
NewTxUnbond - new TxUnbond
Types ¶
type BondUpdate ¶ added in v0.4.0
BondUpdate - struct for bonding or unbonding transactions
func (BondUpdate) ValidateBasic ¶ added in v0.4.0
func (tx BondUpdate) ValidateBasic() error
ValidateBasic - Check for non-empty candidate, and valid coins
type Candidate ¶ added in v0.4.0
type Candidate struct {
PubKey crypto.PubKey `json:"pub_key"` // Pubkey of candidate
Owner sdk.Actor `json:"owner"` // Sender of BondTx - UnbondTx returns here
VotingPower uint64 `json:"voting_power"` // Voting power if pubKey is a considered a validator
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. NOTE if the Owner.Empty() == true then this is a candidate who has revoked candidacy
func NewCandidate ¶ added in v0.4.0
NewCandidate - initialize a new candidate
type Candidates ¶ added in v0.4.0
type Candidates []*Candidate
Candidates - list of Candidates
func (Candidates) Len ¶ added in v0.4.0
func (cs Candidates) Len() int
nolint - sort interface functions
func (Candidates) Less ¶ added in v0.4.0
func (cs Candidates) Less(i, j int) bool
func (Candidates) Sort ¶ added in v0.4.0
func (cs Candidates) Sort()
Sort - Sort the array of bonded values
func (Candidates) Swap ¶ added in v0.4.0
func (cs Candidates) Swap(i, j int)
func (Candidates) Validators ¶ added in v0.4.0
func (cs Candidates) Validators() Validators
Validators - get the most recent updated validator set from the Candidates. These bonds are already sorted by VotingPower from the UpdateVotingPower function which is the only function which is to modify the VotingPower
type DelegatorBond ¶ added in v0.4.0
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.
type Description ¶ added in v0.4.0
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
type Handler ¶
type Handler struct {
stack.PassInitValidate
}
Handler - the transaction processing handler
func NewHandler ¶
func NewHandler() Handler
NewHandler returns a new Handler with the default Params
func (Handler) AssertDispatcher ¶
func (Handler) AssertDispatcher()
AssertDispatcher - placeholder for stack.Dispatchable
func (Handler) CheckTx ¶
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, _ sdk.Checker) (res sdk.CheckResult, err error)
CheckTx checks if the tx is properly structured
func (Handler) DeliverTx ¶
func (h Handler) DeliverTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx, dispatch sdk.Deliver) (res sdk.DeliverResult, err error)
DeliverTx executes the tx if valid
type Params ¶
type Params struct {
HoldAccount sdk.Actor `json:"hold_account"` // PubKey where all bonded coins are held
MaxVals uint16 `json:"max_vals"` // maximum number of validators
AllowedBondDenom string `json:"allowed_bond_denom"` // bondable coin denomination
// gas costs for txs
GasDeclareCandidacy int64 `json:"gas_declare_candidacy"`
GasEditCandidacy int64 `json:"gas_edit_candidacy"`
GasDelegate int64 `json:"gas_delegate"`
GasUnbond int64 `json:"gas_unbond"`
}
Params defines the high level settings for staking
type TxDeclareCandidacy ¶ added in v0.4.0
type TxDeclareCandidacy struct {
BondUpdate
Description
}
TxDeclareCandidacy - struct for unbonding transactions
func (TxDeclareCandidacy) Wrap ¶ added in v0.4.0
func (tx TxDeclareCandidacy) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type TxDelegate ¶ added in v0.4.0
type TxDelegate struct{ BondUpdate }
TxDelegate - struct for bonding transactions
func (TxDelegate) Wrap ¶ added in v0.4.0
func (tx TxDelegate) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type TxEditCandidacy ¶ added in v0.4.0
type TxEditCandidacy struct {
PubKey crypto.PubKey `json:"pub_key"`
Description
}
TxEditCandidacy - struct for editing a candidate
func (TxEditCandidacy) ValidateBasic ¶ added in v0.4.0
func (tx TxEditCandidacy) ValidateBasic() error
ValidateBasic - Check for non-empty candidate,
func (TxEditCandidacy) Wrap ¶ added in v0.4.0
func (tx TxEditCandidacy) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type TxUnbond ¶
TxUnbond - struct for unbonding transactions
func (TxUnbond) ValidateBasic ¶
ValidateBasic - Check for non-empty candidate, positive shares
type Validator ¶ added in v0.4.0
type Validator Candidate
Validator is one of the top Candidates
func (Validator) ABCIValidator ¶ added in v0.4.0
ABCIValidator - Get the validator from a bond value
type Validators ¶ added in v0.4.0
type Validators []Validator
Validators - list of Validators
func (Validators) Len ¶ added in v0.4.0
func (vs Validators) Len() int
nolint - sort interface functions
func (Validators) Less ¶ added in v0.4.0
func (vs Validators) Less(i, j int) bool
func (Validators) Sort ¶ added in v0.4.0
func (vs Validators) Sort()
Sort - Sort validators by pubkey
func (Validators) Swap ¶ added in v0.4.0
func (vs Validators) Swap(i, j int)