Documentation ¶
Index ¶
- Constants
- Variables
- func EmitBalanceChange(address types.Address, coin types.CoinSymbol, balance *big.Int)
- type Account
- type Balance
- type BalanceChangeStruct
- type Balances
- type BitArray
- func (bA *BitArray) Bytes() []byte
- func (bA *BitArray) GetIndex(i int) bool
- func (bA *BitArray) MarshalJSON() ([]byte, error)
- func (bA *BitArray) SetIndex(i int, v bool) bool
- func (bA *BitArray) Size() uint
- func (bA *BitArray) String() string
- func (bA *BitArray) StringIndented(indent string) string
- func (bA *BitArray) UnmarshalJSON(bz []byte) error
- type Candidate
- type Candidates
- type Coin
- type FrozenFund
- type FrozenFunds
- type ImmutableTree
- func (t *ImmutableTree) DeleteVersion(version int64) error
- func (t *ImmutableTree) Get(key []byte) (index int64, value []byte)
- func (t *ImmutableTree) GetImmutable() *ImmutableTree
- func (t *ImmutableTree) Hash() []byte
- func (t *ImmutableTree) Load() (int64, error)
- func (t *ImmutableTree) LoadVersion(targetVersion int64) (int64, error)
- func (t *ImmutableTree) Remove(key []byte) ([]byte, bool)
- func (t *ImmutableTree) SaveVersion() ([]byte, int64, error)
- func (t *ImmutableTree) Set(key, value []byte) bool
- func (t *ImmutableTree) Version() int64
- type Multisig
- type MutableTree
- func (t *MutableTree) DeleteVersion(version int64) error
- func (t *MutableTree) Get(key []byte) (index int64, value []byte)
- func (t *MutableTree) GetImmutable() *ImmutableTree
- func (t *MutableTree) Hash() []byte
- func (t *MutableTree) Load() (int64, error)
- func (t *MutableTree) LoadVersion(targetVersion int64) (int64, error)
- func (t *MutableTree) Remove(key []byte) ([]byte, bool)
- func (t *MutableTree) SaveVersion() ([]byte, int64, error)
- func (t *MutableTree) Set(key, value []byte) bool
- func (t *MutableTree) Version() int64
- type Stake
- type StakeCache
- type StateDB
- func (s *StateDB) AccountExists(address types.Address) bool
- func (s *StateDB) AddAccumReward(pubkey types.Pubkey, reward *big.Int)
- func (s *StateDB) AddBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)
- func (s *StateDB) AddCoinReserve(symbol types.CoinSymbol, value *big.Int)
- func (s *StateDB) AddCoinVolume(symbol types.CoinSymbol, value *big.Int)
- func (s *StateDB) CandidateExists(key types.Pubkey) bool
- func (s *StateDB) CandidatesCount() int
- func (s *StateDB) Clear()
- func (s *StateDB) ClearCandidates(height int64)
- func (s *StateDB) ClearStakes(height int64)
- func (s *StateDB) CoinExists(symbol types.CoinSymbol) bool
- func (s *StateDB) Commit(deleteEmptyObjects bool) (root []byte, version int64, err error)
- func (s *StateDB) CreateCandidate(address types.Address, pubkey types.Pubkey, commission uint, currentBlock uint, ...) *stateCandidates
- func (s *StateDB) CreateCoin(symbol types.CoinSymbol, name string, volume *big.Int, crr uint, ...) *stateCoin
- func (s *StateDB) CreateMultisig(weights []uint, addresses []types.Address, threshold uint) types.Address
- func (s *StateDB) CreateValidator(address types.Address, pubkey types.Pubkey, commission uint, currentBlock uint, ...) *stateValidators
- func (s *StateDB) Delegate(sender types.Address, pubkey []byte, coin types.CoinSymbol, value *big.Int)
- func (s *StateDB) GetBalance(addr types.Address, coinSymbol types.CoinSymbol) *big.Int
- func (s *StateDB) GetBalances(addr types.Address) Balances
- func (s *StateDB) GetCandidates(count int, block int64) []Candidate
- func (s *StateDB) GetNonce(addr types.Address) uint64
- func (s *StateDB) GetOrNewStateFrozenFunds(blockHeight uint64) *stateFrozenFund
- func (s *StateDB) GetOrNewStateObject(addr types.Address) *stateAccount
- func (s *StateDB) GetStateCandidate(key types.Pubkey) *Candidate
- func (s *StateDB) GetStateCandidates() (stateCandidates *stateCandidates)
- func (s *StateDB) GetStateCoin(symbol types.CoinSymbol) *stateCoin
- func (s *StateDB) GetStateFrozenFunds(blockHeight uint64) *stateFrozenFund
- func (s *StateDB) GetStateValidators() (stateValidators *stateValidators)
- func (s *StateDB) IsCheckUsed(check *check.Check) bool
- func (s *StateDB) IsDelegatorStakeSufficient(sender types.Address, PubKey []byte, coinSymbol types.CoinSymbol, ...) bool
- func (s *StateDB) IsNewCandidateStakeSufficient(coinSymbol types.CoinSymbol, stake *big.Int) bool
- func (s *StateDB) MarkStateCandidateDirty()
- func (s *StateDB) MarkStateCoinDirty(symbol types.CoinSymbol)
- func (s *StateDB) MarkStateFrozenFundsDirty(blockHeight uint64)
- func (s *StateDB) MarkStateObjectDirty(addr types.Address)
- func (s *StateDB) MarkStateValidatorsDirty()
- func (s *StateDB) MultisigAccountExists(address types.Address) bool
- func (s *StateDB) PayRewards(height int64)
- func (s *StateDB) PunishByzantineValidator(currentBlock int64, address [20]byte)
- func (s *StateDB) PunishFrozenFundsWithAddress(fromBlock uint64, toBlock uint64, address [20]byte)
- func (s *StateDB) RecalculateTotalStakeValues()
- func (s *StateDB) RemoveCurrentValidator(pubkey types.Pubkey)
- func (s *StateDB) SetBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)
- func (s *StateDB) SetCandidateOffline(pubkey []byte)
- func (s *StateDB) SetCandidateOnline(pubkey []byte)
- func (s *StateDB) SetNewValidators(candidates []Candidate)
- func (s *StateDB) SetNonce(addr types.Address, nonce uint64)
- func (s *StateDB) SetStateValidators(validators *stateValidators)
- func (s *StateDB) SetValidatorAbsent(height int64, address [20]byte)
- func (s *StateDB) SetValidatorPresent(height int64, address [20]byte)
- func (s *StateDB) StakeExists(owner types.Address, PubKey []byte, coinSymbol types.CoinSymbol) bool
- func (s *StateDB) SubBalance(addr types.Address, coinSymbol types.CoinSymbol, amount *big.Int)
- func (s *StateDB) SubCoinReserve(symbol types.CoinSymbol, value *big.Int)
- func (s *StateDB) SubCoinVolume(symbol types.CoinSymbol, value *big.Int)
- func (s *StateDB) SubStake(sender types.Address, pubkey []byte, coin types.CoinSymbol, value *big.Int)
- func (s *StateDB) UseCheck(check *check.Check)
- type Tree
- type Validator
- type Validators
Constants ¶
const ( CandidateStatusOffline = 0x01 CandidateStatusOnline = 0x02 )
const MaxDelegatorsPerCandidate = 1000
const UnbondPeriod = 720 // in mainnet will be 518400 (30 days)
Variables ¶
var ( ValidatorMaxAbsentWindow = 24 ValidatorMaxAbsentTimes = 12 )
var (
BalanceChangeChan = make(chan BalanceChangeStruct, 10)
)
Functions ¶
func EmitBalanceChange ¶
Types ¶
type Account ¶
Account is the Minter consensus representation of accounts. These objects are stored in the main account trie.
type BalanceChangeStruct ¶
type BalanceChangeStruct struct { Address types.Address Coin types.CoinSymbol Balance *big.Int BalanceInBasecoin *big.Int }
func (BalanceChangeStruct) MarshalJSON ¶
func (s BalanceChangeStruct) MarshalJSON() ([]byte, error)
type BitArray ¶ added in v0.4.0
type BitArray struct { Bits uint `json:"bits"` // NOTE: persisted via reflect, must be exported Elems []uint64 `json:"elems"` // NOTE: persisted via reflect, must be exported // contains filtered or unexported fields }
BitArray is a thread-safe implementation of a bit array.
func NewBitArray ¶ added in v0.4.0
NewBitArray returns a new bit array. It returns nil if the number of bits is zero.
func (*BitArray) Bytes ¶ added in v0.4.0
Bytes returns the byte representation of the bits within the bitarray.
func (*BitArray) GetIndex ¶ added in v0.4.0
GetIndex returns the bit at index i within the bit array. The behavior is undefined if i >= bA.Bits
func (*BitArray) MarshalJSON ¶ added in v0.4.0
MarshalJSON implements json.Marshaler interface by marshaling bit array using a custom format: a string of '-' or 'x' where 'x' denotes the 1 bit.
func (*BitArray) SetIndex ¶ added in v0.4.0
SetIndex sets the bit at index i within the bit array. The behavior is undefined if i >= bA.Bits
func (*BitArray) String ¶ added in v0.4.0
String returns a string representation of BitArray: BA{<bit-string>}, where <bit-string> is a sequence of 'x' (1) and '_' (0). The <bit-string> includes spaces and newlines to help people. For a simple sequence of 'x' and '_' characters with no spaces or newlines, see the MarshalJSON() method. Example: "BA{_x_}" or "nil-BitArray" for nil.
func (*BitArray) StringIndented ¶ added in v0.4.0
StringIndented returns the same thing as String(), but applies the indent at every 10th bit, and twice at every 50th bit.
func (*BitArray) UnmarshalJSON ¶ added in v0.4.0
UnmarshalJSON implements json.Unmarshaler interface by unmarshaling a custom JSON description.
type Candidate ¶
type Candidate struct { CandidateAddress 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) GetStakeOfAddress ¶
type Candidates ¶
type Candidates []Candidate
type Coin ¶
type FrozenFund ¶
type FrozenFunds ¶
type FrozenFunds struct { BlockHeight uint64 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 (*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) Hash ¶ added in v0.4.1
func (t *ImmutableTree) Hash() []byte
func (*ImmutableTree) Load ¶ added in v0.4.1
func (t *ImmutableTree) Load() (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 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) Hash ¶ added in v0.4.1
func (t *MutableTree) Hash() []byte
func (*MutableTree) Load ¶ added in v0.4.1
func (t *MutableTree) Load() (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 StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func NewForCheck ¶ added in v0.4.1
func (*StateDB) AccountExists ¶ added in v0.5.0
func (*StateDB) AddAccumReward ¶
func (*StateDB) AddBalance ¶
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) CandidatesCount ¶ added in v0.5.0
func (*StateDB) ClearCandidates ¶ added in v0.5.0
func (*StateDB) ClearStakes ¶ added in v0.5.0
func (*StateDB) CoinExists ¶
func (s *StateDB) CoinExists(symbol types.CoinSymbol) bool
func (*StateDB) CreateCandidate ¶
func (*StateDB) CreateCoin ¶
func (*StateDB) CreateMultisig ¶ added in v0.5.0
func (*StateDB) CreateValidator ¶ added in v0.2.0
func (*StateDB) GetBalance ¶
Retrieve the balance from the given address or 0 if object not found
func (*StateDB) GetCandidates ¶ added in v0.2.0
func (*StateDB) GetOrNewStateFrozenFunds ¶
func (*StateDB) GetOrNewStateObject ¶
Retrieve a state object or create a new state object if nil
func (*StateDB) GetStateCandidate ¶
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 (*StateDB) GetStateValidators ¶ added in v0.2.0
func (s *StateDB) GetStateValidators() (stateValidators *stateValidators)
func (*StateDB) IsDelegatorStakeSufficient ¶ added in v0.5.0
func (*StateDB) IsNewCandidateStakeSufficient ¶ added in v0.5.0
func (*StateDB) MarkStateCandidateDirty ¶
func (s *StateDB) MarkStateCandidateDirty()
func (*StateDB) MarkStateCoinDirty ¶
func (s *StateDB) MarkStateCoinDirty(symbol types.CoinSymbol)
func (*StateDB) MarkStateFrozenFundsDirty ¶
func (*StateDB) MarkStateObjectDirty ¶
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 (*StateDB) PayRewards ¶
func (*StateDB) PunishByzantineValidator ¶ added in v0.2.0
func (*StateDB) PunishFrozenFundsWithAddress ¶ added in v0.3.0
func (*StateDB) RecalculateTotalStakeValues ¶
func (s *StateDB) RecalculateTotalStakeValues()
func (*StateDB) RemoveCurrentValidator ¶ added in v0.3.0
func (*StateDB) SetBalance ¶
func (*StateDB) SetCandidateOffline ¶
func (*StateDB) SetCandidateOnline ¶
func (*StateDB) SetNewValidators ¶ added in v0.2.0
func (*StateDB) SetStateValidators ¶ added in v0.3.0
func (s *StateDB) SetStateValidators(validators *stateValidators)
func (*StateDB) SetValidatorAbsent ¶
func (*StateDB) SetValidatorPresent ¶
func (*StateDB) StakeExists ¶ added in v0.5.0
func (*StateDB) SubBalance ¶
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)
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) Load() (int64, error) SaveVersion() ([]byte, int64, error) DeleteVersion(version int64) error GetImmutable() *ImmutableTree Version() int64 Hash() []byte }
type Validator ¶ added in v0.2.0
type Validator struct { CandidateAddress types.Address TotalBipStake *big.Int PubKey types.Pubkey Commission uint AccumReward *big.Int AbsentTimes *BitArray // contains filtered or unexported fields }
func (*Validator) CountAbsentTimes ¶ added in v0.4.0
func (Validator) GetAddress ¶ added in v0.2.0
type Validators ¶ added in v0.2.0
type Validators []Validator