noop.go 3.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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. package vm
  17. import (
  18. "math/big"
  19. "github.com/ethereum/go-ethereum/common"
  20. "github.com/ethereum/go-ethereum/core/types"
  21. )
  22. func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool {
  23. return true
  24. }
  25. func NoopTransfer(db StateDB, from, to common.Address, amount *big.Int) {}
  26. type NoopEVMCallContext struct{}
  27. func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
  28. return nil, nil
  29. }
  30. func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
  31. return nil, nil
  32. }
  33. func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) {
  34. return nil, common.Address{}, nil
  35. }
  36. func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) {
  37. return nil, nil
  38. }
  39. type NoopStateDB struct{}
  40. func (NoopStateDB) CreateAccount(common.Address) {}
  41. func (NoopStateDB) SubBalance(common.Address, *big.Int) {}
  42. func (NoopStateDB) AddBalance(common.Address, *big.Int) {}
  43. func (NoopStateDB) GetBalance(common.Address) *big.Int { return nil }
  44. func (NoopStateDB) GetNonce(common.Address) uint64 { return 0 }
  45. func (NoopStateDB) SetNonce(common.Address, uint64) {}
  46. func (NoopStateDB) GetCodeHash(common.Address) common.Hash { return common.Hash{} }
  47. func (NoopStateDB) GetCode(common.Address) []byte { return nil }
  48. func (NoopStateDB) SetCode(common.Address, []byte) {}
  49. func (NoopStateDB) GetCodeSize(common.Address) int { return 0 }
  50. func (NoopStateDB) AddRefund(uint64) {}
  51. func (NoopStateDB) GetRefund() uint64 { return 0 }
  52. func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash { return common.Hash{} }
  53. func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash) {}
  54. func (NoopStateDB) Suicide(common.Address) bool { return false }
  55. func (NoopStateDB) HasSuicided(common.Address) bool { return false }
  56. func (NoopStateDB) Exist(common.Address) bool { return false }
  57. func (NoopStateDB) Empty(common.Address) bool { return false }
  58. func (NoopStateDB) RevertToSnapshot(int) {}
  59. func (NoopStateDB) Snapshot() int { return 0 }
  60. func (NoopStateDB) AddLog(*types.Log) {}
  61. func (NoopStateDB) AddPreimage(common.Hash, []byte) {}
  62. func (NoopStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) {}