stake

package
v0.1.0-rc.7 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2018 License: GPL-3.0 Imports: 28 Imported by: 15

Documentation

Overview

nolint

Index

Constants

View Source
const (
	ByteTxDeclareCandidacy  = 0x55
	ByteTxUpdateCandidacy   = 0x56
	ByteTxWithdrawCandidacy = 0x57
	ByteTxVerifyCandidacy   = 0x58
	ByteTxActivateCandidacy = 0x59
	ByteTxDelegate          = 0x60
	ByteTxWithdraw          = 0x61
	ByteTxSetCompRate       = 0x62
	TypeTxDeclareCandidacy  = "stake/declareCandidacy"
	TypeTxUpdateCandidacy   = "stake/updateCandidacy"
	TypeTxVerifyCandidacy   = "stake/verifyCandidacy"
	TypeTxWithdrawCandidacy = "stake/withdrawCandidacy"
	TypeTxActivateCandidacy = "stake/activateCandidacy"
	TypeTxDelegate          = "stake/delegate"
	TypeTxWithdraw          = "stake/withdraw"
	TypeTxSetCompRate       = "stake/set-comprate"
)

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

This section is empty.

Functions

func CheckTx

func CheckTx(ctx types.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error)

CheckTx checks if the tx is properly structured

func DeliverTx

func DeliverTx(ctx types.Context, store state.SimpleDB, tx sdk.Tx, hash []byte) (res sdk.DeliverResult, err error)

DeliverTx executes the tx if valid

func ErrBadAmount

func ErrBadAmount() error

func ErrBadCompRate

func ErrBadCompRate() error

func ErrBadValidatorAddr

func ErrBadValidatorAddr() error

func ErrCandidateExistsAddr

func ErrCandidateExistsAddr() error

func ErrCandidateWithdrawalDisallowed

func ErrCandidateWithdrawalDisallowed() error

func ErrDelegationNotExists

func ErrDelegationNotExists() error

func ErrInsufficientFunds

func ErrInsufficientFunds() error

func ErrInvalidCubeSignature

func ErrInvalidCubeSignature() error

func ErrInvalidWithdrawalAmount

func ErrInvalidWithdrawalAmount() error

func ErrMissingSignature

func ErrMissingSignature() error

func ErrReachMaxAmount

func ErrReachMaxAmount() error

func ErrVerificationDisallowed

func ErrVerificationDisallowed() error

func ErrVerifiedAlready

func ErrVerifiedAlready() error

func GetCandidateDailyStakeMaxValue

func GetCandidateDailyStakeMaxValue(pubKey types.PubKey, startDate string) (res sdk.Int)

func GetCandidatesTotalShares

func GetCandidatesTotalShares() (res sdk.Int)

func HandlePendingUnstakeRequests

func HandlePendingUnstakeRequests(height int64) error

func NewAwardDistributor

func NewAwardDistributor(store state.SimpleDB, height int64, validators, backupValidators Validators, logger log.Logger) *awardDistributor

func NewTxActivateCandidacy

func NewTxActivateCandidacy() sdk.Tx

func NewTxDeclareCandidacy

func NewTxDeclareCandidacy(pubKey types.PubKey, maxAmount string, compRate sdk.Rat, descrpition Description) sdk.Tx

func NewTxDelegate

func NewTxDelegate(validatorAddress common.Address, amount, cubeBatch, sig string) sdk.Tx

func NewTxSetCompRate

func NewTxSetCompRate(delegatorAddress common.Address, compRate sdk.Rat) sdk.Tx

func NewTxUpdateCandidacy

func NewTxUpdateCandidacy(maxAmount string, description Description) sdk.Tx

func NewTxVerifyCandidacy

func NewTxVerifyCandidacy(candidateAddress common.Address, verified bool) sdk.Tx

func NewTxWithdraw

func NewTxWithdraw(validatorAddress common.Address, amount string) sdk.Tx

