Documentation ¶
Overview ¶
Package state provides a caching layer atop the Ethereum state trie.
Index ¶
- Variables
- func NewStateSync(root common.Hash, database trie.DatabaseReader) *trie.Sync
- func NewSync(root common.Hash, database trie.DatabaseReader) *trie.Sync
- func PubToAddress(pubkey []byte) common.Address
- type Account
- type AliasValidator
- type Code
- type Database
- type DelegationFrom
- type DelegationFroms
- type DelegationTo
- type DelegationTos
- type Dump
- type DumpAccount
- type DumpAllLogs
- type DumpDelegationFrom
- type DumpLog
- type DumpValidator
- type DumpValidatorsStat
- type DumpValidatorsStatItem
- type DumpWithdrawRecord
- type Extension
- type NodeIterator
- type Record
- type StateDB
- func (st *StateDB) AddBalance(addr common.Address, amount *big.Int)
- func (st *StateDB) AddLog(log *types.Log)
- func (st *StateDB) AddPendingRelationship(d, v common.Address)
- func (st *StateDB) AddPreimage(hash common.Hash, preimage []byte)
- func (st *StateDB) AddRefund(gas uint64)
- func (st *StateDB) AddStakingRecord(d, v common.Address, txHash common.Hash, newFinalValue *big.Int)
- func (st *StateDB) AddWithdrawRecord(record *WithdrawRecord) bool
- func (st *StateDB) BlockHash() common.Hash
- func (st *StateDB) Commit(deleteEmptyObjects bool) (root, valRoot, stakingRoot common.Hash, err error)
- func (st *StateDB) Copy() *StateDB
- func (st *StateDB) CreateAccount(addr common.Address)
- func (st *StateDB) CreateValidator(name string, operator, coinbase common.Address, role params.ValidatorRole, ...) (newVal *Validator)
- func (st *StateDB) Database() Database
- func (st *StateDB) DelegatorPendingCount(d common.Address) int
- func (st *StateDB) Dump() []byte
- func (st *StateDB) Empty(addr common.Address) bool
- func (st *StateDB) Error() error
- func (st *StateDB) Exist(addr common.Address) bool
- func (st *StateDB) Finalise(deleteEmptyObjects bool)
- func (st *StateDB) ForEachStakingRecord(cb func(d, v common.Address, record *Record) error) error
- func (st *StateDB) ForEachStorage(addr common.Address, cb func(key, value common.Hash) bool)
- func (st *StateDB) GetBalance(addr common.Address) *big.Int
- func (st *StateDB) GetCode(addr common.Address) []byte
- func (st *StateDB) GetCodeHash(addr common.Address) common.Hash
- func (st *StateDB) GetCodeSize(addr common.Address) int
- func (st *StateDB) GetCommittedState(addr common.Address, hash common.Hash) common.Hash
- func (st *StateDB) GetCountOfDelegateTo(d common.Address) int
- func (st *StateDB) GetDelegationsFrom(d common.Address) ([]*DelegationTo, error)
- func (st *StateDB) GetLogs(hash common.Hash) []*types.Log
- func (st *StateDB) GetNonce(addr common.Address) uint64
- func (st *StateDB) GetOrNewStateObject(addr common.Address) *stateObject
- func (st *StateDB) GetProof(a common.Address) ([][]byte, error)
- func (st *StateDB) GetRefund() uint64
- func (st *StateDB) GetStakingRecord(d, v common.Address) *Record
- func (st *StateDB) GetStakingRecordValue(d, v common.Address) *big.Int
- func (st *StateDB) GetState(addr common.Address, bhash common.Hash) common.Hash
- func (st *StateDB) GetStorageProof(a common.Address, key common.Hash) ([][]byte, error)
- func (st *StateDB) GetValidatorByMainAddr(mainAddress common.Address) *Validator
- func (st *StateDB) GetValidators() *Validators
- func (st *StateDB) GetValidatorsStat() (*ValidatorsStat, error)
- func (st *StateDB) GetWithdrawQueue() *WithdrawQueue
- func (st *StateDB) HasSuicided(addr common.Address) bool
- func (st *StateDB) IntermediateRoot(deleteEmptyObjects bool) (common.Hash, common.Hash, common.Hash)
- func (st *StateDB) LogDump() (DumpAllLogs, error)
- func (st *StateDB) Logs() []*types.Log
- func (st *StateDB) PendingRelationshipExist(d, v common.Address) bool
- func (st *StateDB) PendingValidatorExist(v common.Address) bool
- func (st *StateDB) Preimages() map[common.Hash][]byte
- func (st *StateDB) Prepare(thash, bhash common.Hash, ti int)
- func (st *StateDB) RawDump() Dump
- func (st *StateDB) RemoveValidator(mainAddress common.Address) bool
- func (st *StateDB) RemoveWithdrawRecords(index []int) bool
- func (st *StateDB) Reset(root, valRoot common.Hash) error
- func (st *StateDB) ResetStakingTrie()
- func (st *StateDB) RevertToSnapshot(revid int)
- func (st *StateDB) SetBalance(addr common.Address, amount *big.Int)
- func (st *StateDB) SetCode(addr common.Address, code []byte)
- func (st *StateDB) SetNonce(addr common.Address, nonce uint64)
- func (st *StateDB) SetState(addr common.Address, key, value common.Hash)
- func (st *StateDB) Snapshot() int
- func (st *StateDB) StorageTrie(addr common.Address) Trie
- func (st *StateDB) SubBalance(addr common.Address, amount *big.Int)
- func (st *StateDB) SubRefund(gas uint64)
- func (st *StateDB) Suicide(addr common.Address) bool
- func (st *StateDB) TxIndex() int
- func (st *StateDB) UpdateDelegation(d common.Address, val *Validator, tokenChanged *big.Int) (*Validator, *DelegationFrom, *big.Int, params.CurdFlag)
- func (st *StateDB) UpdateDelegator(addr, toValidator common.Address, delta *big.Int, delete bool)
- func (st *StateDB) UpdateValidator(newVal, oldVal *Validator) bool
- func (st *StateDB) ValidatorPendingCount(v common.Address) int
- func (st *StateDB) ValidatorsModified() bool
- type Storage
- type Trie
- type ValKindStat
- func (v *ValKindStat) AddRewards(amount *big.Int) *ValKindStat
- func (v *ValKindStat) AddVal(val *Validator)
- func (v *ValKindStat) DecodeRLP(s *rlp.Stream) error
- func (v ValKindStat) DeepCopy() *ValKindStat
- func (v ValKindStat) Dump() DumpValidatorsStatItem
- func (v ValKindStat) EncodeRLP(w io.Writer) error
- func (v ValKindStat) GetCount() uint64
- func (v ValKindStat) GetOfflineCount() uint64
- func (v ValKindStat) GetOfflineStake() *big.Int
- func (v ValKindStat) GetOfflineToken() *big.Int
- func (v ValKindStat) GetOnlineStake() *big.Int
- func (v ValKindStat) GetOnlineToken() *big.Int
- func (v ValKindStat) GetRewardsDistributable() *big.Int
- func (v ValKindStat) GetRewardsResidue() *big.Int
- func (v *ValKindStat) ResetRewards(total *big.Int) *ValKindStat
- func (v *ValKindStat) SetRewardsResidue(amount *big.Int) *ValKindStat
- func (v *ValKindStat) SubVal(val *Validator)
- type Validator
- func (v *Validator) AddTotalRewards(reward *big.Int)
- func (v *Validator) DecodeRLP(s *rlp.Stream) error
- func (v *Validator) DeepCopy() *Validator
- func (v Validator) Dump() DumpValidator
- func (v Validator) EncodeRLP(w io.Writer) error
- func (v Validator) Equal(val *Validator) bool
- func (v *Validator) GetDelegationFrom(d common.Address) *DelegationFrom
- func (v *Validator) IsInvalid() bool
- func (v *Validator) IsOffline() bool
- func (v *Validator) IsOnline() bool
- func (v *Validator) IsOperator(addr common.Address) bool
- func (v Validator) Kind() params.ValidatorKind
- func (v *Validator) Less(val *Validator) bool
- func (v *Validator) MainAddress() common.Address
- func (v Validator) MarshalJSON() ([]byte, error)
- func (v *Validator) PartialCopy() *Validator
- func (v Validator) StakeEqual(val *Validator) bool
- func (v *Validator) UpdateDelegationFrom(d *DelegationFrom) (flag params.CurdFlag)
- type ValidatorIndex
- func (index *ValidatorIndex) Add(mainAddress common.Address)
- func (index *ValidatorIndex) DecodeRLP(s *rlp.Stream) error
- func (index *ValidatorIndex) DeepCopy() *ValidatorIndex
- func (index *ValidatorIndex) Delete(mainAddress common.Address)
- func (index *ValidatorIndex) Empty() bool
- func (index *ValidatorIndex) EncodeRLP(w io.Writer) error
- func (index *ValidatorIndex) List() []common.Address
- type ValidatorReader
- type Validators
- func (s *Validators) DecodeRLP(stream *rlp.Stream) error
- func (s Validators) EncodeRLP(w io.Writer) error
- func (s Validators) GetByIndex(index int) (*Validator, bool)
- func (s Validators) GetIndex(mainAddress common.Address) (int, bool)
- func (s Validators) GetRlp(i int) []byte
- func (s Validators) Len() int
- func (s *Validators) Less(i, j int) bool
- func (s Validators) List() []*Validator
- func (s *Validators) Remove(mainAddress common.Address) bool
- func (s *Validators) Swap(i, j int)
- type ValidatorsStat
- func (m *ValidatorsStat) DecodeRLP(s *rlp.Stream) error
- func (m *ValidatorsStat) DeepCopy() *ValidatorsStat
- func (m ValidatorsStat) Dump() *DumpValidatorsStat
- func (m *ValidatorsStat) EncodeRLP(w io.Writer) error
- func (m *ValidatorsStat) GetByKind(kind params.ValidatorKind) *ValKindStat
- func (m *ValidatorsStat) GetByRole(role params.ValidatorRole) *ValKindStat
- func (m *ValidatorsStat) GetCountOfKind(kind params.ValidatorKind) uint64
- func (m *ValidatorsStat) GetRewardResidue() *big.Int
- func (m *ValidatorsStat) GetStakeByKind(kind params.ValidatorKind) *big.Int
- func (m *ValidatorsStat) String() string
- type WithdrawQueue
- func (q *WithdrawQueue) Add(record *WithdrawRecord)
- func (q WithdrawQueue) DeepCopy() *WithdrawQueue
- func (q *WithdrawQueue) Delete(record *WithdrawRecord)
- func (q WithdrawQueue) Len() int
- func (q WithdrawQueue) Less(i, j int) bool
- func (q *WithdrawQueue) RemoveRecords(idx []int) []*WithdrawRecord
- func (q *WithdrawQueue) Swap(i, j int)
- type WithdrawRecord
Constants ¶
This section is empty.
Variables ¶
var MaxTrieCacheGen = uint16(120)
Trie cache generation limit after which to evict trie nodes from memory.
Functions ¶
func NewStateSync ¶
NewStateSync create a new state trie download scheduler.
func PubToAddress ¶
Types ¶
type Account ¶
type Account struct { Nonce uint64 Balance *big.Int Root common.Hash // merkle root of the storage trie CodeHash []byte DelegationBalance *big.Int DelegationsHash []byte }
Account is the Ethereum consensus representation of accounts. These objects are stored in the main account trie.
type AliasValidator ¶
type AliasValidator Validator // alias to Validator, for the purpose of marshalling or encoding.
type Database ¶
type Database interface { // OpenTrie opens the main account trie. OpenTrie(root common.Hash) (Trie, error) // OpenStorageTrie opens the storage trie of an account. OpenStorageTrie(addrHash, root common.Hash) (Trie, error) // CopyTrie returns an independent copy of the given trie. CopyTrie(Trie) Trie // ContractCode retrieves a particular contract's code. ContractCode(addrHash, codeHash common.Hash) ([]byte, error) // ContractCodeSize retrieves a particular contracts code's size. ContractCodeSize(addrHash, codeHash common.Hash) (int, error) // DelegationBytes retrieves a particular DelegationBytes(dlgHash common.Hash) ([]byte, error) // TrieDB retrieves the low level trie database used for data storage. TrieDB() *trie.Database }
Database wraps access to tries and contract code.
func NewDatabase ¶
NewDatabase creates a backing store for state. The returned database is safe for concurrent use and retains cached trie nodes in memory. The pool is an optional intermediate trie-node memory pool between the low level storage layer and the high level trie abstraction.
type DelegationFrom ¶
type DelegationFrom struct { Delegator common.Address `json:"delegator"` Stake *big.Int `json:"stake"` Token *big.Int `json:"token"` }
func (*DelegationFrom) DeepCopy ¶
func (d *DelegationFrom) DeepCopy() *DelegationFrom
func (*DelegationFrom) Empty ¶
func (d *DelegationFrom) Empty() bool
type DelegationFroms ¶
type DelegationFroms []*DelegationFrom
func (DelegationFroms) Len ¶
func (d DelegationFroms) Len() int
func (DelegationFroms) Less ¶
func (d DelegationFroms) Less(i, j int) bool
func (DelegationFroms) Swap ¶
func (d DelegationFroms) Swap(i, j int)
type DelegationTo ¶
type DelegationTos ¶
type DelegationTos []*DelegationTo
type Dump ¶
type Dump struct { Root string `json:"root"` ValRoot string `json:"valRoot"` StakingRoot string `json:"stakingRoot"` Accounts map[string]DumpAccount `json:"accounts"` Validators map[string]DumpValidator `json:"validators"` ValidatorsStat *DumpValidatorsStat `json:"validatorsStat"` ValidatorsWithdraw []*DumpWithdrawRecord `json:"validatorsWithdraw"` }
type DumpAccount ¶
type DumpAllLogs ¶
type DumpDelegationFrom ¶
type DumpLog ¶
type DumpLog struct { Address common.Address `json:"address"` Topics []common.Hash `json:"topics"` Data hexutil.Bytes `json:"data"` BlockNumber hexutil.Uint64 `json:"blockNumber"` TxHash common.Hash `json:"transactionHash"` TxIndex hexutil.Uint `json:"transactionIndex"` BlockHash common.Hash `json:"blockHash"` Index hexutil.Uint `json:"logIndex"` Removed bool `json:"removed"` }
type DumpValidator ¶
type DumpValidator struct { MainAddress common.Address `json:"mainAddress"` Name string `json:"name"` OperatorAddress common.Address `json:"operatorAddress"` Coinbase common.Address `json:"coinbase"` MainPubKey hexutil.Bytes `json:"mainPubKey"` BlsPubKey hexutil.Bytes `json:"blsPubKey"` Token string `json:"token"` Stake string `json:"stake"` Status uint8 `json:"status"` Role uint8 `json:"role"` Expelled bool `json:"expelled"` ExpelExpired uint64 `json:"expelExpired"` LastInactive uint64 `json:"lastInactive"` SelfToken string `json:"selfToken"` // self staking tokens, LU SelfStake string `json:"selfStake"` RewardsDistributable string `json:"rewardsDistributable"` RewardsTotal string `json:"rewardsTotal"` RewardsLastSettled uint64 `json:"rewardsLastSettled"` // 最后一次分配的区块的高度 AcceptDelegation uint16 `json:"acceptDelegation"` CommissionRate uint16 `json:"commissionRate"` // 抽佣率,万分数 RiskObligation uint16 `json:"riskObligation"` // 风险承担率,万分数 Delegations []*DumpDelegationFrom `json:"delegations"` // 名下委托集合,必须是排好序的 // for later extend Ext Extension `json:"ext"` }
type DumpValidatorsStat ¶
type DumpValidatorsStat struct { Kinds map[params.ValidatorKind]DumpValidatorsStatItem `json:"kinds"` Roles map[params.ValidatorRole]DumpValidatorsStatItem `json:"roles"` }
type DumpValidatorsStatItem ¶
type DumpValidatorsStatItem struct { OnlineStake string `json:"onlineStake"` OnlineToken string `json:"onlineToken"` OnlineCount uint64 `json:"onlineCount"` OfflineStake string `json:"offlineStake"` OfflineToken string `json:"offlineToken"` OfflineCount uint64 `json:"offlineCount"` RewardsResidue string `json:"rewardsResidue"` RewardsDistributable string `json:"rewardsDistributable"` }
type DumpWithdrawRecord ¶
type DumpWithdrawRecord struct { Operator common.Address `json:"operator"` Delegator common.Address `json:"delegator"` Validator common.Address `json:"validator"` Recipient common.Address `json:"recipient"` Nonce uint64 `json:"nonce"` CreationHeight uint64 `json:"creationHeight"` // height which the withdrawing took place CompletionHeight uint64 `json:"completionHeight"` // height which the withdrawing will complete InitialBalance string `json:"initialBalance"` // tokens initially scheduled to receive at completion FinalBalance string `json:"finalBalance"` // tokens to receive at completion 最后实际收到的token数量 Finished uint8 `json:"finished"` TxHash common.Hash `json:"txHash"` }
type NodeIterator ¶
type NodeIterator struct { Hash common.Hash // Hash of the current entry being iterated (nil if not standalone) Parent common.Hash // Hash of the first full ancestor node (nil if current is the root) Error error // Failure set in case of an internal error in the iterator // contains filtered or unexported fields }
NodeIterator is an iterator to traverse the entire state trie post-order, including all of the contract code and contract state tries.
func NewNodeIterator ¶
func NewNodeIterator(state *StateDB) *NodeIterator
NewNodeIterator creates an post-order state node iterator.
func (*NodeIterator) Next ¶
func (it *NodeIterator) Next() bool
Next moves the iterator to the next node, returning whether there are any further nodes. In case of an internal error this method returns false and sets the Error field to the encountered failure.
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
StateDBs within the ethereum protocol are used to store anything within the merkle trie. StateDBs take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts the valTrie is used to store validators and global stat. the global stat data will be stored with a special key.
func (*StateDB) AddBalance ¶
AddBalance adds amount to the account associated with addr.
func (*StateDB) AddPendingRelationship ¶
AddPendingRelationship adds a relationship to current staking trie Note: It's the caller's responsibility to make sure that the relationship is unique globally.
func (*StateDB) AddPreimage ¶
AddPreimage records a SHA3 preimage seen by the VM.
func (*StateDB) AddStakingRecord ¶
func (*StateDB) AddWithdrawRecord ¶
func (st *StateDB) AddWithdrawRecord(record *WithdrawRecord) bool
func (*StateDB) Commit ¶
func (st *StateDB) Commit(deleteEmptyObjects bool) (root, valRoot, stakingRoot common.Hash, err error)
Commit writes the state to the underlying in-memory trie database.
func (*StateDB) Copy ¶
Copy creates a deep, independent copy of the state. Snapshots of the copied state cannot be applied to the copy.
func (*StateDB) CreateAccount ¶
CreateAccount explicitly creates a state object. If a state object with the address already exists the balance is carried over to the new account.
CreateAccount is called during the EVM CREATE operation. The situation might arise that a contract does the following:
- sends funds to sha(account ++ (nonce + 1))
- tx_create(sha(account ++ nonce)) (note that this gets the address of 1)
Carrying over the balance ensures that Ether doesn't disappear.
func (*StateDB) CreateValidator ¶
func (*StateDB) Database ¶
Database retrieves the low level database supporting the lower level trie ops.
func (*StateDB) DelegatorPendingCount ¶
func (*StateDB) Empty ¶
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*StateDB) Exist ¶
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*StateDB) Finalise ¶
Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*StateDB) ForEachStakingRecord ¶
func (*StateDB) ForEachStorage ¶
func (*StateDB) GetBalance ¶
Retrieve the balance from the given address or 0 if object not found
func (*StateDB) GetCommittedState ¶
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*StateDB) GetCountOfDelegateTo ¶
GetCountOfDelegateTo gets a delegator address, returns how many validators it has delegation to.
func (*StateDB) GetDelegationsFrom ¶
func (st *StateDB) GetDelegationsFrom(d common.Address) ([]*DelegationTo, error)
func (*StateDB) GetOrNewStateObject ¶
Retrieve a state object or create a new state object if nil.
func (*StateDB) GetStakingRecord ¶ added in v0.9.9
func (*StateDB) GetStakingRecordValue ¶
func (*StateDB) GetStorageProof ¶
GetProof returns the StorageProof for given key
func (*StateDB) GetValidatorByMainAddr ¶
func (*StateDB) GetValidators ¶
func (st *StateDB) GetValidators() *Validators
GetValidators 获取全部 validator 集合
func (*StateDB) GetValidatorsStat ¶
func (st *StateDB) GetValidatorsStat() (*ValidatorsStat, error)
func (*StateDB) GetWithdrawQueue ¶
func (st *StateDB) GetWithdrawQueue() *WithdrawQueue
func (*StateDB) IntermediateRoot ¶
func (st *StateDB) IntermediateRoot(deleteEmptyObjects bool) (common.Hash, common.Hash, common.Hash)
IntermediateRoot computes the current root hash of the state trie. It is called in between transactions to get the root hash that goes into transaction receipts.
func (*StateDB) LogDump ¶
func (st *StateDB) LogDump() (DumpAllLogs, error)
func (*StateDB) PendingRelationshipExist ¶
func (*StateDB) PendingValidatorExist ¶
func (*StateDB) Prepare ¶
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
func (*StateDB) RemoveValidator ¶
func (*StateDB) RemoveWithdrawRecords ¶
func (*StateDB) Reset ¶
Reset clears out all ephemeral state objects from the state db, but keeps the underlying state trie to avoid reloading data for the next operations.
func (*StateDB) ResetStakingTrie ¶
func (st *StateDB) ResetStakingTrie()
ResetStakingTrie will force the staking trie to start a new trie
func (*StateDB) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*StateDB) StorageTrie ¶
StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.
func (*StateDB) SubBalance ¶
SubBalance subtracts amount from the account associated with addr.
func (*StateDB) SubRefund ¶
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
func (*StateDB) Suicide ¶
Suicide marks the given account as suicided. This clears the account balance.
The account's state object is still available until the state is committed, getStateObject will return a non-nil account after Suicide.
func (*StateDB) UpdateDelegation ¶
func (st *StateDB) UpdateDelegation(d common.Address, val *Validator, tokenChanged *big.Int) (*Validator, *DelegationFrom, *big.Int, params.CurdFlag)
UpdateDelegation will update both delegator and validator without any business check. returns newValidator,newDelegationFrom, stakeChanged, delegatorUpdateStatus
func (*StateDB) UpdateDelegator ¶
UpdateDelegator updates delegations index for an account, `delta` is the delegation amount current added (when delta is positive) or subtracted (when delta is negative).
func (*StateDB) UpdateValidator ¶
func (*StateDB) ValidatorPendingCount ¶
func (*StateDB) ValidatorsModified ¶
type Trie ¶
type Trie interface { TryGet(key []byte) ([]byte, error) TryUpdate(key, value []byte) error TryDelete(key []byte) error Commit(onleaf trie.LeafCallback) (common.Hash, error) Hash() common.Hash NodeIterator(startKey []byte) trie.NodeIterator GetKey([]byte) []byte // TODO(fjl): remove this when SecureTrie is removed Prove(key []byte, fromLevel uint, proofDb youdb.Putter) error }
Trie is a Ethereum Merkle Trie.
type ValKindStat ¶
type ValKindStat struct {
// contains filtered or unexported fields
}
func NewValKindStat ¶
func NewValKindStat() *ValKindStat
func (*ValKindStat) AddRewards ¶
func (v *ValKindStat) AddRewards(amount *big.Int) *ValKindStat
func (*ValKindStat) AddVal ¶
func (v *ValKindStat) AddVal(val *Validator)
func (ValKindStat) DeepCopy ¶
func (v ValKindStat) DeepCopy() *ValKindStat
func (ValKindStat) Dump ¶
func (v ValKindStat) Dump() DumpValidatorsStatItem
func (ValKindStat) GetCount ¶
func (v ValKindStat) GetCount() uint64
func (ValKindStat) GetOfflineCount ¶
func (v ValKindStat) GetOfflineCount() uint64
func (ValKindStat) GetOfflineStake ¶
func (v ValKindStat) GetOfflineStake() *big.Int
func (ValKindStat) GetOfflineToken ¶
func (v ValKindStat) GetOfflineToken() *big.Int
func (ValKindStat) GetOnlineStake ¶
func (v ValKindStat) GetOnlineStake() *big.Int
func (ValKindStat) GetOnlineToken ¶
func (v ValKindStat) GetOnlineToken() *big.Int
func (ValKindStat) GetRewardsDistributable ¶
func (v ValKindStat) GetRewardsDistributable() *big.Int
func (ValKindStat) GetRewardsResidue ¶
func (v ValKindStat) GetRewardsResidue() *big.Int
func (*ValKindStat) ResetRewards ¶
func (v *ValKindStat) ResetRewards(total *big.Int) *ValKindStat
func (*ValKindStat) SetRewardsResidue ¶
func (v *ValKindStat) SetRewardsResidue(amount *big.Int) *ValKindStat
func (*ValKindStat) SubVal ¶
func (v *ValKindStat) SubVal(val *Validator)
type Validator ¶
type Validator struct { Name string `json:"name"` // alias name for validator OperatorAddress common.Address `json:"operatorAddress"` // manager address Coinbase common.Address `json:"coinbase"` // send rewards Role params.ValidatorRole `json:"role"` // role of validator Status uint8 `json:"status"` Expelled bool `json:"expelled" rlp:"-"` // rlp did not support bool type ExpelExpired uint64 `json:"expelExpired"` LastInactive uint64 `json:"lastInactive"` MainPubKey hexutil.Bytes `json:"mainPubKey"` // consensus pubkey BlsPubKey hexutil.Bytes `json:"blsPubKey"` // bls pubkey Token *big.Int `json:"token"` // Lu Stake *big.Int `json:"stake"` // token / StakeUnit SelfToken *big.Int `json:"selfToken"` // self staking tokens, LU SelfStake *big.Int `json:"selfStake"` RewardsDistributable *big.Int `json:"rewardsDistributable"` RewardsTotal *big.Int `json:"rewardsTotal"` RewardsLastSettled uint64 `json:"rewardsLastSettled"` AcceptDelegation uint16 `json:"acceptDelegation"` CommissionRate uint16 `json:"commissionRate"` // 抽佣率,万分数 RiskObligation uint16 `json:"riskObligation"` // 风险承担率,万分数 Delegations DelegationFroms `json:"delegations"` // 名下委托集合,必须是排好序的 // for later extend Ext Extension `json:"ext"` // contains filtered or unexported fields }
func NewValidator ¶
func NewValidator(name string, operatorAddress, coinbase common.Address, role params.ValidatorRole, mainPubKey, blsPubKey hexutil.Bytes, token, stake *big.Int, acceptDelegation, commissionRate, riskObligation uint16, status uint8) *Validator
NewValidator creates a validator object.
func (*Validator) AddTotalRewards ¶
func (Validator) Dump ¶
func (v Validator) Dump() DumpValidator
func (*Validator) GetDelegationFrom ¶
func (v *Validator) GetDelegationFrom(d common.Address) *DelegationFrom
func (Validator) Kind ¶
func (v Validator) Kind() params.ValidatorKind
func (*Validator) MainAddress ¶
func (Validator) MarshalJSON ¶
func (*Validator) PartialCopy ¶
PartialCopy is a deep copy except that PartialCopy do not copy the Delegations slice
func (Validator) StakeEqual ¶
func (*Validator) UpdateDelegationFrom ¶
func (v *Validator) UpdateDelegationFrom(d *DelegationFrom) (flag params.CurdFlag)
type ValidatorIndex ¶
type ValidatorIndex struct {
// contains filtered or unexported fields
}
func NewValidatorIndex ¶
func NewValidatorIndex() *ValidatorIndex
func (*ValidatorIndex) Add ¶
func (index *ValidatorIndex) Add(mainAddress common.Address)
func (*ValidatorIndex) DeepCopy ¶
func (index *ValidatorIndex) DeepCopy() *ValidatorIndex
func (*ValidatorIndex) Delete ¶
func (index *ValidatorIndex) Delete(mainAddress common.Address)
func (*ValidatorIndex) Empty ¶
func (index *ValidatorIndex) Empty() bool
func (*ValidatorIndex) List ¶
func (index *ValidatorIndex) List() []common.Address
type ValidatorReader ¶
type ValidatorReader interface { GetValidatorsStat() (*ValidatorsStat, error) GetValidatorByMainAddr(mainAddress common.Address) *Validator GetValidators() *Validators }
func NewVldReader ¶
NewVldReader create a new state that only with the given validator trie.
type Validators ¶
type Validators struct {
// contains filtered or unexported fields
}
func NewValidators ¶
func NewValidators(list []*Validator) *Validators
func (Validators) GetByIndex ¶
func (s Validators) GetByIndex(index int) (*Validator, bool)
func (Validators) GetRlp ¶
func (s Validators) GetRlp(i int) []byte
func (Validators) Len ¶
func (s Validators) Len() int
func (*Validators) Less ¶
func (s *Validators) Less(i, j int) bool
func (Validators) List ¶
func (s Validators) List() []*Validator
func (*Validators) Swap ¶
func (s *Validators) Swap(i, j int)
type ValidatorsStat ¶
type ValidatorsStat struct { Kinds map[params.ValidatorKind]*ValKindStat `json:"kinds"` Roles map[params.ValidatorRole]*ValKindStat `json:"roles"` }
func NewValidatorsStat ¶
func NewValidatorsStat() *ValidatorsStat
func (*ValidatorsStat) DeepCopy ¶
func (m *ValidatorsStat) DeepCopy() *ValidatorsStat
func (ValidatorsStat) Dump ¶
func (m ValidatorsStat) Dump() *DumpValidatorsStat
func (*ValidatorsStat) GetByKind ¶
func (m *ValidatorsStat) GetByKind(kind params.ValidatorKind) *ValKindStat
func (*ValidatorsStat) GetByRole ¶
func (m *ValidatorsStat) GetByRole(role params.ValidatorRole) *ValKindStat
func (*ValidatorsStat) GetCountOfKind ¶
func (m *ValidatorsStat) GetCountOfKind(kind params.ValidatorKind) uint64
func (*ValidatorsStat) GetRewardResidue ¶
func (m *ValidatorsStat) GetRewardResidue() *big.Int
func (*ValidatorsStat) GetStakeByKind ¶
func (m *ValidatorsStat) GetStakeByKind(kind params.ValidatorKind) *big.Int
func (*ValidatorsStat) String ¶
func (m *ValidatorsStat) String() string
type WithdrawQueue ¶
type WithdrawQueue struct {
Records []*WithdrawRecord
}
func NewWithdrawQueue ¶
func NewWithdrawQueue() *WithdrawQueue
func (*WithdrawQueue) Add ¶
func (q *WithdrawQueue) Add(record *WithdrawRecord)
func (WithdrawQueue) DeepCopy ¶
func (q WithdrawQueue) DeepCopy() *WithdrawQueue
func (*WithdrawQueue) Delete ¶
func (q *WithdrawQueue) Delete(record *WithdrawRecord)
func (WithdrawQueue) Len ¶
func (q WithdrawQueue) Len() int
func (WithdrawQueue) Less ¶
func (q WithdrawQueue) Less(i, j int) bool
func (*WithdrawQueue) RemoveRecords ¶
func (q *WithdrawQueue) RemoveRecords(idx []int) []*WithdrawRecord
RemoveEntry - remove entry at index i to the withdrawing delegation
func (*WithdrawQueue) Swap ¶
func (q *WithdrawQueue) Swap(i, j int)
type WithdrawRecord ¶
type WithdrawRecord struct { Operator common.Address `json:"operator"` Delegator common.Address `json:"delegator"` Validator common.Address `json:"validator"` Recipient common.Address `json:"recipient"` Nonce uint64 `json:"nonce"` CreationHeight uint64 `json:"creationHeight"` // height which the withdraw took place CompletionHeight uint64 `json:"completionHeight"` // height which the withdraw will complete InitialBalance *big.Int `json:"initialBalance"` // tokens initially scheduled to receive at completion FinalBalance *big.Int `json:"finalBalance"` // tokens to receive at completion 最后实际收到的token数量 Finished uint8 `json:"finished"` TxHash common.Hash `json:"txHash"` }
func NewWithdrawRecord ¶
func NewWithdrawRecord() *WithdrawRecord
func (*WithdrawRecord) DeepCopy ¶
func (u *WithdrawRecord) DeepCopy() *WithdrawRecord
func (*WithdrawRecord) Dump ¶
func (u *WithdrawRecord) Dump() *DumpWithdrawRecord
func (WithdrawRecord) IsMature ¶
func (u WithdrawRecord) IsMature(height uint64) bool
func (*WithdrawRecord) String ¶
func (u *WithdrawRecord) String() string