github.com/arieschain/arieschain@v0.0.0-20191023063405-37c074544356/core/vm/interface.go (about)

     1  package vm
     2  
     3  import (
     4  	"math/big"
     5  
     6  	"github.com/quickchainproject/quickchain/common"
     7  	"github.com/quickchainproject/quickchain/core/types"
     8  )
     9  
    10  // StateDB is an EVM database for full state querying.
    11  type StateDB interface {
    12  	CreateAccount(common.Address)
    13  
    14  	SubBalance(common.Address, *big.Int)
    15  	AddBalance(common.Address, *big.Int)
    16  	GetBalance(common.Address) *big.Int
    17  
    18  	GetNonce(common.Address) uint64
    19  	SetNonce(common.Address, uint64)
    20  
    21  	GetCodeHash(common.Address) common.Hash
    22  	GetCode(common.Address) []byte
    23  	SetCode(common.Address, []byte)
    24  	GetCodeSize(common.Address) int
    25  
    26  	AddRefund(uint64)
    27  	GetRefund() uint64
    28  
    29  	GetState(common.Address, common.Hash) common.Hash
    30  	SetState(common.Address, common.Hash, common.Hash)
    31  
    32  	Suicide(common.Address) bool
    33  	HasSuicided(common.Address) bool
    34  
    35  	// Exist reports whether the given account exists in state.
    36  	// Notably this should also return true for suicided accounts.
    37  	Exist(common.Address) bool
    38  	// Empty returns whether the given account is empty. Empty
    39  	// is defined according to EIP161 (balance = nonce = code = 0).
    40  	Empty(common.Address) bool
    41  
    42  	RevertToSnapshot(int)
    43  	Snapshot() int
    44  
    45  	AddLog(*types.Log)
    46  	AddPreimage(common.Hash, []byte)
    47  
    48  	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
    49  }
    50  
    51  // CallContext provides a basic interface for the EVM calling conventions. The EVM EVM
    52  // depends on this context being implemented for doing subcalls and initialising new EVM contracts.
    53  type CallContext interface {
    54  	// Call another contract
    55  	Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
    56  	// Take another's contract code and execute within our own context
    57  	CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
    58  	// Same as CallCode except sender and value is propagated from parent to child scope
    59  	DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
    60  	// Create a new contract
    61  	Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
    62  }