Documentation ¶
Index ¶
- Constants
- type Account
- type BucketTree
- type StateDB
- func (sdb *StateDB) AddBalance(addr common.Address, amount *big.Int)
- func (sdb *StateDB) AddLog(log *types.Log)
- func (sdb *StateDB) ChargeGas(addr common.Address, amount uint64)
- func (sdb *StateDB) Commit(batch tdb.Batch) (common.Hash, error)
- func (sdb *StateDB) CreateAccount(addr common.Address)
- func (sdb *StateDB) Empty(addr common.Address) bool
- func (sdb *StateDB) Exist(addr common.Address) bool
- func (sdb *StateDB) GetBalance(addr common.Address) *big.Int
- func (sdb *StateDB) GetCode(addr common.Address) []byte
- func (sdb *StateDB) GetCodeHash(addr common.Address) common.Hash
- func (sdb *StateDB) GetCodeSize(address common.Address) int
- func (sdb *StateDB) GetLogs(txHash common.Hash) types.Logs
- func (sdb *StateDB) GetNonce(addr common.Address) uint64
- func (sdb *StateDB) GetOrNewStateObj(addr common.Address) *stateObject
- func (sdb *StateDB) GetState(addr common.Address, key common.Hash) []byte
- func (sdb *StateDB) GetStateObj(addr common.Address) *stateObject
- func (sdb *StateDB) HasSuicided(addr common.Address) bool
- func (sdb *StateDB) IntermediateRoot() (common.Hash, error)
- func (sdb *StateDB) Prepare(txHash, blockHash common.Hash, txIndex uint32)
- func (sdb *StateDB) RevertToSnapshot(revid int)
- func (sdb *StateDB) SetBalance(addr common.Address, target *big.Int)
- func (sdb *StateDB) SetCode(addr common.Address, code []byte)
- func (sdb *StateDB) SetNonce(addr common.Address, nonce uint64)
- func (sdb *StateDB) SetState(addr common.Address, key common.Hash, value []byte)
- func (sdb *StateDB) Snapshot() int
- func (sdb *StateDB) StateBmt(addr common.Address) BucketTree
- func (sdb *StateDB) SubBalance(addr common.Address, amount *big.Int)
- func (sdb *StateDB) Suicide(addr common.Address) bool
- func (sdb *StateDB) UpdateCurrHeight(height uint64)
- type Storage
Constants ¶
const (
KeyContractCode = "c"
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Nonce uint64 `json:"nonce"` Balance *big.Int `json:"balance"` Root common.Hash `json:"root"` CodeHash common.Hash `json:"code_hash"` }
func (*Account) Deserialize ¶
type BucketTree ¶
type BucketTree interface { Hash() common.Hash Init(root []byte) error Prepare(dirty bmt.WriteSet) error Process() (common.Hash, error) Commit(batch tdb.Batch) error Get(key []byte) ([]byte, error) Copy() *bmt.BucketTree Purge() }
Bucket tree
type StateDB ¶
type StateDB struct {
// contains filtered or unexported fields
}
func (*StateDB) ChargeGas ¶
ChargeGas charge a given address as gas during the transaction execution, but will give back at the state commit process. This mechanism is make free transactions possible and defend sending huge amount of transactions from the same address viciously.
func (*StateDB) 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.
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) GetOrNewStateObj ¶
Get or create a state object
func (*StateDB) GetStateObj ¶
Get state object from cache and bucket tree If error, return nil
func (*StateDB) IntermediateRoot ¶
Process dirty state object to state tree and get intermediate root
func (*StateDB) RevertToSnapshot ¶
func (*StateDB) StateBmt ¶
func (sdb *StateDB) StateBmt(addr common.Address) BucketTree
Get state bucket merkel tree of state object