github.com/n1ghtfa1l/go-vnt@v0.6.4-alpha.6/core/vm/interface/interface.go (about)

     1  // Copyright 2016 The go-ethereum Authors
     2  // This file is part of the go-ethereum library.
     3  //
     4  // The go-ethereum library is free software: you can redistribute it and/or modify
     5  // it under the terms of the GNU Lesser General Public License as published by
     6  // the Free Software Foundation, either version 3 of the License, or
     7  // (at your option) any later version.
     8  //
     9  // The go-ethereum library is distributed in the hope that it will be useful,
    10  // but WITHOUT ANY WARRANTY; without even the implied warranty of
    11  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
    12  // GNU Lesser General Public License for more details.
    13  //
    14  // You should have received a copy of the GNU Lesser General Public License
    15  // along with the go-ethereum library. If not, see <http://www.gnu.org/licenses/>.
    16  
    17  package inter
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/vntchain/go-vnt/common"
    23  	"github.com/vntchain/go-vnt/core/types"
    24  )
    25  
    26  // StateDB is an VM database for full state querying.
    27  type StateDB interface {
    28  	CreateAccount(common.Address)
    29  
    30  	SubBalance(common.Address, *big.Int)
    31  	AddBalance(common.Address, *big.Int)
    32  	GetBalance(common.Address) *big.Int
    33  
    34  	GetNonce(common.Address) uint64
    35  	SetNonce(common.Address, uint64)
    36  
    37  	GetCodeHash(common.Address) common.Hash
    38  	GetCode(common.Address) []byte
    39  	SetCode(common.Address, []byte)
    40  	GetCodeSize(common.Address) int
    41  
    42  	AddRefund(uint64)
    43  	GetRefund() uint64
    44  
    45  	GetState(common.Address, common.Hash) common.Hash
    46  	SetState(common.Address, common.Hash, common.Hash)
    47  
    48  	Suicide(common.Address) bool
    49  	HasSuicided(common.Address) bool
    50  
    51  	// Exist reports whether the given account exists in state.
    52  	// Notably this should also return true for suicided accounts.
    53  	Exist(common.Address) bool
    54  	// Empty returns whether the given account is empty. Empty
    55  	// is defined according to EIP161 (balance = nonce = code = 0).
    56  	Empty(common.Address) bool
    57  
    58  	RevertToSnapshot(int)
    59  	Snapshot() int
    60  
    61  	AddLog(*types.Log)
    62  	AddPreimage(common.Hash, []byte)
    63  
    64  	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
    65  }
    66  
    67  type Contract interface {
    68  	AsDelegate() Contract
    69  	Caller() common.Address
    70  	UseGas(gas uint64) (ok bool)
    71  	Address() common.Address
    72  	Value() *big.Int
    73  	SetCode(hash common.Hash, code []byte)
    74  	SetCallCode(addr *common.Address, hash common.Hash, code []byte)
    75  }
    76  
    77  type ChainContext interface {
    78  	GetStateDb() StateDB
    79  	GetOrigin() common.Address
    80  	GetTime() *big.Int
    81  	GetBlockNum() *big.Int
    82  }