Documentation ¶
Overview ¶
Package state manages the main accounts trie. It follows the flow as bellow:
o | [ revertable state ] | [ stacked map ] -> [ journal ] -> [ playback(staging) ] -> [ updated trie ] | [ trie cache ] | [ read-only trie ]
It's much simpler than Ethereum's statedb. An important difference with statedb is the logic of account suicide. TODO: explain more
Index ¶
- type Account
- type Creator
- type SECache
- type SECacheEntry
- type Stage
- type State
- func (s *State) AddBalance(addr meter.Address, amount *big.Int)
- func (s *State) AddBoundedBalance(addr meter.Address, amount *big.Int)
- func (s *State) AddBoundedEnergy(addr meter.Address, amount *big.Int)
- func (s *State) AddEnergy(addr meter.Address, amount *big.Int)
- func (s *State) BuildStorageTrie(addr meter.Address) (*trie.SecureTrie, error)
- func (s *State) DecodeStorage(addr meter.Address, key meter.Bytes32, dec func([]byte) error)
- func (s *State) Delete(addr meter.Address)
- func (s *State) EncodeStorage(addr meter.Address, key meter.Bytes32, enc func() ([]byte, error))
- func (s *State) Err() error
- func (s *State) Exists(addr meter.Address) bool
- func (s *State) GetAuctionCB() (result *meter.AuctionCB)
- func (s *State) GetBalance(addr meter.Address) *big.Int
- func (s *State) GetBoundedBalance(addr meter.Address) *big.Int
- func (s *State) GetBoundedEnergy(addr meter.Address) *big.Int
- func (s *State) GetBucketList() (result *meter.BucketList)
- func (s *State) GetCandidateList() (result *meter.CandidateList)
- func (s *State) GetCode(addr meter.Address) []byte
- func (s *State) GetCodeHash(addr meter.Address) meter.Bytes32
- func (s *State) GetDelegateList() (result *meter.DelegateList)
- func (s *State) GetDelegateStatList() (result *meter.DelegateStatList)
- func (s *State) GetEnergy(addr meter.Address) *big.Int
- func (s *State) GetInJailList() (result *meter.InJailList)
- func (s *State) GetMaster(addr meter.Address) meter.Address
- func (s *State) GetProfileList() (result *meter.ProfileList)
- func (s *State) GetRawStorage(addr meter.Address, key meter.Bytes32) rlp.RawValue
- func (s *State) GetStakeHolderList() (result *meter.StakeholderList)
- func (s *State) GetStatisticsEpoch() (result uint32)
- func (s *State) GetStorage(addr meter.Address, key meter.Bytes32) meter.Bytes32
- func (s *State) GetSummaryList() (result *meter.AuctionSummaryList)
- func (s *State) GetValidatorRewardList() (result *meter.ValidatorRewardList)
- func (s *State) IsExclusiveAccount(addr meter.Address) bool
- func (s *State) NewCheckpoint() int
- func (s *State) RevertTo(revision int)
- func (s *State) SetAuctionCB(auctionCB *meter.AuctionCB)
- func (s *State) SetBalance(addr meter.Address, balance *big.Int)
- func (s *State) SetBoundedBalance(addr meter.Address, balance *big.Int)
- func (s *State) SetBoundedEnergy(addr meter.Address, energy *big.Int)
- func (s *State) SetBucketList(bucketList *meter.BucketList)
- func (s *State) SetCandidateList(candList *meter.CandidateList)
- func (s *State) SetCode(addr meter.Address, code []byte)
- func (s *State) SetDelegateList(delegateList *meter.DelegateList)
- func (s *State) SetDelegateStatList(list *meter.DelegateStatList)
- func (s *State) SetEnergy(addr meter.Address, energy *big.Int)
- func (s *State) SetInJailList(list *meter.InJailList)
- func (s *State) SetMaster(addr meter.Address, master meter.Address)
- func (s *State) SetProfileList(lockList *meter.ProfileList)
- func (s *State) SetRawStorage(addr meter.Address, key meter.Bytes32, raw rlp.RawValue)
- func (s *State) SetStakeHolderList(holderList *meter.StakeholderList)
- func (s *State) SetStatisticsEpoch(phaseOutEpoch uint32)
- func (s *State) SetStorage(addr meter.Address, key, value meter.Bytes32)
- func (s *State) SetSummaryList(summaryList *meter.AuctionSummaryList)
- func (s *State) SetValidatorRewardList(list *meter.ValidatorRewardList)
- func (s *State) Spawn(root meter.Bytes32) *State
- func (s *State) Stage() *Stage
- func (s *State) SubBalance(addr meter.Address, amount *big.Int) bool
- func (s *State) SubBoundedBalance(addr meter.Address, amount *big.Int) bool
- func (s *State) SubBoundedEnergy(addr meter.Address, amount *big.Int) bool
- func (s *State) SubEnergy(addr meter.Address, amount *big.Int) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Balance *big.Int Energy *big.Int BoundBalance *big.Int BoundEnergy *big.Int Master []byte // master address CodeHash []byte // hash of code StorageRoot []byte // merkle root of the storage trie }
Account is the Thor consensus representation of an account. RLP encoded objects are stored in main account trie.
func (*Account) CalcEnergy ¶
CalcEnergy calculates energy based on current block time.
func (*Account) DiffString ¶
type Creator ¶
type Creator struct {
// contains filtered or unexported fields
}
Creator state creator to cut-off kv dependency.
type SECache ¶
type SECache struct {
// contains filtered or unexported fields
}
func NewSECache ¶
func NewSECache() *SECache
func (*SECache) GetAuctionSummaryList ¶
func (se *SECache) GetAuctionSummaryList(raw []byte) *meter.AuctionSummaryList
func (*SECache) SetAuctionSummaryList ¶
func (se *SECache) SetAuctionSummaryList(raw []byte, val *meter.AuctionSummaryList)
type SECacheEntry ¶
type SECacheEntry struct {
// contains filtered or unexported fields
}
func NewSECacheEntry ¶
func NewSECacheEntry() *SECacheEntry
type Stage ¶
type Stage struct {
// contains filtered or unexported fields
}
Stage abstracts changes on the main accounts trie.
type State ¶
type State struct {
// contains filtered or unexported fields
}
State manages the main accounts trie.
func (*State) AddBalance ¶
AddBalance stub.
func (*State) AddBoundedBalance ¶ added in v1.2.0
AddBoundedBalance stub.
func (*State) AddBoundedEnergy ¶ added in v1.2.0
func (*State) BuildStorageTrie ¶
BuildStorageTrie build up storage trie for given address with cumulative changes.
func (*State) DecodeStorage ¶
DecodeStorage get and decode storage value. Error returned by dec will be absorbed by State instance.
func (*State) Delete ¶
Delete delete an account at the given address. That's set balance, energy and code to zero value.
func (*State) EncodeStorage ¶
EncodeStorage set storage value encoded by given enc method. Error returned by end will be absorbed by State instance.
func (*State) Exists ¶
Exists returns whether an account exists at the given address. See Account.IsEmpty()
func (*State) GetBalance ¶
GetBalance returns balance for the given address.
func (*State) GetBoundedBalance ¶
GetBalance returns balance for the given address.
func (*State) GetBoundedEnergy ¶
GetEnergy get energy for the given address at block number specified.
func (*State) GetBucketList ¶
func (s *State) GetBucketList() (result *meter.BucketList)
Bucket List
func (*State) GetCandidateList ¶
func (s *State) GetCandidateList() (result *meter.CandidateList)
Candidate List
func (*State) GetCodeHash ¶
GetCodeHash returns code hash for the given address.
func (*State) GetDelegateList ¶
func (s *State) GetDelegateList() (result *meter.DelegateList)
Delegates List
func (*State) GetDelegateStatList ¶
func (s *State) GetDelegateStatList() (result *meter.DelegateStatList)
==== Statistics List, unlike others, save/get list
func (*State) GetInJailList ¶
func (s *State) GetInJailList() (result *meter.InJailList)
inJail List
func (*State) GetMaster ¶
GetMaster get master for the given address. Master can move energy, manage users...
func (*State) GetProfileList ¶
func (s *State) GetProfileList() (result *meter.ProfileList)
Profile List
func (*State) GetRawStorage ¶
GetRawStorage returns storage value in rlp raw for given address and key.
func (*State) GetStakeHolderList ¶
func (s *State) GetStakeHolderList() (result *meter.StakeholderList)
StakeHolder List
func (*State) GetStatisticsEpoch ¶
Statistics List, unlike others, save/get list
func (*State) GetStorage ¶
GetStorage returns storage value for the given address and key.
func (*State) GetSummaryList ¶
func (s *State) GetSummaryList() (result *meter.AuctionSummaryList)
summary List
func (*State) GetValidatorRewardList ¶
func (s *State) GetValidatorRewardList() (result *meter.ValidatorRewardList)
validator reward list
func (*State) IsExclusiveAccount ¶ added in v1.2.0
func (*State) NewCheckpoint ¶
NewCheckpoint makes a checkpoint of current state. It returns revision of the checkpoint.
func (*State) SetAuctionCB ¶
func (*State) SetBalance ¶
SetBalance set balance for the given address.
func (*State) SetBoundedBalance ¶
SetBalance set balance for the given address.
func (*State) SetBoundedEnergy ¶
SetEnergy set energy at block number for the given address.
func (*State) SetBucketList ¶
func (s *State) SetBucketList(bucketList *meter.BucketList)
func (*State) SetCandidateList ¶
func (s *State) SetCandidateList(candList *meter.CandidateList)
func (*State) SetDelegateList ¶
func (s *State) SetDelegateList(delegateList *meter.DelegateList)
func (*State) SetDelegateStatList ¶
func (s *State) SetDelegateStatList(list *meter.DelegateStatList)
func (*State) SetInJailList ¶
func (s *State) SetInJailList(list *meter.InJailList)
func (*State) SetProfileList ¶
func (s *State) SetProfileList(lockList *meter.ProfileList)
func (*State) SetRawStorage ¶
SetRawStorage set storage value in rlp raw.
func (*State) SetStakeHolderList ¶
func (s *State) SetStakeHolderList(holderList *meter.StakeholderList)
func (*State) SetStatisticsEpoch ¶
func (*State) SetStorage ¶
SetStorage set storage value for the given address and key.
func (*State) SetSummaryList ¶
func (s *State) SetSummaryList(summaryList *meter.AuctionSummaryList)
func (*State) SetValidatorRewardList ¶
func (s *State) SetValidatorRewardList(list *meter.ValidatorRewardList)
func (*State) Spawn ¶
Spawn create a new state object shares current state's underlying db. Also errors will be reported to current state.
func (*State) SubBalance ¶
SubBalance stub.
func (*State) SubBoundedBalance ¶ added in v1.2.0
SubBoundedBalance stub.
func (*State) SubBoundedEnergy ¶ added in v1.2.0
SubEnergy stub.