state

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2020 License: MIT Imports: 30 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CandidateStatusOffline = 0x01
	CandidateStatusOnline  = 0x02
)
View Source
const MaxDelegatorsPerCandidate = 1000
View Source
const UnbondPeriod = 518400

Variables

View Source
var (
	ValidatorMaxAbsentWindow = 24
	ValidatorMaxAbsentTimes  = 12
)

Functions

This section is empty.

Types

type Account

type Account struct {
	Nonce        uint64
	Balance      Balances
	MultisigData Multisig
}

Account is the Minter consensus representation of accounts. These objects are stored in the main account trie.

type Balance

type Balance struct {
	Coin   types.CoinSymbol
	Amount *big.Int
}

type Balances

type Balances struct {
	Data map[types.CoinSymbol]*big.Int
}

func (*Balances) DecodeRLP

func (b *Balances) DecodeRLP(s *rlp.Stream) error

func (Balances) EncodeRLP

func (b Balances) EncodeRLP(w io.Writer) error

type Candidate

type Candidate struct {
	RewardAddress  types.Address
	OwnerAddress   types.Address
	TotalBipStake  *big.Int
	PubKey         types.Pubkey
	Commission     uint
	Stakes         []Stake
	CreatedAtBlock uint
	Status         byte
	// contains filtered or unexported fields
}

func (Candidate) GetAddress added in v0.2.0

func (candidate Candidate) GetAddress() [20]byte

func (Candidate) GetStakeOfAddress

func (candidate Candidate) GetStakeOfAddress(addr types.Address, coin types.CoinSymbol) *Stake

func (Candidate) String

func (candidate Candidate) String() string

type Candidates

type Candidates []Candidate

type Coin

type Coin struct {
	Name           string
	Symbol         types.CoinSymbol
	Volume         *big.Int
	Crr            uint
	ReserveBalance *big.Int
}

func (Coin) String

func (coin Coin) String() string

type FrozenFund

type FrozenFund struct {
	Address      types.Address
	CandidateKey []byte
	Coin         types.CoinSymbol
	Value        *big.Int
}

type FrozenFunds

type FrozenFunds struct {
	List []FrozenFund
}

func (FrozenFunds) String

func (f FrozenFunds) String() string

type ImmutableTree added in v0.4.1

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

func NewImmutableTree added in v0.20.5

func NewImmutableTree(db dbm.DB) *ImmutableTree

func (*ImmutableTree) DeleteVersion added in v0.4.1

func (t *ImmutableTree) DeleteVersion(version int64) error

func (*ImmutableTree) Get added in v0.4.1

func (t *ImmutableTree) Get(key []byte) (index int64, value []byte)

func (*ImmutableTree) GetImmutable added in v0.4.1

func (t *ImmutableTree) GetImmutable() *ImmutableTree

func (*ImmutableTree) GetImmutableAtHeight added in v0.20.5

func (t *ImmutableTree) GetImmutableAtHeight(version int64) (*ImmutableTree, error)

func (*ImmutableTree) Hash added in v0.4.1

func (t *ImmutableTree) Hash() []byte

func (*ImmutableTree) Iterate added in v0.15.0

func (t *ImmutableTree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)

func (*ImmutableTree) LazyLoadVersion added in v1.0.4

func (t *ImmutableTree) LazyLoadVersion(targetVersion int64) (int64, error)

func (*ImmutableTree) LoadVersion added in v0.4.1

func (t *ImmutableTree) LoadVersion(targetVersion int64) (int64, error)

func (*ImmutableTree) Remove added in v0.4.1

func (t *ImmutableTree) Remove(key []byte) ([]byte, bool)

func (*ImmutableTree) SaveVersion added in v0.4.1

func (t *ImmutableTree) SaveVersion() ([]byte, int64, error)

func (*ImmutableTree) Set added in v0.4.1

func (t *ImmutableTree) Set(key, value []byte) bool

func (*ImmutableTree) Version added in v0.4.1

func (t *ImmutableTree) Version() int64

type Multisig added in v0.5.0

type Multisig struct {
	Weights   []uint
	Threshold uint
	Addresses []types.Address
}

func (*Multisig) Address added in v0.5.0

func (m *Multisig) Address() types.Address

func (*Multisig) GetWeight added in v0.5.0

func (m *Multisig) GetWeight(address types.Address) uint

type MutableTree added in v0.4.1

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

func NewMutableTree added in v0.4.1

func NewMutableTree(db dbm.DB) *MutableTree

func (*MutableTree) DeleteVersion added in v0.4.1

