noop.go 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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) GetAccount(common.Address) Account { return nil }
  41. func (NoopStateDB) CreateAccount(common.Address) Account { return nil }
  42. func (NoopStateDB) SubBalance(common.Address, *big.Int) {}
  43. func (NoopStateDB) AddBalance(common.Address, *big.Int) {}
  44. func (NoopStateDB) GetBalance(common.Address) *big.Int { return nil }
  45. func (NoopStateDB) GetNonce(common.Address) uint64 { return 0 }
  46. func (NoopStateDB) SetNonce(common.Address, uint64) {}
  47. func (NoopStateDB) GetCodeHash(common.Address) common.Hash { return common.Hash{} }
  48. func (NoopStateDB) GetCode(common.Address) []byte { return nil }
  49. func (NoopStateDB) SetCode(common.Address, []byte) {}
  50. func (NoopStateDB) GetCodeSize(common.Address) int { return 0 }
  51. func (NoopStateDB) AddRefund(*big.Int) {}
  52. func (NoopStateDB) GetRefund() *big.Int { return nil }
  53. func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash { return common.Hash{} }
  54. func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash) {}
  55. func (NoopStateDB) Suicide(common.Address) bool { return false }
  56. func (NoopStateDB) HasSuicided(common.Address) bool { return false }
  57. func (NoopStateDB) Exist(common.Address) bool { return false }
  58. func (NoopStateDB) Empty(common.Address) bool { return false }
  59. func (NoopStateDB) RevertToSnapshot(int) {}
  60. func (NoopStateDB) Snapshot() int { return 0 }
  61. func (NoopStateDB) AddLog(*types.Log) {}