stake

package
v0.13.0 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2018 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Overview

nolint

Index

Constants

View Source
const (
	GasDeclareCandidacy int64 = 20
	GasEditCandidacy    int64 = 20
	GasDelegate         int64 = 20
	GasUnbond           int64 = 20
)

nolint

View Source
const MsgType = "stake"

name to idetify transaction types

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

View Source
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 ErrBadBondingAmount() sdk.Error

func ErrBadBondingDenom

func ErrBadBondingDenom() sdk.Error

func ErrBadCandidateAddr

func ErrBadCandidateAddr() sdk.Error

func ErrBadDelegatorAddr

func ErrBadDelegatorAddr() sdk.Error

func ErrBadRemoveValidator

func ErrBadRemoveValidator() sdk.Error

func ErrBadShares

func ErrBadShares() sdk.Error

func ErrBadValidatorAddr

func ErrBadValidatorAddr() sdk.Error

func ErrBondNotNominated

func ErrBondNotNominated() sdk.Error

func ErrCandidateEmpty

func ErrCandidateEmpty() sdk.Error

func ErrCandidateExistsAddr

func ErrCandidateExistsAddr() sdk.Error

func ErrCommissionHuge

func ErrCommissionHuge() sdk.Error

func ErrCommissionNegative

func ErrCommissionNegative() sdk.Error

func ErrInsufficientFunds

func ErrInsufficientFunds() sdk.Error

func ErrMissingSignature

func ErrMissingSignature() sdk.Error

func ErrNoBondingAcct

func ErrNoBondingAcct() sdk.Error

func ErrNoCandidateForAddress

func ErrNoCandidateForAddress() sdk.Error

func ErrNoDelegatorForAddress

func ErrNoDelegatorForAddress() sdk.Error

func ErrNotEnoughBondShares

func ErrNotEnoughBondShares(shares string) sdk.Error

func GetAccUpdateValidatorKey

func GetAccUpdateValidatorKey(addr sdk.Address) []byte

get the key for the accumulated update validators

func GetCandidateKey

func GetCandidateKey(addr sdk.Address) []byte

get the key for the candidate with address

func GetDelegatorBondKey

func GetDelegatorBondKey(delegatorAddr, candidateAddr sdk.Address, cdc *wire.Codec) []byte

get the key for delegator bond with candidate

func GetDelegatorBondsKey

func GetDelegatorBondsKey(delegatorAddr sdk.Address, cdc *wire.Codec) []byte

get the prefix for a delegator for all candidates

func GetRecentValidatorKey

func GetRecentValidatorKey(addr sdk.Address) []byte

get the key for the accumulated update validators

func GetValidatorKey

func GetValidatorKey(addr sdk.Address, power sdk.Rat, cdc *wire.Codec) []byte

get the key for the validator used in the power-store

func NewHandler

func NewHandler(k Keeper, ck bank.CoinKeeper) sdk.Handler

func RegisterWire

func RegisterWire(cdc *wire.Codec)

XXX complete

func UnbondCoins added in v0.13.0

func UnbondCoins(ctx sdk.Context, k Keeper, bond DelegatorBond, candidate Candidate, shares sdk.Rat) sdk.Error

XXX where this used Perform all the actions required to bond tokens to a delegator bond from their account

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

func NewCandidate(address sdk.Address, pubKey crypto.PubKey, description Description) Candidate

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 Candidates

type Candidates []Candidate

Candidates - list of Candidates

type CodeType

type CodeType = sdk.CodeType
const (
	// Gaia errors reserve 200 ~ 299.
	CodeInvalidValidator CodeType = 201
	CodeInvalidCandidate CodeType = 202
	CodeInvalidBond      CodeType = 203
	CodeInvalidInput     CodeType = 204
	CodeUnauthorized     CodeType = sdk.CodeUnauthorized
	CodeInternal         CodeType = sdk.CodeInternal
	CodeUnknownRequest   CodeType = sdk.CodeUnknownRequest
)

type DelegatorBond

type DelegatorBond struct {
	DelegatorAddr sdk.Address `json:"delegatoraddr"`
	CandidateAddr sdk.Address `json:"candidate_addr"`
	Shares        sdk.Rat     `json:"shares"`
}

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 NewKeeper

func NewKeeper(ctx sdk.Context, cdc *wire.Codec, key sdk.StoreKey, ck bank.CoinKeeper) Keeper

func (Keeper) GetCandidate

func (k Keeper) GetCandidate(ctx sdk.Context, addr sdk.Address) (candidate Candidate, found bool)

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) GetParams

func (k Keeper) GetParams(ctx sdk.Context) (params Params)

load/save the global staking params

func (Keeper) GetPool

func (k Keeper) GetPool(ctx sdk.Context) (gs Pool)

load/save the global staking state

func (Keeper) GetValidators

func (k Keeper) GetValidators(ctx sdk.Context) (validators []Validator)

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

func (k Keeper) IsRecentValidator(ctx sdk.Context, address sdk.Address) bool

Is the address provided a part of the most recently saved validator group?

func (Keeper) Tick

func (k Keeper) Tick(ctx sdk.Context) (change []*abci.Validator, err error)

Tick - called at the end of every block

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) Type

func (msg MsgDeclareCandidacy) Type() string

nolint

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) Type

func (msg MsgDelegate) Type() string

nolint

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) Type

func (msg MsgEditCandidacy) Type() string

nolint

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"`
	Shares        string      `json:"shares"`
}

MsgUnbond - struct for unbonding transactions

func NewMsgUnbond

func NewMsgUnbond(delegatorAddr, candidateAddr sdk.Address, shares string) MsgUnbond

func (MsgUnbond) Get

func (msg MsgUnbond) Get(key interface{}) (value interface{})

func (MsgUnbond) GetSignBytes

func (msg MsgUnbond) GetSignBytes() []byte

get the bytes for the message signer to sign on

func (MsgUnbond) GetSigners

func (msg MsgUnbond) GetSigners() []sdk.Address

func (MsgUnbond) String

func (msg MsgUnbond) String() string

func (MsgUnbond) Type

func (msg MsgUnbond) Type() string

nolint

func (MsgUnbond) ValidateBasic

func (msg MsgUnbond) ValidateBasic() sdk.Error

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
	BondedShares      sdk.Rat `json:"bonded_shares"`       // sum of all shares distributed for the Bonded Pool
	UnbondedShares    sdk.Rat `json:"unbonded_shares"`     // sum of all shares distributed for the Unbonded Pool
	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

type Validator

type Validator struct {
	Address     sdk.Address `json:"address"`      // Address of validator
	VotingPower sdk.Rat     `json:"voting_power"` // Voting power if considered a validator
}

Validator is one of the top Candidates

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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