func (t *MutableTree) DeleteVersion(version int64) error

func (*MutableTree) Get added in v0.4.1

func (t *MutableTree) Get(key []byte) (index int64, value []byte)

func (*MutableTree) GetImmutable added in v0.4.1

func (t *MutableTree) GetImmutable() *ImmutableTree

func (*MutableTree) GetImmutableAtHeight added in v0.20.5

func (t *MutableTree) GetImmutableAtHeight(version int64) (*ImmutableTree, error)

func (*MutableTree) Hash added in v0.4.1

func (t *MutableTree) Hash() []byte

func (*MutableTree) Iterate added in v0.15.0

func (t *MutableTree) Iterate(fn func(key []byte, value []byte) bool) (stopped bool)

func (*MutableTree) LazyLoadVersion added in v1.0.4

func (t *MutableTree) LazyLoadVersion(targetVersion int64) (int64, error)

func (*MutableTree) LoadVersion added in v0.4.1

func (t *MutableTree) LoadVersion(targetVersion int64) (int64, error)

func (*MutableTree) Remove added in v0.4.1

func (t *MutableTree) Remove(key []byte) ([]byte, bool)

func (*MutableTree) SaveVersion added in v0.4.1

func (t *MutableTree) SaveVersion() ([]byte, int64, error)

func (*MutableTree) Set added in v0.4.1

func (t *MutableTree) Set(key, value []byte) bool

func (*MutableTree) Version added in v0.4.1

func (t *MutableTree) Version() int64

type Stake

type Stake struct {
	Owner    types.Address
	Coin     types.CoinSymbol
	Value    *big.Int
	BipValue *big.Int
}

func (*Stake) CalcBipValue added in v0.3.0

func (s *Stake) CalcBipValue(context *StateDB) *big.Int

func (*Stake) CalcSimulatedBipValue added in v1.0.2

func (s *Stake) CalcSimulatedBipValue(context *StateDB) *big.Int

func (*Stake) MarshalJSON

func (s *Stake) MarshalJSON() ([]byte, error)

type StakeCache added in v0.3.0

type StakeCache struct {
	TotalValue *big.Int
	BipValue   *big.Int
}

type StateDB

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

func New

func New(height uint64, db dbm.DB, keepState bool) (*StateDB, error)

func NewForCheck added in v0.4.1

func NewForCheck(height uint64, db dbm.DB) (*StateDB, error)

func NewForCheckFromDeliver added in v0.20.5

func NewForCheckFromDeliver(s *StateDB) *StateDB

func (*StateDB) AccountExists added in v0.5.0

func (s *StateDB) AccountExists(address types.Address) bool

func (*StateDB) AddAccumReward

func (s *StateDB) AddAccumReward(pubkey types.Pubkey, reward *big.Int)

func (*StateDB) AddBalance

func (s *StateDB) AddBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)

AddBalance adds amount to the account associated with addr

func (*StateDB) AddCoinReserve

func (s *StateDB) AddCoinReserve(symbol types.CoinSymbol, value *big.Int)

func (*StateDB) AddCoinVolume

func (s *StateDB) AddCoinVolume(symbol types.CoinSymbol, value *big.Int)

func (*StateDB) AddTotalSlashed added in v0.15.0

func (s *StateDB) AddTotalSlashed(value *big.Int)

func (*StateDB) CandidateExists

func (s *StateDB) CandidateExists(key types.Pubkey) bool

func (*StateDB) CandidatesCount added in v0.5.0

func (s *StateDB) CandidatesCount() int

func (*StateDB) CheckForInvariants added in v0.15.0

func (s *StateDB) CheckForInvariants() error

func (*StateDB) Clear added in v0.4.1

func (s *StateDB) Clear()

func (*StateDB) ClearCandidates added in v0.5.0

func (s *StateDB) ClearCandidates()

func (*StateDB) ClearStakes added in v0.5.0

func (s *StateDB) ClearStakes()

func (*StateDB) CoinExists

func (s *StateDB) CoinExists(symbol types.CoinSymbol) bool

func (*StateDB) Commit

func (s *StateDB) Commit() (root []byte, version int64, err error)

Commit writes the state to the underlying in-memory trie database.

func (*StateDB) CreateCandidate

func (s *StateDB) CreateCandidate(
	rewardAddress types.Address,
	ownerAddress types.Address,
	pubkey types.Pubkey,
	commission uint,
	currentBlock uint,
	coin types.CoinSymbol,
	initialStake *big.Int) *stateCandidates

func (*StateDB) CreateCoin

