Documentation
¶
Overview ¶
Package vmdb
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Package vmdb ¶
@author: xwc1125
Index ¶
- func NewDatabase(db kvstore.Database) basedb.Database
- func NewDatabaseWithCache(db kvstore.Database, cache int) basedb.Database
- func NewStateSync(root types.Hash, database kvstore.KeyValueReader, bloom *tree.SyncBloom) *tree.Sync
- type BzStateDb
- type StateDB
- func (s *StateDB) AddBalance(addr types.DomainAddress, amount *big.Int)
- func (s *StateDB) AddLog(logger *statetype.Log)
- func (s *StateDB) AddPreimage(hash types.Hash, preimage []byte)
- func (s *StateDB) AddRefund(gas uint64)
- func (s *StateDB) AddTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
- func (s *StateDB) BlockHash() types.Hash
- func (s *StateDB) Commit(deleteEmptyObjects bool) (types.Hash, error)
- func (s *StateDB) Copy() *StateDB
- func (s *StateDB) CreateAccount(addr types.DomainAddress)
- func (s *StateDB) Database() basedb.Database
- func (s *StateDB) Empty(addr types.DomainAddress) bool
- func (s *StateDB) Error() error
- func (s *StateDB) Exist(addr types.DomainAddress) bool
- func (s *StateDB) Finalise(deleteEmptyObjects bool)
- func (db *StateDB) ForEachStorage(addr types.DomainAddress, cb func(key, value types.Hash) bool) error
- func (s *StateDB) GetBalance(addr types.DomainAddress) *big.Int
- func (s *StateDB) GetCode(addr types.DomainAddress) []byte
- func (s *StateDB) GetCodeHash(addr types.DomainAddress) types.Hash
- func (s *StateDB) GetCodeSize(addr types.DomainAddress) int
- func (s *StateDB) GetCommittedState(addr types.DomainAddress, hash types.Hash) types.Hash
- func (s *StateDB) GetContractInfo(addr types.DomainAddress) []byte
- func (s *StateDB) GetLogs(hash types.Hash) []*statetype.Log
- func (s *StateDB) GetNonce(addr types.DomainAddress) uint64
- func (s *StateDB) GetOrNewStateObject(addr types.DomainAddress) *stateObject
- func (s *StateDB) GetProof(a types.DomainAddress) ([][]byte, error)
- func (s *StateDB) GetRefund() uint64
- func (s *StateDB) GetState(addr types.DomainAddress, hash types.Hash) types.Hash
- func (s *StateDB) GetStorageProof(a types.DomainAddress, key types.Hash) ([][]byte, error)
- func (s *StateDB) GetTokenBalance(addr types.DomainAddress, token types.DomainAddress) *big.Int
- func (s *StateDB) GetTokenBalances(addr types.DomainAddress) statetype.TokenValues
- func (s *StateDB) HasSuicided(addr types.DomainAddress) bool
- func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) types.Hash
- func (s *StateDB) Logs() []*statetype.Log
- func (s *StateDB) Preimages() map[types.Hash][]byte
- func (s *StateDB) Prepare(thash, bhash types.Hash, ti int)
- func (s *StateDB) Reset(root types.Hash) error
- func (s *StateDB) RevertToSnapshot(revid int)
- func (s *StateDB) SetBalance(addr types.DomainAddress, amount *big.Int)
- func (s *StateDB) SetCode(addr types.DomainAddress, code []byte)
- func (s *StateDB) SetContractInfo(addr types.DomainAddress, info []byte)
- func (s *StateDB) SetNonce(addr types.DomainAddress, nonce uint64)
- func (s *StateDB) SetState(addr types.DomainAddress, key, value types.Hash)
- func (s *StateDB) SetTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
- func (s *StateDB) Snapshot() int
- func (s *StateDB) StorageTree(addr types.DomainAddress) tree.Tree
- func (s *StateDB) SubBalance(addr types.DomainAddress, amount *big.Int)
- func (s *StateDB) SubRefund(gas uint64)
- func (s *StateDB) SubTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
- func (s *StateDB) Suicide(addr types.DomainAddress) bool
- func (s *StateDB) TxIndex() int
- type StateDBFace
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDatabaseWithCache ¶
NewDatabaseWithCache creates a backing store for state. The returned database is safe for concurrent use and retains a lot of collapsed RLP trie nodes in a large memory cache.
func NewStateSync ¶
func NewStateSync(root types.Hash, database kvstore.KeyValueReader, bloom *tree.SyncBloom) *tree.Sync
NewStateSync create a new state trie download scheduler.
Types ¶
type BzStateDb ¶
type BzStateDb interface { AddBalance(addr types.Address, amount *big.Int) SubBalance(addr types.Address, amount *big.Int) GetBalance(addr types.Address) *big.Int SetBalance(addr types.Address, amount *big.Int) GetNonce(addr types.Address) *big.Int SetNonce(addr types.Address, nonce *big.Int) AddLog(log *statetype.Log) GetLogs(hash types.Hash) []*statetype.Log Logs() []*statetype.Log AddRefund(gas uint64) SubRefund(gas uint64) GetRefund() uint64 GetCode(addr types.Address) []byte GetCodeSize(addr types.Address) int GetCodeHash(addr types.Address) types.Hash SetCode(addr types.Address, code []byte) }
type StateDB ¶
type StateDB struct { // Measurements gathered during execution for debugging purposes AccountReads time.Duration AccountHashes time.Duration AccountUpdates time.Duration AccountCommits time.Duration StorageReads time.Duration StorageHashes time.Duration StorageUpdates time.Duration StorageCommits time.Duration // contains filtered or unexported fields }
StateDB 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
func (*StateDB) AddBalance ¶
func (s *StateDB) AddBalance(addr types.DomainAddress, amount *big.Int)
AddBalance adds amount to the account associated with addr.
func (*StateDB) AddPreimage ¶
AddPreimage records a SHA3 preimage seen by the VM.
func (*StateDB) AddTokenBalance ¶
func (s *StateDB) AddTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
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 ¶
func (s *StateDB) CreateAccount(addr types.DomainAddress)
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) Database ¶
Database retrieves the low level database supporting the lower level trie ops.
func (*StateDB) Empty ¶
func (s *StateDB) Empty(addr types.DomainAddress) bool
Empty returns whether the state object is either non-existent or empty according to the EIP161 specification (balance = nonce = code = 0)
func (*StateDB) Exist ¶
func (s *StateDB) Exist(addr types.DomainAddress) bool
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 s destructed objects and clears the journal as well as the refunds. Finalise, however, will not push any updates into the tries just yet. Only IntermediateRoot or Commit will do that.
func (*StateDB) ForEachStorage ¶
func (*StateDB) GetBalance ¶
func (s *StateDB) GetBalance(addr types.DomainAddress) *big.Int
Retrieve the balance from the given address or 0 if object not found
func (*StateDB) GetCodeHash ¶
func (s *StateDB) GetCodeHash(addr types.DomainAddress) types.Hash
func (*StateDB) GetCodeSize ¶
func (s *StateDB) GetCodeSize(addr types.DomainAddress) int
func (*StateDB) GetCommittedState ¶
GetCommittedState retrieves a value from the given account's committed storage trie.
func (*StateDB) GetContractInfo ¶
func (s *StateDB) GetContractInfo(addr types.DomainAddress) []byte
func (*StateDB) GetOrNewStateObject ¶
func (s *StateDB) GetOrNewStateObject(addr types.DomainAddress) *stateObject
Retrieve a state object or create a new state object if nil.
func (*StateDB) GetProof ¶
func (s *StateDB) GetProof(a types.DomainAddress) ([][]byte, error)
GetProof returns the MerkleProof for a given Account
func (*StateDB) GetStorageProof ¶
GetProof returns the StorageProof for given key
func (*StateDB) GetTokenBalance ¶
func (s *StateDB) GetTokenBalance(addr types.DomainAddress, token types.DomainAddress) *big.Int
func (*StateDB) GetTokenBalances ¶
func (s *StateDB) GetTokenBalances(addr types.DomainAddress) statetype.TokenValues
func (*StateDB) HasSuicided ¶
func (s *StateDB) HasSuicided(addr types.DomainAddress) bool
func (*StateDB) IntermediateRoot ¶
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) Prepare ¶
Prepare sets the current transaction hash and index and block hash which is used when the EVM emits new state logs.
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) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*StateDB) SetBalance ¶
func (s *StateDB) SetBalance(addr types.DomainAddress, amount *big.Int)
func (*StateDB) SetContractInfo ¶
func (s *StateDB) SetContractInfo(addr types.DomainAddress, info []byte)
func (*StateDB) SetState ¶
func (s *StateDB) SetState(addr types.DomainAddress, key, value types.Hash)
func (*StateDB) SetTokenBalance ¶
func (s *StateDB) SetTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
func (*StateDB) StorageTree ¶
func (s *StateDB) StorageTree(addr types.DomainAddress) tree.Tree
StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.
func (*StateDB) SubBalance ¶
func (s *StateDB) SubBalance(addr types.DomainAddress, amount *big.Int)
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) SubTokenBalance ¶
func (s *StateDB) SubTokenBalance(addr types.DomainAddress, token types.DomainAddress, amount *big.Int)
type StateDBFace ¶
type StateDBFace interface { Error() error Reset(root types.Hash) error Exist(addr types.Address) bool Empty(addr types.Address) bool Copy() *StateDB GetState(addr types.Address, hash types.Hash) types.Hash GetCommittedState(addr types.Address, hash types.Hash) types.Hash SetState(addr types.Address, key, value types.Hash) GetProof(a types.Address) ([][]byte, error) GetStorageProof(a types.Address, key types.Hash) ([][]byte, error) TxIndex() int BlockHash() types.Hash AddPreimage(hash types.Hash, preimage []byte) Preimages() map[types.Hash][]byte StorageTree(addr types.Address) tree.Tree HasSuicided(addr types.Address) bool Suicide(addr types.Address) bool Snapshot() int RevertToSnapshot(revid int) IntermediateRoot(deleteEmptyObjects bool) types.Hash Finalise(deleteEmptyObjects bool) Prepare(thash, bhash types.Hash, ti int) Commit(deleteEmptyObjects bool) (types.Hash, error) }