Documentation
¶
Overview ¶
nolint
Index ¶
- Constants
- Variables
- func ErrBadAmount() error
- func ErrBadValidatorAddr() error
- func ErrBondNotNominated() error
- func ErrCandidateExistsAddr() error
- func ErrCandidateWithdrawalDisallowed() error
- func ErrDelegationNotExists() error
- func ErrInsufficientFunds() error
- func ErrInvalidWithdrawalAmount() error
- func ErrMissingSignature() error
- func ErrNoCandidateForAddress() error
- func ErrReachMaxAmount() error
- func ErrVerificationDisallowed() error
- func ErrVerifiedAlready() error
- func NewAwardCalculator(height int64, validators Validators, transactionFees *big.Int) *awardCalculator
- func NewTxActivateCandidacy() sdk.Tx
- func NewTxDeclareCandidacy(pubKey crypto.PubKey, maxAmount, compRate string, descrpition Description) sdk.Tx
- func NewTxDelegate(validatorAddress common.Address, amount string) sdk.Tx
- func NewTxUpdateCandidacy(maxAmount string, description Description) sdk.Tx
- func NewTxVerifyCandidacy(candidateAddress common.Address, verified bool) sdk.Tx
- func NewTxWithdraw(validatorAddress common.Address, amount string) sdk.Tx
- func NewTxWithdrawCandidacy() sdk.Tx
- func PunishAbsentValidator(pubKey crypto.PubKey) (err error)
- func PunishByzantineValidator(pubKey crypto.PubKey) (err error)
- func RemoveDelegation(delegation *Delegation)
- func RemoveDelegator(delegator *Delegator)
- func SaveCandidate(candidate *Candidate)
- func SaveDelegation(d *Delegation)
- func SaveDelegator(delegator *Delegator)
- func UpdateDelegation(d *Delegation)
- func UpdateDelegatorAddress(d *Delegation, originalAddress common.Address)
- func UpdateValidatorSet(store state.SimpleDB, seed []byte) (change []*abci.Validator, err error)
- type Candidate
- type Candidates
- type DelegateHistory
- type Delegation
- func (d *Delegation) AddAwardAmount(value *big.Int) *big.Int
- func (d *Delegation) AddDelegateAmount(value *big.Int) *big.Int
- func (d *Delegation) AddSlashAmount(value *big.Int) *big.Int
- func (d *Delegation) AddWithdrawAmount(value *big.Int) *big.Int
- func (d *Delegation) ParseAwardAmount() *big.Int
- func (d *Delegation) ParseDelegateAmount() *big.Int
- func (d *Delegation) ParseSlashAmount() *big.Int
- func (d *Delegation) ParseWithdrawAmount() *big.Int
- func (d *Delegation) Shares() (shares *big.Int)
- type Delegator
- type Description
- type Params
- type PunishHistory
- type StakeTxHandler
- func (h *StakeTxHandler) CheckTx(ctx types.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
- func (h *StakeTxHandler) DeliverTx(ctx types.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.DeliverResult, err error)
- func (h *StakeTxHandler) InitState(key, value string, store state.SimpleDB) error
- type TxActivateCandidacy
- type TxDeclareCandidacy
- type TxDelegate
- type TxUpdateCandidacy
- type TxVerifyCandidacy
- type TxWithdraw
- type TxWithdrawCandidacy
- type Validator
- type Validators
Constants ¶
const ( ByteTxDeclareCandidacy = 0x55 ByteTxUpdateCandidacy = 0x56 ByteTxWithdrawCandidacy = 0x57 ByteTxVerifyCandidacy = 0x58 ByteTxActivateCandidacy = 0x59 ByteTxDelegate = 0x60 ByteTxWithdraw = 0x61 TypeTxDeclareCandidacy = stakingModuleName + "/declareCandidacy" TypeTxUpdateCandidacy = stakingModuleName + "/updateCandidacy" TypeTxVerifyCandidacy = stakingModuleName + "/verifyCandidacy" TypeTxWithdrawCandidacy = stakingModuleName + "/withdrawCandidacy" TypeTxActivateCandidacy = stakingModuleName + "/activateCandidacy" TypeTxDelegate = stakingModuleName + "/delegate" TypeTxWithdraw = stakingModuleName + "/withdraw" )
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 ParamKey = []byte{0x01} // key for global parameters relating to staking )
nolint
Functions ¶
func ErrBadAmount ¶
func ErrBadAmount() error
func ErrBadValidatorAddr ¶
func ErrBadValidatorAddr() error
func ErrBondNotNominated ¶
func ErrBondNotNominated() error
func ErrCandidateExistsAddr ¶
func ErrCandidateExistsAddr() error
func ErrCandidateWithdrawalDisallowed ¶
func ErrCandidateWithdrawalDisallowed() error
func ErrDelegationNotExists ¶
func ErrDelegationNotExists() error
func ErrInsufficientFunds ¶
func ErrInsufficientFunds() error
func ErrInvalidWithdrawalAmount ¶
func ErrInvalidWithdrawalAmount() error
func ErrMissingSignature ¶
func ErrMissingSignature() error
func ErrNoCandidateForAddress ¶
func ErrNoCandidateForAddress() error
func ErrReachMaxAmount ¶
func ErrReachMaxAmount() error
func ErrVerificationDisallowed ¶
func ErrVerificationDisallowed() error
func ErrVerifiedAlready ¶
func ErrVerifiedAlready() error
func NewAwardCalculator ¶
func NewAwardCalculator(height int64, validators Validators, transactionFees *big.Int) *awardCalculator
func NewTxActivateCandidacy ¶
func NewTxActivateCandidacy() sdk.Tx
func NewTxDeclareCandidacy ¶
func NewTxDeclareCandidacy(pubKey crypto.PubKey, maxAmount, compRate string, descrpition Description) sdk.Tx
func NewTxDelegate ¶
func NewTxUpdateCandidacy ¶
func NewTxUpdateCandidacy(maxAmount string, description Description) sdk.Tx
func NewTxVerifyCandidacy ¶
func NewTxWithdraw ¶
func NewTxWithdrawCandidacy ¶
func NewTxWithdrawCandidacy() sdk.Tx
func PunishAbsentValidator ¶
func RemoveDelegation ¶
func RemoveDelegation(delegation *Delegation)
func RemoveDelegator ¶
func RemoveDelegator(delegator *Delegator)
func SaveCandidate ¶
func SaveCandidate(candidate *Candidate)
func SaveDelegation ¶
func SaveDelegation(d *Delegation)
func SaveDelegator ¶
func SaveDelegator(delegator *Delegator)
func UpdateDelegation ¶
func UpdateDelegation(d *Delegation)
func UpdateDelegatorAddress ¶
func UpdateDelegatorAddress(d *Delegation, originalAddress common.Address)
Types ¶
type Candidate ¶
type Candidate struct {
PubKey crypto.PubKey `json:"pub_key"` // Pubkey of candidate
OwnerAddress common.Address `json:"owner_address"` // Sender of BondTx - UnbondTx returns here
VotingPower int64 `json:"voting_power"` // Voting power if pubKey is a considered a validator
CompRate string `json:"cut"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
Description Description `json:"description"`
Verified string `json:"verified"`
Active string `json:"active"`
}
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 GetCandidateByAddress ¶
func GetCandidateByPubKey ¶
func NewCandidate ¶
func NewCandidate(pubKey crypto.PubKey, ownerAddress common.Address, shares string, votingPower int64, maxShares, compRate string, description Description, verified string, active string) *Candidate
NewCandidate - initialize a new candidate
func (*Candidate) ParseCompRate ¶
func (*Candidate) ParseMaxShares ¶
func (*Candidate) ParseShares ¶
type Candidates ¶
type Candidates []*Candidate
func GetCandidates ¶
func GetCandidates() (candidates Candidates)
func (Candidates) Less ¶
func (cs Candidates) Less(i, j int) bool
func (Candidates) Swap ¶
func (cs Candidates) Swap(i, j int)
func (Candidates) Validators ¶
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 DelegateHistory ¶
type Delegation ¶
type Delegation struct {
DelegatorAddress common.Address `json:"delegator_address"`
PubKey crypto.PubKey `json:"pub_key"`
DelegateAmount string `json:"delegate_amount"`
AwardAmount string `json:"award_amount"`
WithdrawAmount string `json:"withdraw_amount"`
SlashAmount string `json:"slash_amount"`
CreatedAt string `json:"created_at"`
UpdatedAt string `json:"updated_at"`
}
func GetDelegation ¶
func GetDelegation(delegatorAddress common.Address, pubKey crypto.PubKey) *Delegation
func GetDelegationsByDelegator ¶
func GetDelegationsByDelegator(delegatorAddress common.Address) (delegations []*Delegation)
func GetDelegationsByPubKey ¶
func GetDelegationsByPubKey(pubKey crypto.PubKey) (delegations []*Delegation)
func (*Delegation) AddAwardAmount ¶
func (d *Delegation) AddAwardAmount(value *big.Int) *big.Int
func (*Delegation) AddDelegateAmount ¶
func (d *Delegation) AddDelegateAmount(value *big.Int) *big.Int
func (*Delegation) AddSlashAmount ¶
func (d *Delegation) AddSlashAmount(value *big.Int) *big.Int
func (*Delegation) AddWithdrawAmount ¶
func (d *Delegation) AddWithdrawAmount(value *big.Int) *big.Int
func (*Delegation) ParseAwardAmount ¶
func (d *Delegation) ParseAwardAmount() *big.Int
func (*Delegation) ParseDelegateAmount ¶
func (d *Delegation) ParseDelegateAmount() *big.Int
func (*Delegation) ParseSlashAmount ¶
func (d *Delegation) ParseSlashAmount() *big.Int
func (*Delegation) ParseWithdrawAmount ¶
func (d *Delegation) ParseWithdrawAmount() *big.Int
func (*Delegation) Shares ¶
func (d *Delegation) Shares() (shares *big.Int)
type Delegator ¶
func GetDelegator ¶
type Description ¶
type Params ¶
type Params struct {
StakeAccount common.Address `json:"stake_account"` // PubKey where all bonded coins are held
MaxVals uint16 `json:"max_vals"` // maximum number of validators
Validators string `json:"validators"` // initial validators definition
ReserveRequirementRatio string `json:"reserve_requirement_ratio"`
EnableHybridElection bool `json:"enable_hybrid_election"` // enable DPOS+VRF hybrid election
TicketPrice uint64 `json:"ticket_price"` // ticket price for each subuser in sortition
}
Params defines the high level settings for staking
type PunishHistory ¶
type StakeTxHandler ¶
type StakeTxHandler struct {
}
func (*StakeTxHandler) CheckTx ¶
func (h *StakeTxHandler) CheckTx(ctx types.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)
CheckTx checks if the tx is properly structured
type TxActivateCandidacy ¶
type TxActivateCandidacy struct{}
func (TxActivateCandidacy) ValidateBasic ¶
func (tx TxActivateCandidacy) ValidateBasic() error
ValidateBasic - Check for non-empty candidate, and valid coins
func (TxActivateCandidacy) Wrap ¶
func (tx TxActivateCandidacy) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type TxDeclareCandidacy ¶
type TxDeclareCandidacy struct {
PubKey crypto.PubKey `json:"pub_key"`
MaxAmount string `json:"max_amount"`
CompRate string `json:"comp_rate"`
Description
}
func (TxDeclareCandidacy) ReserveRequirement ¶
func (tx TxDeclareCandidacy) ReserveRequirement(ratio string) (result *big.Int)
func (TxDeclareCandidacy) ValidateBasic ¶
func (tx TxDeclareCandidacy) ValidateBasic() error
func (TxDeclareCandidacy) Wrap ¶
func (tx TxDeclareCandidacy) Wrap() sdk.Tx
type TxDelegate ¶
type TxDelegate struct {
ValidatorAddress common.Address `json:"validator_address"`
Amount string `json:"amount"`
}
TxDelegate - struct for bonding or unbonding transactions
func (TxDelegate) ValidateBasic ¶
func (tx TxDelegate) ValidateBasic() error
func (TxDelegate) Wrap ¶
func (tx TxDelegate) Wrap() sdk.Tx
type TxUpdateCandidacy ¶
type TxUpdateCandidacy struct {
MaxAmount string `json:"max_amount"`
Description
}
func (TxUpdateCandidacy) ValidateBasic ¶
func (tx TxUpdateCandidacy) ValidateBasic() error
func (TxUpdateCandidacy) Wrap ¶
func (tx TxUpdateCandidacy) Wrap() sdk.Tx
type TxVerifyCandidacy ¶
type TxVerifyCandidacy struct {
CandidateAddress common.Address `json:"candidate_address"`
Verified bool `json:"verified"`
}
func (TxVerifyCandidacy) ValidateBasic ¶
func (tx TxVerifyCandidacy) ValidateBasic() error
ValidateBasic - Check for non-empty candidate, and valid coins
func (TxVerifyCandidacy) Wrap ¶
func (tx TxVerifyCandidacy) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type TxWithdraw ¶
type TxWithdraw struct {
ValidatorAddress common.Address `json:"validator_address"`
Amount string `json:"amount"`
}
func (TxWithdraw) ValidateBasic ¶
func (tx TxWithdraw) ValidateBasic() error
func (TxWithdraw) Wrap ¶
func (tx TxWithdraw) Wrap() sdk.Tx
type TxWithdrawCandidacy ¶
type TxWithdrawCandidacy struct{}
func (TxWithdrawCandidacy) ValidateBasic ¶
func (tx TxWithdrawCandidacy) ValidateBasic() error
ValidateBasic - Check for non-empty candidate, and valid coins
func (TxWithdrawCandidacy) Wrap ¶
func (tx TxWithdrawCandidacy) Wrap() sdk.Tx
Wrap - Wrap a Tx as a Basecoin Tx
type Validator ¶
type Validator Candidate
Validator is one of the top Candidates
func (Validator) ABCIValidator ¶
ABCIValidator - Get the validator from a bond value
type Validators ¶
type Validators []Validator
Validators - list of Validators
func (Validators) Less ¶
func (vs Validators) Less(i, j int) bool
func (Validators) Remove ¶
func (vs Validators) Remove(i int32) Validators
func (Validators) Swap ¶
func (vs Validators) Swap(i, j int)