func (s *StateDB) CreateCoin(
	symbol types.CoinSymbol,
	name string,
	volume *big.Int,
	crr uint,
	reserve *big.Int) *stateCoin

func (*StateDB) CreateMultisig added in v0.5.0

func (s *StateDB) CreateMultisig(weights []uint, addresses []types.Address, threshold uint) types.Address

func (*StateDB) CreateValidator added in v0.2.0

func (s *StateDB) CreateValidator(
	rewardAddress types.Address,
	pubkey types.Pubkey,
	commission uint,
	currentBlock uint,
	coin types.CoinSymbol,
	initialStake *big.Int) *stateValidators

func (*StateDB) DB added in v0.20.5

func (s *StateDB) DB() dbm.DB

func (*StateDB) Delegate

func (s *StateDB) Delegate(sender types.Address, pubkey []byte, coin types.CoinSymbol, value *big.Int)

func (*StateDB) EditCandidate added in v0.10.0

func (s *StateDB) EditCandidate(pubkey []byte, newRewardAddress types.Address, newOwnerAddress types.Address)

func (*StateDB) Export added in v0.15.0

func (s *StateDB) Export(currentHeight uint64) types.AppState

func (*StateDB) GetBalance

func (s *StateDB) GetBalance(addr types.Address, coinSymbol types.CoinSymbol) *big.Int

Retrieve the balance from the given address or 0 if object not found

func (*StateDB) GetBalances

func (s *StateDB) GetBalances(addr types.Address) Balances

func (*StateDB) GetCandidates added in v0.2.0

func (s *StateDB) GetCandidates(count int, block int64) []Candidate

func (*StateDB) GetCurrentMaxGas added in v0.9.0

func (s *StateDB) GetCurrentMaxGas() uint64

func (*StateDB) GetMaxGas added in v0.12.1

func (s *StateDB) GetMaxGas() uint64

func (*StateDB) GetNonce

func (s *StateDB) GetNonce(addr types.Address) uint64

func (*StateDB) GetOrNewStateFrozenFunds

func (s *StateDB) GetOrNewStateFrozenFunds(blockHeight uint64) *stateFrozenFund

func (*StateDB) GetOrNewStateObject

func (s *StateDB) GetOrNewStateObject(addr types.Address) *stateAccount

Retrieve a state object or create a new state object if nil

func (*StateDB) GetStateCandidate

func (s *StateDB) GetStateCandidate(key types.Pubkey) *Candidate

func (*StateDB) GetStateCandidateByTmAddress added in v0.15.0

func (s *StateDB) GetStateCandidateByTmAddress(address [20]byte) *Candidate

func (*StateDB) GetStateCandidates added in v0.2.0

func (s *StateDB) GetStateCandidates() (stateCandidates *stateCandidates)

func (*StateDB) GetStateCoin

func (s *StateDB) GetStateCoin(symbol types.CoinSymbol) *stateCoin

func (*StateDB) GetStateFrozenFunds

func (s *StateDB) GetStateFrozenFunds(blockHeight uint64) *stateFrozenFund

func (*StateDB) GetStateValidators added in v0.2.0

func (s *StateDB) GetStateValidators() (stateValidators *stateValidators)

func (*StateDB) GetTotalSlashed added in v0.15.0

func (s *StateDB) GetTotalSlashed() *big.Int

func (*StateDB) Height added in v0.17.1

func (s *StateDB) Height() uint64

func (*StateDB) Import added in v0.15.0

func (s *StateDB) Import(appState types.AppState)

func (*StateDB) IsCheckUsed

func (s *StateDB) IsCheckUsed(check *check.Check) bool

func (*StateDB) IsDelegatorStakeSufficient added in v0.5.0

func (s *StateDB) IsDelegatorStakeSufficient(sender types.Address, pubKey []byte, coinSymbol types.CoinSymbol,
	value *big.Int) bool

func (*StateDB) IsNewCandidateStakeSufficient added in v0.5.0

func (s *StateDB) IsNewCandidateStakeSufficient(coinSymbol types.CoinSymbol, stake *big.Int) bool

func (*StateDB) MarkStateCandidateDirty

func (s *StateDB) MarkStateCandidateDirty()

func (*StateDB) MarkStateCoinDirty

func (s *StateDB) MarkStateCoinDirty(symbol types.CoinSymbol)

func (*StateDB) MarkStateFrozenFundsDirty

func (s *StateDB) MarkStateFrozenFundsDirty(blockHeight uint64)

func (*StateDB) MarkStateObjectDirty

func (s *StateDB) MarkStateObjectDirty(addr types.Address)

