Documentation ¶
Index ¶
- Constants
- Variables
- func Marshal(data interface{}) ([]byte, error)
- func StageContractState(st *ContractState, states *StateDB) error
- type ContractState
- func GetEnterpriseAccountState(states *StateDB) (*ContractState, error)
- func GetMultiCallState(id []byte, st *types.State) *ContractState
- func GetNameAccountState(states *StateDB) (*ContractState, error)
- func GetSystemAccountState(states *StateDB) (*ContractState, error)
- func OpenContractState(id []byte, st *types.State, states *StateDB) (*ContractState, error)
- func OpenContractStateAccount(id []byte, states *StateDB) (*ContractState, error)
- func (cs *ContractState) DeleteData(key []byte) error
- func (cs *ContractState) GetAccountID() types.AccountID
- func (cs *ContractState) GetCode() ([]byte, error)
- func (cs *ContractState) GetData(key []byte) ([]byte, error)
- func (cs *ContractState) GetID() []byte
- func (cs *ContractState) GetInitialData(key []byte) ([]byte, error)
- func (cs *ContractState) GetRawKV(key []byte) ([]byte, error)
- func (cs *ContractState) GetSourceCode() []byte
- func (cs *ContractState) HasKey(key []byte) bool
- func (cs *ContractState) Hash() []byte
- func (ctrState *ContractState) IsMultiCall() bool
- func (cs *ContractState) Marshal() ([]byte, error)
- func (cs *ContractState) Rollback(revision Snapshot) error
- func (cs *ContractState) SetCode(sourceCode []byte, bytecode []byte) error
- func (cs *ContractState) SetData(key, value []byte) error
- func (cs *ContractState) SetMultiCallCode(code []byte)
- func (cs *ContractState) SetRawKV(key []byte, value []byte) error
- func (cs *ContractState) Snapshot() Snapshot
- type Dump
- type DumpAccount
- type Snapshot
- type StateDB
- func (states *StateDB) Clone() *StateDB
- func (states *StateDB) Commit() error
- func (sdb *StateDB) Dump() ([]byte, error)
- func (states *StateDB) GetAccountAndProof(id []byte, root []byte, compressed bool) (*types.AccountProof, error)
- func (states *StateDB) GetAccountState(id types.AccountID) (*types.State, error)
- func (states *StateDB) GetRoot() []byte
- func (states *StateDB) GetState(id types.AccountID) (*types.State, error)
- func (states *StateDB) GetVarAndProof(id []byte, root []byte, compressed bool) (*types.ContractVarProof, error)
- func (states *StateDB) HasMarker(root []byte) bool
- func (states *StateDB) IsLegacyTrieKey() bool
- func (states *StateDB) LoadCache(root []byte) error
- func (states *StateDB) PutState(id types.AccountID, state *types.State) error
- func (sdb *StateDB) RawDump() (Dump, error)
- func (states *StateDB) Revert(root types.HashID) error
- func (states *StateDB) Rollback(revision Snapshot) error
- func (states *StateDB) SetRoot(root []byte) error
- func (states *StateDB) Snapshot() Snapshot
- func (states *StateDB) TrieQuery(id []byte, root []byte, compressed bool) ([]byte, [][]byte, int, bool, []byte, []byte, error)
- func (states *StateDB) Update() error
Constants ¶
const ( StateName = "state" StateLatest = StateName + ".latest" )
Variables ¶
var ( EmptyHashID = types.HashID{} EmptyBlockID = types.BlockID{} EmptyAccountID = types.AccountID{} )
var (
StateMarker = []byte{0x54, 0x45} // marker: tail end
)
Functions ¶
func StageContractState ¶
func StageContractState(st *ContractState, states *StateDB) error
Types ¶
type ContractState ¶
func GetEnterpriseAccountState ¶
func GetEnterpriseAccountState(states *StateDB) (*ContractState, error)
GetEnterpriseAccountState returns the ContractState of the AERGO enterprise account.
func GetMultiCallState ¶ added in v2.6.0
func GetMultiCallState(id []byte, st *types.State) *ContractState
func GetNameAccountState ¶
func GetNameAccountState(states *StateDB) (*ContractState, error)
GetNameAccountState returns the ContractState of the AERGO name account.
func GetSystemAccountState ¶
func GetSystemAccountState(states *StateDB) (*ContractState, error)
GetSystemAccountState returns the ContractState of the AERGO system account.
func OpenContractState ¶
func OpenContractStateAccount ¶
func OpenContractStateAccount(id []byte, states *StateDB) (*ContractState, error)
func (*ContractState) DeleteData ¶
func (cs *ContractState) DeleteData(key []byte) error
DeleteData remove key and value pair from the storage.
func (*ContractState) GetAccountID ¶
func (cs *ContractState) GetAccountID() types.AccountID
func (*ContractState) GetCode ¶
func (cs *ContractState) GetCode() ([]byte, error)
func (*ContractState) GetData ¶
func (cs *ContractState) GetData(key []byte) ([]byte, error)
GetData returns the value corresponding to the key from the buffered storage.
func (*ContractState) GetID ¶
func (cs *ContractState) GetID() []byte
func (*ContractState) GetInitialData ¶
func (cs *ContractState) GetInitialData(key []byte) ([]byte, error)
GetInitialData returns the value corresponding to the key from the contract storage.
func (*ContractState) GetRawKV ¶
func (cs *ContractState) GetRawKV(key []byte) ([]byte, error)
GetRawKV loads (key, value) from st.store.
func (*ContractState) GetSourceCode ¶ added in v2.6.0
func (cs *ContractState) GetSourceCode() []byte
func (*ContractState) HasKey ¶
func (cs *ContractState) HasKey(key []byte) bool
HasKey returns existence of the key
func (*ContractState) Hash ¶
func (cs *ContractState) Hash() []byte
Hash implements types.ImplHashBytes
func (*ContractState) IsMultiCall ¶ added in v2.6.0
func (ctrState *ContractState) IsMultiCall() bool
this refers to the specific contract, not the transaction
func (*ContractState) Marshal ¶
func (cs *ContractState) Marshal() ([]byte, error)
Marshal implements types.ImplMarshal
func (*ContractState) Rollback ¶
func (cs *ContractState) Rollback(revision Snapshot) error
Rollback discards changes of storage buffer to revision number
func (*ContractState) SetCode ¶
func (cs *ContractState) SetCode(sourceCode []byte, bytecode []byte) error
func (*ContractState) SetData ¶
func (cs *ContractState) SetData(key, value []byte) error
SetData store key and value pair to the storage.
func (*ContractState) SetMultiCallCode ¶ added in v2.6.0
func (cs *ContractState) SetMultiCallCode(code []byte)
func (*ContractState) SetRawKV ¶
func (cs *ContractState) SetRawKV(key []byte, value []byte) error
SetRawKV saves (key, value) to st.store without any kind of encoding.
func (*ContractState) Snapshot ¶
func (cs *ContractState) Snapshot() Snapshot
Snapshot returns revision number of storage buffer
type Dump ¶
type Dump struct { Root []byte `json:"root"` Accounts map[types.AccountID]DumpAccount `json:"accounts"` }
func (Dump) MarshalJSON ¶
type DumpAccount ¶
func (DumpAccount) MarshalJSON ¶
func (d DumpAccount) MarshalJSON() ([]byte, error)
type StateDB ¶
type StateDB struct { Buffer *stateBuffer Cache *storageCache Trie *trie.Trie Store db.DB Testmode bool // contains filtered or unexported fields }
StateDB manages trie of states
func NewStateDB ¶
NewStateDB craete StateDB instance
func (*StateDB) GetAccountAndProof ¶
func (states *StateDB) GetAccountAndProof(id []byte, root []byte, compressed bool) (*types.AccountProof, error)
GetAccountAndProof gets the state and associated proof of an account in the given trie root. If the account doesnt exist, a proof of non existence is returned.
func (*StateDB) GetAccountState ¶
GetAccountState gets state of account id from statedb. empty state is returned when there is no state corresponding to account id.
func (*StateDB) GetState ¶
GetState gets state of account id from state buffer and trie. nil value is returned when there is no state corresponding to account id.
func (*StateDB) GetVarAndProof ¶
func (states *StateDB) GetVarAndProof(id []byte, root []byte, compressed bool) (*types.ContractVarProof, error)
GetVarAndProof gets the value of a variable in the given contract trie root.
func (*StateDB) IsLegacyTrieKey ¶
func (*StateDB) LoadCache ¶
LoadCache reads first layer of trie given root hash and also updates root node of trie as a given root hash