Documentation ¶
Overview ¶
Package account is used to do accounts or contract operations
Index ¶
- type AccAccesser
- type Account
- type AccountDB
- func (adb *AccountDB) AddBalance(addr common.Address, amount *big.Int)
- func (adb *AccountDB) AddRefund(gas uint64)
- func (adb *AccountDB) CanTransfer(addr common.Address, amount *big.Int) bool
- func (adb *AccountDB) Commit(deleteEmptyObjects bool) (root common.Hash, err error)
- func (adb *AccountDB) CreateAccount(addr common.Address)
- func (adb *AccountDB) DataIterator(addr common.Address, prefix []byte) *trie.Iterator
- func (adb *AccountDB) Database() AccountDatabase
- func (adb *AccountDB) Empty(addr common.Address) bool
- func (adb *AccountDB) Error() error
- func (adb *AccountDB) Exist(addr common.Address) bool
- func (adb *AccountDB) Finalise(deleteEmptyObjects bool)
- func (adb *AccountDB) GetBalance(addr common.Address) *big.Int
- func (adb *AccountDB) GetCode(addr common.Address) []byte
- func (adb *AccountDB) GetCodeHash(addr common.Address) common.Hash
- func (adb *AccountDB) GetCodeSize(addr common.Address) int
- func (adb *AccountDB) GetData(a common.Address, key []byte) []byte
- func (adb *AccountDB) GetNonce(addr common.Address) uint64
- func (adb *AccountDB) GetRefund() uint64
- func (adb *AccountDB) GetStateObject(a common.Address) AccAccesser
- func (adb *AccountDB) HasSuicided(addr common.Address) bool
- func (adb *AccountDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash
- func (adb *AccountDB) MarkAccountObjectDirty(addr common.Address)
- func (adb *AccountDB) RemoveData(addr common.Address, key []byte)
- func (adb *AccountDB) Reset(root common.Hash) error
- func (adb *AccountDB) RevertToSnapshot(revid int)
- func (adb *AccountDB) SetBalance(addr common.Address, amount *big.Int)
- func (adb *AccountDB) SetCode(addr common.Address, code []byte)
- func (adb *AccountDB) SetData(addr common.Address, key []byte, value []byte)
- func (adb *AccountDB) SetNonce(addr common.Address, nonce uint64)
- func (adb *AccountDB) Snapshot() int
- func (adb *AccountDB) StorageTrie(a common.Address) Trie
- func (adb *AccountDB) SubBalance(addr common.Address, amount *big.Int)
- func (adb *AccountDB) Suicide(addr common.Address) bool
- func (adb *AccountDB) Transfer(sender, recipient common.Address, amount *big.Int)
- func (adb *AccountDB) Traverse(config *TraverseConfig) (bool, error)
- type AccountDatabase
- type Code
- type DataIterator
- type NodeIterator
- type Storage
- type SubTreeKeyProvider
- type TraverseConfig
- type TraverseStat
- type Trie
- type VisitAccountCallback
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccAccesser ¶
type Account ¶
Account is the consensus representation of accounts. These objects are stored in the main account trie.
type AccountDB ¶
type AccountDB struct {
// contains filtered or unexported fields
}
AccountDB are used to store anything within the merkle trie. AccountDB take care of caching and storing nested states. It's the general query interface to retrieve: * Contracts * Accounts
func NewAccountDB ¶
func NewAccountDB(root common.Hash, db AccountDatabase) (*AccountDB, error)
Create a new account from a given trie.
func (*AccountDB) AddBalance ¶
AddBalance adds amount to the account associated with addr.
func (*AccountDB) CanTransfer ¶
func (*AccountDB) 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.
func (*AccountDB) DataIterator ¶
DataIterator returns a new key-value iterator from a node iterator
func (*AccountDB) Database ¶
func (adb *AccountDB) Database() AccountDatabase
Database retrieves the low level database supporting the lower level trie ops.
func (*AccountDB) Empty ¶
Empty returns whether the state object is either non-existent or (balance = nonce = code = 0)
func (*AccountDB) Exist ¶
Exist reports whether the given account address exists in the state. Notably this also returns true for suicided accounts.
func (*AccountDB) Finalise ¶
Finalise finalises the state by removing the self destructed objects and clears the journal as well as the refunds.
func (*AccountDB) GetBalance ¶
GetBalance Retrieve the balance from the given address or 0 if object not found
func (*AccountDB) GetCodeHash ¶
GetCodeHash returns code's hash
func (*AccountDB) GetCodeSize ¶
GetCodeSize retrieves a particular contracts code's size.
func (*AccountDB) GetNonce ¶
GetBalance Retrieve the nonce from the given address or 0 if object not found
func (*AccountDB) GetStateObject ¶
func (adb *AccountDB) GetStateObject(a common.Address) AccAccesser
GetStateObject returns stateobject's interface.
func (*AccountDB) HasSuicided ¶
HasSuicided returns this account is suicided
func (*AccountDB) 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 (*AccountDB) MarkAccountObjectDirty ¶
MarkAccountObjectDirty Record the modified accounts
func (*AccountDB) RemoveData ¶
RemoveData set data nil
func (*AccountDB) 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 (*AccountDB) RevertToSnapshot ¶
RevertToSnapshot reverts all state changes made since the given revision.
func (*AccountDB) SetBalance ¶
func (*AccountDB) Snapshot ¶
// Snapshot returns an identifier for the current revision of the account.
func (*AccountDB) StorageTrie ¶
StorageTrie returns the storage trie of an account. The return value is a copy and is nil for non-existent accounts.
func (*AccountDB) SubBalance ¶
SubBalance subtracts amount from the account associated with addr.
func (*AccountDB) Suicide ¶
Suicide marks the given account as suicided. This clears the account balance.
The account's account object is still available until the account is committed, getAccountObject will return a non-nil account after Suicide.
type AccountDatabase ¶
type AccountDatabase 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) // TrieDB retrieves the low level trie database used for data storage. TrieDB() *trie.NodeDatabase }
func NewDatabase ¶
func NewDatabase(db tasdb.Database, gcEnable bool) AccountDatabase
NewDatabase 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 NewDatabaseWithCache ¶
type DataIterator ¶
func (*DataIterator) GetValue ¶
func (di *DataIterator) GetValue() []byte
func (*DataIterator) Next ¶
func (di *DataIterator) Next() bool
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 *AccountDB) *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 SubTreeKeyProvider ¶
type TraverseConfig ¶
type TraverseConfig struct { VisitAccountCb VisitAccountCallback ResolveNodeCb trie.ResolveNodeCallback CheckHash bool SubTreeKeysProvider SubTreeKeyProvider // Provides concerned keys for the specified address, and only traverse the given keys for the address VisitedRoots map[common.Hash]struct{} // Store visited roots, no more revisit for duplicate roots // contains filtered or unexported fields }
func (*TraverseConfig) OnResolve ¶
func (cfg *TraverseConfig) OnResolve(hash common.Hash, data []byte)
func (*TraverseConfig) OnVisitAccount ¶
func (cfg *TraverseConfig) OnVisitAccount(stat *TraverseStat)
type TraverseStat ¶
type TraverseStat struct { Addr common.Address Account Account DataCount uint64 DataSize uint64 NodeSize uint64 NodeCount uint64 KeySize uint64 CodeSize uint64 Cost time.Duration }
func (*TraverseStat) String ¶
func (vs *TraverseStat) String() string
type Trie ¶
type Trie interface { // TryGet returns the value for key stored in the trie. The value bytes must // not be modified by the caller. If a node was not found in the database, a // trie.MissingNodeError is returned. TryGet(key []byte) ([]byte, error) // TryUpdate associates key with value in the trie. If value has length zero, any // existing value is deleted from the trie. The value bytes must not be modified // by the caller while they are stored in the trie. If a node was not found in the // database, a trie.MissingNodeError is returned. TryUpdate(key, value []byte) error // TryDelete removes any existing value for key from the trie. If a node was not // found in the database, a trie.MissingNodeError is returned. TryDelete(key []byte) error // Commit writes all nodes to the trie's memory database, tracking the internal // and external (for account tries) references. Commit(onleaf trie.LeafCallback) (common.Hash, error) // Hash returns the root hash of the trie. It does not write to the database and // can be used even if the trie doesn't have one. Hash() common.Hash // NodeIterator returns an iterator that returns nodes of the trie. Iteration // starts at the key after the given start key. NodeIterator(startKey []byte) trie.NodeIterator // Traverse is a debug method to iterate over the entire trie stored in // the disk and check whether every node is reachable from the meta root. The goal // is to find any errors that might cause trie nodes missing during prune // // This method is extremely CPU and disk intensive, and time consuming, only use when must. Traverse(onleaf trie.ExtLeafCallback, resolve trie.ResolveNodeCallback, checkHash bool) (bool, error) }
type VisitAccountCallback ¶
type VisitAccountCallback func(stat *TraverseStat)