func NewTxWithdrawCandidacy

func NewTxWithdrawCandidacy() sdk.Tx

func RecordCandidateDailyStakes

func RecordCandidateDailyStakes() error

func RemoveCandidateDailyStakes

func RemoveCandidateDailyStakes(pubKey types.PubKey, startDate string)

func RemoveDelegation

func RemoveDelegation(delegatorAddress common.Address, pubKey types.PubKey)

func RemoveDelegator

func RemoveDelegator(delegator *Delegator)

func RemoveValidator

func RemoveValidator(pubKey types.PubKey) (err error)

func ResetDeliverSqlTx

func ResetDeliverSqlTx()

func SaveCandidate

func SaveCandidate(candidate *Candidate)

func SaveCandidateDailyStake

func SaveCandidateDailyStake(cds *CandidateDailyStake)

func SaveDelegation

func SaveDelegation(d *Delegation)

func SaveDelegator

func SaveDelegator(delegator *Delegator)

func SetDeliverSqlTx

func SetDeliverSqlTx(tx *sql.Tx)

func SetGenesisValidator

func SetGenesisValidator(val types.GenesisValidator, store state.SimpleDB) error

func SlashAbsentValidator

func SlashAbsentValidator(pubKey types.PubKey, absence *Absence) (err error)

func SlashBadProposer

func SlashBadProposer(pubKey types.PubKey) (err error)

func SlashByzantineValidator

func SlashByzantineValidator(pubKey types.PubKey) (err error)

func UpdateDelegation

func UpdateDelegation(d *Delegation)

func UpdateValidatorSet

