stake

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jan 5, 2018 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
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

View Source
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

func GetCandidateKey(pubKey crypto.PubKey) []byte

GetCandidateKey - get the key for the candidate with pubKey

func GetDelegatorBondKey added in v0.4.0

func GetDelegatorBondKey(delegator sdk.Actor, candidate crypto.PubKey) []byte

GetDelegatorBondKey - get the key for delegator bond with candidate

func GetDelegatorBondKeyPrefix added in v0.4.0

func GetDelegatorBondKeyPrefix(delegator sdk.Actor) []byte

GetDelegatorBondKeyPrefix - get the prefix for a delegator for all candidates

func GetDelegatorBondsKey added in v0.4.0

func GetDelegatorBondsKey(delegator sdk.Actor) []byte

GetDelegatorBondsKey - get the key for list of all the delegator's bonds

func Name

func Name() string

Name is the name of the modules.

func NewTxDeclareCandidacy added in v0.4.0

func NewTxDeclareCandidacy(bond coin.Coin, pubKey crypto.PubKey, description Description) sdk.Tx

NewTxDeclareCandidacy - new TxDeclareCandidacy

func NewTxDelegate added in v0.4.0

func NewTxDelegate(bond coin.Coin, pubKey crypto.PubKey) sdk.Tx

NewTxDelegate - new TxDelegate

func NewTxEditCandidacy added in v0.4.0

func NewTxEditCandidacy(pubKey crypto.PubKey, description Description) sdk.Tx

NewTxEditCandidacy - new TxEditCandidacy

func NewTxUnbond

func NewTxUnbond(shares uint64, pubKey crypto.PubKey) sdk.Tx

NewTxUnbond - new TxUnbond

func UpdateValidatorSet added in v0.4.0

func UpdateValidatorSet(store state.SimpleDB) (change []*abci.Validator, err error)

UpdateValidatorSet - Updates the voting power for the candidate set and returns the subset of validators which have changed for Tendermint

Types

type BondUpdate added in v0.4.0

type BondUpdate struct {
	PubKey crypto.PubKey `json:"pub_key"`
	Bond   coin.Coin     `json:"amount"`
}

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
	Shares      uint64        `json:"shares"`       // Total number of delegated shares to this candidate, equivalent to coins held in bond account
	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

func NewCandidate(pubKey crypto.PubKey, owner sdk.Actor) *Candidate

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

type DelegatorBond struct {
	PubKey crypto.PubKey
	Shares uint64
}

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

func (Handler) InitState

func (h Handler) InitState(l log.Logger, store state.SimpleDB,
	module, key, value string, cb sdk.InitStater) (log string, err error)

InitState - set genesis parameters for staking

func (Handler) Name

func (Handler) Name() string

Name - return stake namespace

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

type TxUnbond struct {
	PubKey crypto.PubKey `json:"pub_key"`
	Shares uint64        `json:"amount"`
}

TxUnbond - struct for unbonding transactions

func (TxUnbond) ValidateBasic

func (tx TxUnbond) ValidateBasic() error

ValidateBasic - Check for non-empty candidate, positive shares

func (TxUnbond) Wrap

func (tx TxUnbond) Wrap() sdk.Tx

Wrap - Wrap a Tx as a Basecoin Tx

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

func (v Validator) ABCIValidator() *abci.Validator

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)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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