github.com/halybang/go-ethereum@v1.0.5-0.20180325041310-3b262bc1367c/core/vm/noop.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/wanchain/go-wanchain/common" 23 "github.com/wanchain/go-wanchain/core/types" 24 25 ) 26 27 func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool { 28 return true 29 } 30 func NoopTransfer(db StateDB, from, to common.Address, amount *big.Int) {} 31 32 type NoopEVMCallContext struct{} 33 34 func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) { 35 return nil, nil 36 } 37 func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) { 38 return nil, nil 39 } 40 func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) { 41 return nil, common.Address{}, nil 42 } 43 func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) { 44 return nil, nil 45 } 46 47 type NoopStateDB struct{} 48 49 func (NoopStateDB) CreateAccount(common.Address) {} 50 func (NoopStateDB) SubBalance(common.Address, *big.Int) {} 51 func (NoopStateDB) AddBalance(common.Address, *big.Int) {} 52 func (NoopStateDB) GetBalance(common.Address) *big.Int { return nil } 53 func (NoopStateDB) GetNonce(common.Address) uint64 { return 0 } 54 func (NoopStateDB) SetNonce(common.Address, uint64) {} 55 func (NoopStateDB) GetCodeHash(common.Address) common.Hash { return common.Hash{} } 56 func (NoopStateDB) GetCode(common.Address) []byte { return nil } 57 func (NoopStateDB) SetCode(common.Address, []byte) {} 58 func (NoopStateDB) GetCodeSize(common.Address) int { return 0 } 59 func (NoopStateDB) AddRefund(*big.Int) {} 60 func (NoopStateDB) GetRefund() *big.Int { return nil } 61 func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash { return common.Hash{} } 62 func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash) {} 63 func (NoopStateDB) Suicide(common.Address) bool { return false } 64 func (NoopStateDB) HasSuicided(common.Address) bool { return false } 65 func (NoopStateDB) Exist(common.Address) bool { return false } 66 func (NoopStateDB) Empty(common.Address) bool { return false } 67 func (NoopStateDB) RevertToSnapshot(int) {} 68 func (NoopStateDB) Snapshot() int { return 0 } 69 func (NoopStateDB) AddLog(*types.Log) {} 70 func (NoopStateDB) AddPreimage(common.Hash, []byte) {} 71 func (NoopStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) {} 72 73 func (NoopStateDB) ForEachStorageByteArray(common.Address, func(common.Hash, []byte) bool){} 74 func (NoopStateDB) GetStateByteArray(addr common.Address, hs common.Hash) []byte {return nil} 75 76 func (NoopStateDB) SetStateByteArray(common.Address, common.Hash, []byte) {}