func UpdateValidatorSet() (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

func VerifyCubeSignature

func VerifyCubeSignature(address common.Address, nonce uint64, cubeBatch string, sig string) error

Types

type Absence

type Absence struct {
	// contains filtered or unexported fields
}

func (*Absence) Accumulate

func (a *Absence) Accumulate()

func (Absence) GetCount

func (a Absence) GetCount() int16

type AbsentValidators

type AbsentValidators struct {
	Validators map[types.PubKey]*Absence
}

func NewAbsentValidators

func NewAbsentValidators() *AbsentValidators

func (AbsentValidators) Add

func (av AbsentValidators) Add(pk types.PubKey, height int64)

func (AbsentValidators) Clear

func (av AbsentValidators) Clear(currentBlockHeight int64)

func (AbsentValidators) Contains

func (av AbsentValidators) Contains(pk types.PubKey) bool

func (AbsentValidators) Remove

func (av AbsentValidators) Remove(pk types.PubKey)

type AwardInfo

type AwardInfo struct {
	Address common.Address `json:"address"`
	State   string         `json:"state"`
	Amount  string         `json:"amount"`
}

type AwardInfos

type AwardInfos []AwardInfo

type Candidate

type Candidate struct {
	PubKey             types.PubKey `json:"pub_key"`       // Pubkey of candidate
	OwnerAddress       string       `json:"owner_address"` // Sender of BondTx - UnbondTx returns here
	Shares             string       `json:"shares"`        // Total number of delegated shares to this candidate, equivalent to coins held in bond account
	VotingPower        int64        `json:"voting_power"`  // Voting power if pubKey is a considered a validator
	PendingVotingPower int64        `json:"pending_voting_power"`
	MaxShares          string       `json:"max_shares"`
	CompRate           sdk.Rat      `json:"comp_rate"`
	CreatedAt          string       `json:"created_at"`
	UpdatedAt          string       `json:"updated_at"`
	Description        Description  `json:"description"`
	Verified           string       `json:"verified"`
	Active             string       `json:"active"`
	BlockHeight        int64        `json:"block_height"`
	Rank               int64        `json:"rank"`
	State              string       `json:"state"`
	NumOfDelegator     int64        `json:"num_of_delegators"`
}

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 GetCandidateByAddress(address common.Address) *Candidate

func GetCandidateByPubKey

func GetCandidateByPubKey(pubKey types.PubKey) *Candidate

func QueryCandidateByAddress

func QueryCandidateByAddress(address common.Address) *Candidate

func (*Candidate) AddShares

func (c *Candidate) AddShares(value sdk.Int) (res sdk.Int)

func (*Candidate) CalcVotingPower

func (c *Candidate) CalcVotingPower() (res int64)

func (*Candidate) Hash

func (c *Candidate) Hash() []byte

func (*Candidate) ParseMaxShares

func (c *Candidate) ParseMaxShares() sdk.Int

func (*Candidate) ParseShares

func (c *Candidate) ParseShares() sdk.Int

func (*Candidate) SelfStakingAmount

func (c *Candidate) SelfStakingAmount(ssr sdk.Rat) (res sdk.Int)

func (*Candidate) Validator

func (c *Candidate) Validator() Validator

Validator returns a copy of the Candidate as a Validator. Should only be called when the Candidate qualifies as a validator.

type CandidateDailyStake

type CandidateDailyStake struct {
	Id        int64
	PubKey    types.PubKey
	Amount    string
	CreatedAt string
}

type Candidates

type Candidates []*Candidate

func GetBackupValidators

func GetBackupValidators() (candidates Candidates)

func GetCandidates

func GetCandidates() (candidates Candidates)

func QueryCandidates

func QueryCandidates() (candidates Candidates)

func (Candidates) Len

func (cs Candidates) Len() int

nolint - sort interface functions

func (Candidates) Less

func (cs Candidates) Less(i, j int) bool

func (Candidates) Sort

func (cs Candidates) Sort()

Sort - Sort the array of bonded values

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 CubePubKey

type CubePubKey struct {
	CubeBatch string `json:"cube_batch"`
	PubKey    string `json:"pub_key"`
}

type DelegateHistory

type DelegateHistory struct {
	Id               int64
	DelegatorAddress common.Address
	PubKey           types.PubKey
	Amount           sdk.Int
	OpCode           string
	CreatedAt        string
}

type Delegation

type Delegation struct {
	DelegatorAddress common.Address `json:"delegator_address"`
	PubKey           types.PubKey   `json:"pub_key"`
	DelegateAmount   string         `json:"delegate_amount"`
	AwardAmount      string         `json:"award_amount"`
	WithdrawAmount   string         `json:"withdraw_amount"`
	SlashAmount      string         `json:"slash_amount"`
	CompRate         sdk.Rat        `json:"comp_rate"`
	VotingPower      int64          `json:"voting_power"`
	CreatedAt        string         `json:"created_at"`
	UpdatedAt        string         `json:"updated_at"`
	State            string         `json:"state"`
}

func GetDelegation

func GetDelegation(delegatorAddress common.Address, pubKey types.PubKey) *Delegation

func GetDelegationsByPubKey

func GetDelegationsByPubKey(pubKey types.PubKey, state string) (delegations []*Delegation)

func QueryDelegationsByDelegator

func QueryDelegationsByDelegator(delegatorAddress common.Address) (delegations []*Delegation)

func (*Delegation) AddAwardAmount

func (d *Delegation) AddAwardAmount(value sdk.Int) (res sdk.Int)

func (*Delegation) AddDelegateAmount

func (d *Delegation) AddDelegateAmount(value sdk.Int) (res sdk.Int)

func (*Delegation) AddSlashAmount

func (d *Delegation) AddSlashAmount(value sdk.Int) (res sdk.Int)

func (*Delegation) AddWithdrawAmount

func (d *Delegation) AddWithdrawAmount(value sdk.Int) (res sdk.Int)

func (*Delegation) CalcVotingPower

func (d *Delegation) CalcVotingPower(sharesPercentage sdk.Rat) int64

func (*Delegation) Hash

func (d *Delegation) Hash() []byte

func (*Delegation) ParseAwardAmount

func (d *Delegation) ParseAwardAmount() sdk.Int

func (*Delegation) ParseDelegateAmount

func (d *Delegation) ParseDelegateAmount() sdk.Int

func (*Delegation) ParseSlashAmount

func (d *Delegation) ParseSlashAmount() sdk.Int

func (*Delegation) ParseWithdrawAmount

func (d *Delegation) ParseWithdrawAmount() sdk.Int

func (*Delegation) Shares

func (d *Delegation) Shares() (res sdk.Int)

type Delegator

type Delegator struct {
	Address   common.Address
	CreatedAt string
}

func GetDelegator

func GetDelegator(address string) *Delegator

type Description

type Description struct {
	Name     string `json:"name"`
	Website  string `json:"website"`
	Location string `json:"location"`
	Email    string `json:"email"`
	Profile  string `json:"profile"`
}

type PunishHistory

type PunishHistory struct {
	PubKey        types.PubKey
	SlashingRatio sdk.Rat
	SlashAmount   sdk.Int
	Reason        string
	CreatedAt     string
}

type SqlTxWrapper

type SqlTxWrapper struct {
	// contains filtered or unexported fields
}

func (*SqlTxWrapper) Commit

func (wrapper *SqlTxWrapper) Commit()

func (*SqlTxWrapper) Rollback

func (wrapper *SqlTxWrapper) Rollback()

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      string      `json:"pub_key"`
	MaxAmount   string      `json:"max_amount"`
	CompRate    sdk.Rat     `json:"comp_rate"`
	Description Description `json:"description"`
}