MarkStateObjectDirty adds the specified object to the dirty map to avoid costly state object cache iteration to find a handful of modified ones.

func (*StateDB) MarkStateValidatorsDirty added in v0.2.0

func (s *StateDB) MarkStateValidatorsDirty()

func (*StateDB) MultisigAccountExists added in v0.5.0

func (s *StateDB) MultisigAccountExists(address types.Address) bool

func (*StateDB) PayRewards

func (s *StateDB) PayRewards()

func (*StateDB) PunishByzantineValidator added in v0.2.0

func (s *StateDB) PunishByzantineValidator(address [20]byte)

func (*StateDB) PunishFrozenFundsWithAddress added in v0.3.0

func (s *StateDB) PunishFrozenFundsWithAddress(fromBlock uint64, toBlock uint64, address [20]byte)

func (*StateDB) RecalculateTotalStakeValues

func (s *StateDB) RecalculateTotalStakeValues()

func (*StateDB) RemoveCurrentValidator added in v0.3.0

func (s *StateDB) RemoveCurrentValidator(pubkey types.Pubkey)

func (*StateDB) SanitizeCoin added in v0.16.0

func (s *StateDB) SanitizeCoin(symbol types.CoinSymbol)

func (*StateDB) SetBalance

func (s *StateDB) SetBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)

func (*StateDB) SetCandidateOffline

func (s *StateDB) SetCandidateOffline(pubkey []byte)

func (*StateDB) SetCandidateOnline

func (s *StateDB) SetCandidateOnline(pubkey []byte)

func (*StateDB) SetMaxGas added in v0.9.0

func (s *StateDB) SetMaxGas(maxGas uint64)

func (*StateDB) SetNewValidators added in v0.2.0

func (s *StateDB) SetNewValidators(candidates []Candidate)

func (*StateDB) SetNonce

func (s *StateDB) SetNonce(addr types.Address, nonce uint64)

func (*StateDB) SetStateValidators added in v0.3.0

func (s *StateDB) SetStateValidators(validators *stateValidators)

func (*StateDB) SetValidatorAbsent

func (s *StateDB) SetValidatorAbsent(address [20]byte)

func (*StateDB) SetValidatorPresent

func (s *StateDB) SetValidatorPresent(address [20]byte)

func (*StateDB) StakeExists added in v0.5.0

func (s *StateDB) StakeExists(owner types.Address, pubKey []byte, coinSymbol types.CoinSymbol) bool

func (*StateDB) SubBalance

func (s *StateDB) SubBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)

SubBalance subtracts amount from the account associated with addr

func (*StateDB) SubCoinReserve

func (s *StateDB) SubCoinReserve(symbol types.CoinSymbol, value *big.Int)

func (*StateDB) SubCoinVolume

func (s *StateDB) SubCoinVolume(symbol types.CoinSymbol, value *big.Int)

func (*StateDB) SubStake

func (s *StateDB) SubStake(sender types.Address, pubkey []byte, coin types.CoinSymbol, value *big.Int)

func (*StateDB) UseCheck

func (s *StateDB) UseCheck(check *check.Check)

type Tree added in v0.4.1

type Tree interface {
	Get(key []byte) (index int64, value []byte)
	Set(key, value []byte) bool
	Remove(key []byte) ([]byte, bool)
	LoadVersion(targetVersion int64) (int64, error)
	LazyLoadVersion(targetVersion int64) (int64, error)
	SaveVersion() ([]byte, int64, error)
	DeleteVersion(version int64) error
	GetImmutable() *ImmutableTree
	GetImmutableAtHeight(version int64) (*ImmutableTree, error)
	Version() int64
	Hash() []byte
	Iterate(fn func(key []byte, value []byte) bool) (stopped bool)
}

type Validator added in v0.2.0

type Validator struct {
	RewardAddress types.Address
	TotalBipStake *big.Int
	PubKey        types.Pubkey
	Commission    uint
	AccumReward   *big.Int
	AbsentTimes   *types.BitArray
	// contains filtered or unexported fields
}

func (*Validator) CountAbsentTimes added in v0.4.0

func (validator *Validator) CountAbsentTimes() int

func (Validator) GetAddress added in v0.2.0

func (validator Validator) GetAddress() [20]byte

func (*Validator) IsToDrop added in v0.3.0

func (validator *Validator) IsToDrop() bool

func (Validator) String added in v0.2.0

func (validator Validator) String() string

type Validators added in v0.2.0

type Validators []Validator

Jump to

Keyboard shortcuts

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