github.com/sberex/go-sberex@v1.8.2-0.20181113200658-ed96ac38f7d7/core/vm/noop.go (about)

     1  // This file is part of the go-sberex library. The go-sberex library is 
     2  // free software: you can redistribute it and/or modify it under the terms 
     3  // of the GNU Lesser General Public License as published by the Free 
     4  // Software Foundation, either version 3 of the License, or (at your option)
     5  // any later version.
     6  //
     7  // The go-sberex library is distributed in the hope that it will be useful, 
     8  // but WITHOUT ANY WARRANTY; without even the implied warranty of
     9  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser 
    10  // General Public License <http://www.gnu.org/licenses/> for more details.
    11  
    12  package vm
    13  
    14  import (
    15  	"math/big"
    16  
    17  	"github.com/Sberex/go-sberex/common"
    18  	"github.com/Sberex/go-sberex/core/types"
    19  )
    20  
    21  func NoopCanTransfer(db StateDB, from common.Address, balance *big.Int) bool {
    22  	return true
    23  }
    24  func NoopTransfer(db StateDB, from, to common.Address, amount *big.Int) {}
    25  
    26  type NoopEVMCallContext struct{}
    27  
    28  func (NoopEVMCallContext) Call(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
    29  	return nil, nil
    30  }
    31  func (NoopEVMCallContext) CallCode(caller ContractRef, addr common.Address, data []byte, gas, value *big.Int) ([]byte, error) {
    32  	return nil, nil
    33  }
    34  func (NoopEVMCallContext) Create(caller ContractRef, data []byte, gas, value *big.Int) ([]byte, common.Address, error) {
    35  	return nil, common.Address{}, nil
    36  }
    37  func (NoopEVMCallContext) DelegateCall(me ContractRef, addr common.Address, data []byte, gas *big.Int) ([]byte, error) {
    38  	return nil, nil
    39  }
    40  
    41  type NoopStateDB struct{}
    42  
    43  func (NoopStateDB) CreateAccount(common.Address)                                       {}
    44  func (NoopStateDB) SubBalance(common.Address, *big.Int)                                {}
    45  func (NoopStateDB) AddBalance(common.Address, *big.Int)                                {}
    46  func (NoopStateDB) GetBalance(common.Address) *big.Int                                 { return nil }
    47  func (NoopStateDB) GetNonce(common.Address) uint64                                     { return 0 }
    48  func (NoopStateDB) SetNonce(common.Address, uint64)                                    {}
    49  func (NoopStateDB) GetCodeHash(common.Address) common.Hash                             { return common.Hash{} }
    50  func (NoopStateDB) GetCode(common.Address) []byte                                      { return nil }
    51  func (NoopStateDB) SetCode(common.Address, []byte)                                     {}
    52  func (NoopStateDB) GetCodeSize(common.Address) int                                     { return 0 }
    53  func (NoopStateDB) AddRefund(uint64)                                                   {}
    54  func (NoopStateDB) GetRefund() uint64                                                  { return 0 }
    55  func (NoopStateDB) GetState(common.Address, common.Hash) common.Hash                   { return common.Hash{} }
    56  func (NoopStateDB) SetState(common.Address, common.Hash, common.Hash)                  {}
    57  func (NoopStateDB) Suicide(common.Address) bool                                        { return false }
    58  func (NoopStateDB) HasSuicided(common.Address) bool                                    { return false }
    59  func (NoopStateDB) Exist(common.Address) bool                                          { return false }
    60  func (NoopStateDB) Empty(common.Address) bool                                          { return false }
    61  func (NoopStateDB) RevertToSnapshot(int)                                               {}
    62  func (NoopStateDB) Snapshot() int                                                      { return 0 }
    63  func (NoopStateDB) AddLog(*types.Log)                                                  {}
    64  func (NoopStateDB) AddPreimage(common.Hash, []byte)                                    {}
    65  func (NoopStateDB) ForEachStorage(common.Address, func(common.Hash, common.Hash) bool) {}