Documentation ¶
Index ¶
- Variables
- type Statedb
- func (s *Statedb) AddBalance(addr common.Address, amount *big.Int)
- func (s *Statedb) AddLog(log *types.Log)
- func (s *Statedb) AddRefund(gas uint64)
- func (s *Statedb) Commit(batch database.Batch) (common.Hash, error)
- func (s *Statedb) CreateAccount(address common.Address)
- func (s *Statedb) Empty(address common.Address) bool
- func (s *Statedb) Exist(address common.Address) bool
- func (s *Statedb) GetBalance(addr common.Address) *big.Int
- func (s *Statedb) GetCode(address common.Address) []byte
- func (s *Statedb) GetCodeHash(address common.Address) common.Hash
- func (s *Statedb) GetCodeSize(address common.Address) int
- func (s *Statedb) GetCommittedData(addr common.Address, key common.Hash) []byte
- func (s *Statedb) GetCurrentLogs() []*types.Log
- func (s *Statedb) GetData(addr common.Address, key common.Hash) []byte
- func (s *Statedb) GetDbErr() error
- func (s *Statedb) GetNonce(addr common.Address) uint64
- func (s *Statedb) GetRefund() uint64
- func (s *Statedb) HasSuicided(address common.Address) bool
- func (s *Statedb) Hash() (common.Hash, error)
- func (s *Statedb) Prepare(txIndex int) int
- func (s *Statedb) RevertToSnapshot(revid int)
- func (s *Statedb) SetBalance(addr common.Address, balance *big.Int)
- func (s *Statedb) SetCode(address common.Address, code []byte)
- func (s *Statedb) SetData(addr common.Address, key common.Hash, value []byte)
- func (s *Statedb) SetNonce(addr common.Address, nonce uint64)
- func (s *Statedb) Snapshot() int
- func (s *Statedb) SubBalance(addr common.Address, amount *big.Int)
- func (s *Statedb) SubRefund(gas uint64)
- func (s *Statedb) Suicide(address common.Address) bool
- func (s *Statedb) Trie() Trie
- type Trie
Constants ¶
This section is empty.
Variables ¶
var ( // TrieDbPrefix is the key prefix of trie database in statedb. TrieDbPrefix = []byte("S") )
Functions ¶
This section is empty.
Types ¶
type Statedb ¶
type Statedb struct {
// contains filtered or unexported fields
}
Statedb is used to store accounts into the MPT tree
func NewEmptyStatedb ¶
NewEmptyStatedb creates an empty statedb instance.
func NewStatedb ¶
NewStatedb constructs and returns a statedb instance
func NewStatedbWithTrie ¶
NewStatedbWithTrie creates a statedb instance with specified trie.
func (*Statedb) AddBalance ¶
AddBalance adds the specified amount to the balance for the specified account if exists.
func (*Statedb) CreateAccount ¶
CreateAccount creates a new account in statedb.
func (*Statedb) Empty ¶
Empty indicates whether the given account satisfies (balance = nonce = code = 0).
func (*Statedb) Exist ¶
Exist indicates whether the given account exists in statedb. Note that it should also return true for suicided accounts.
func (*Statedb) GetBalance ¶
GetBalance returns the balance of the specified account if exists. Otherwise, returns zero.
func (*Statedb) GetCode ¶
GetCode returns the contract code associated with the specified address if any. Otherwise, return nil.
func (*Statedb) GetCodeHash ¶
GetCodeHash returns the hash of the contract code associated with the specified address if any. Otherwise, return an empty hash.
func (*Statedb) GetCodeSize ¶
GetCodeSize returns the size of the contract code associated with the specified address if any. Otherwise, return 0.
func (*Statedb) GetCommittedData ¶
GetCommittedData returns the account committed data of the specified key if exists.
func (*Statedb) GetCurrentLogs ¶
GetCurrentLogs returns the current transaction logs.
func (*Statedb) GetData ¶
GetData returns the account data of the specified key if exists. Otherwise, return nil.
func (*Statedb) GetNonce ¶
GetNonce gets the nonce of the specified account if exists. Otherwise, return 0.
func (*Statedb) HasSuicided ¶
HasSuicided returns true if the specified account exists and suicided, otherwise false.
func (*Statedb) Hash ¶
Hash flush the dirty data into trie and calculates the intermediate root hash.
func (*Statedb) Prepare ¶
Prepare resets the logs and journal to process a new tx and return the statedb snapshot.
func (*Statedb) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*Statedb) SetBalance ¶
SetBalance sets the balance of the specified account if exists.
func (*Statedb) SubBalance ¶
SubBalance subtracts the specified amount from the balance for the specified account if exists.
func (*Statedb) SubRefund ¶
SubRefund removes gas from the refund counter. This method will panic if the refund counter goes below zero
type Trie ¶
type Trie interface { Hash() common.Hash Commit(batch database.Batch) common.Hash Get(key []byte) ([]byte, bool, error) Put(key, value []byte) error DeletePrefix(prefix []byte) (bool, error) GetProof(key []byte) (map[string][]byte, error) }
Trie is used for statedb to store key-value pairs. For full node, it's MPT based on levelDB. For light node, it's a ODR trie with limited functions.