github.com/insight-chain/inb-go@v1.1.3-0.20191221022159-da049980ae38/core/vm/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 vm
    18  
    19  import (
    20  	"math/big"
    21  
    22  	"github.com/insight-chain/inb-go/common"
    23  	"github.com/insight-chain/inb-go/core/types"
    24  )
    25  
    26  // StateDB is an EVM 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  	//achilles
    35  	AddNet(addr common.Address, amount *big.Int)
    36  	UseRes(addr common.Address, amount *big.Int)
    37  	GetNet(addr common.Address) *big.Int
    38  	GetStakingValue(addr common.Address) *big.Int
    39  	GetDate(addr common.Address) *big.Int
    40  	GetUnStakingHeight(addr common.Address) *big.Int
    41  	GetTotalStaking(addr common.Address) *big.Int
    42  	GetTotalStakingYear(addr common.Address) *big.Int
    43  	GetUnStaking(addr common.Address) *big.Int
    44  	MortgageNet(addr common.Address, amount *big.Int, duration *big.Int, sTime big.Int, hash common.Hash) *big.Int
    45  	ResetNet(addr common.Address, update *big.Int) *big.Int
    46  	Receive(addr common.Address, sTime *big.Int) *big.Int
    47  	Redeem(addr common.Address, amount *big.Int, sTime *big.Int)
    48  	UnitConvertNet() *big.Int
    49  	StoreLength(addr common.Address) int
    50  	//Resource by zc
    51  	//GetStateObject(address common.Address, num *big.Int, variety int)
    52  	//Resource by zc
    53  	//2019.7.22 inb by ghy begin
    54  	CanReceiveLockedAward(common.Address, common.Hash, *big.Int, types.SpecialConsensus) (error, *big.Int, bool, common.Address)
    55  	ReceiveLockedAward(common.Address, common.Hash, *big.Int, bool, *big.Int, common.Address)
    56  
    57  	CanReceiveVoteAward(common.Address, *big.Int, types.SpecialConsensus) (error, *big.Int, common.Address)
    58  	ReceiveVoteAward(common.Address, *big.Int, *big.Int, common.Address)
    59  
    60  	Vote(common.Address, *big.Int)
    61  	//2019.7.22 inb by ghy end
    62  	GetNonce(common.Address) uint64
    63  	SetNonce(common.Address, uint64)
    64  
    65  	GetCodeHash(common.Address) common.Hash
    66  	GetCode(common.Address) []byte
    67  	SetCode(common.Address, []byte)
    68  	GetCodeSize(common.Address) int
    69  
    70  	AddRefund(uint64)
    71  	SubRefund(uint64)
    72  	GetRefund() uint64
    73  
    74  	GetCommittedState(common.Address, common.Hash) common.Hash
    75  	GetState(common.Address, common.Hash) common.Hash
    76  	SetState(common.Address, common.Hash, common.Hash)
    77  
    78  	Suicide(common.Address) bool
    79  	HasSuicided(common.Address) bool
    80  
    81  	// Exist reports whether the given account exists in state.
    82  	// Notably this should also return true for suicided accounts.
    83  	Exist(common.Address) bool
    84  	// Empty returns whether the given account is empty. Empty
    85  	// is defined according to EIP161 (balance = nonce = code = 0).
    86  	Empty(common.Address) bool
    87  
    88  	RevertToSnapshot(int)
    89  	Snapshot() int
    90  
    91  	AddLog(*types.Log)
    92  	AddPreimage(common.Hash, []byte)
    93  
    94  	ForEachStorage(common.Address, func(common.Hash, common.Hash) bool)
    95  }
    96  
    97  // CallContext provides a basic interface for the EVM calling conventions. The EVM
    98  // depends on this context being implemented for doing subcalls and initialising new EVM contracts.
    99  type CallContext interface {
   100  	// Call another contract
   101  	Call(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   102  	// Take another's contract code and execute within our own context
   103  	CallCode(env *EVM, me ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error)
   104  	// Same as CallCode except sender and value is propagated from parent to child scope
   105  	DelegateCall(env *EVM, me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error)
   106  	// Create a new contract
   107  	Create(env *EVM, me ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error)
   108  }