func (TxDeclareCandidacy) SelfStakingAmount

func (tx TxDeclareCandidacy) SelfStakingAmount(ssr sdk.Rat) (res sdk.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"`
	CubeBatch        string         `json:"cube_batch"`
	Sig              string         `json:"sig"`
}

TxDelegate - struct for bonding or unbonding transactions

func (TxDelegate) ValidateBasic

func (tx TxDelegate) ValidateBasic() error

func (TxDelegate) Wrap

func (tx TxDelegate) Wrap() sdk.Tx

Wrap - Wrap a Tx as a Travis Tx

type TxSetCompRate

type TxSetCompRate struct {
	DelegatorAddress common.Address `json:"delegator_address"`
	CompRate         sdk.Rat        `json:"comp_rate"`
}

func (TxSetCompRate) ValidateBasic

func (tx TxSetCompRate) ValidateBasic() error

func (TxSetCompRate) Wrap

func (tx TxSetCompRate) Wrap() sdk.Tx

Wrap - Wrap a Tx as a Travis Tx

type TxUpdateCandidacy

type TxUpdateCandidacy struct {
	MaxAmount   string      `json:"max_amount"`
	Description Description `json:"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

Wrap - Wrap a Tx as a Travis 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 UnstakeRequest

type UnstakeRequest struct {
	Id                   int64
	DelegatorAddress     common.Address
	PubKey               types.PubKey
	InitiatedBlockHeight int64
	PerformedBlockHeight int64
	Amount               string
	State                string
	CreatedAt            string
	UpdatedAt            string
}

func GetUnstakeRequests

func GetUnstakeRequests(height int64) (reqs []*UnstakeRequest)

func (*UnstakeRequest) Hash

func (r *UnstakeRequest) Hash() []byte

type Validator

type Validator Candidate

Validator is one of the top Candidates

func (Validator) ABCIValidator

func (v Validator) ABCIValidator() abci.Validator

ABCIValidator - Get the validator from a bond value

type Validators

type Validators []Validator

Validators - list of Validators

func (Validators) Len

func (vs Validators) Len() int

nolint - sort interface functions

func (Validators) Less

func (vs Validators) Less(i, j int) bool

func (Validators) Remove

func (vs Validators) Remove(i int) Validators

func (Validators) Sort

func (vs Validators) Sort()

Sort - Sort validators by pubkey

func (Validators) Swap

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