diff options
author | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-10-06 18:35:05 +0800 |
---|---|---|
committer | Gustav Simonsson <gustav.simonsson@gmail.com> | 2015-10-06 18:42:34 +0800 |
commit | e1616f77c7fb348f6b171b608d036f2bd4e34cc3 (patch) | |
tree | 580e923bedf622c5b872ef2d23cb62fcd98a22b8 | |
parent | 44fd3951410fb5923d7e578ac97942a7ea791e96 (diff) | |
download | go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar.gz go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar.bz2 go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar.lz go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar.xz go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.tar.zst go-tangerine-e1616f77c7fb348f6b171b608d036f2bd4e34cc3.zip |
core, core/vm, cmd/evm: remove redundant balance check
-rw-r--r-- | cmd/evm/main.go | 4 | ||||
-rw-r--r-- | core/execution.go | 9 | ||||
-rw-r--r-- | core/vm/environment.go | 2 | ||||
-rw-r--r-- | core/vm/jit_test.go | 4 | ||||
-rw-r--r-- | core/vm_env.go | 4 | ||||
-rw-r--r-- | tests/util.go | 6 |
6 files changed, 10 insertions, 19 deletions
diff --git a/cmd/evm/main.go b/cmd/evm/main.go index bf24da982..e170dc190 100644 --- a/cmd/evm/main.go +++ b/cmd/evm/main.go @@ -217,8 +217,8 @@ func (self *VMEnv) AddLog(log *vm.Log) { func (self *VMEnv) CanTransfer(from common.Address, balance *big.Int) bool { return self.state.GetBalance(from).Cmp(balance) >= 0 } -func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error { - return core.Transfer(from, to, amount) +func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) { + core.Transfer(from, to, amount) } func (self *VMEnv) Call(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) { diff --git a/core/execution.go b/core/execution.go index e3c00a2ea..fd8464f6e 100644 --- a/core/execution.go +++ b/core/execution.go @@ -17,7 +17,6 @@ package core import ( - "errors" "math/big" "github.com/ethereum/go-ethereum/common" @@ -108,13 +107,7 @@ func exec(env vm.Environment, caller vm.ContractRef, address, codeAddr *common.A } // generic transfer method -func Transfer(from, to vm.Account, amount *big.Int) error { - if from.Balance().Cmp(amount) < 0 { - return errors.New("Insufficient balance in account") - } - +func Transfer(from, to vm.Account, amount *big.Int) { from.SubBalance(amount) to.AddBalance(amount) - - return nil } diff --git a/core/vm/environment.go b/core/vm/environment.go index f8e19baea..ec739b26c 100644 --- a/core/vm/environment.go +++ b/core/vm/environment.go @@ -51,7 +51,7 @@ type Environment interface { // Determines whether it's possible to transact CanTransfer(from common.Address, balance *big.Int) bool // Transfers amount from one account to the other - Transfer(from, to Account, amount *big.Int) error + Transfer(from, to Account, amount *big.Int) // Adds a LOG to the state AddLog(*Log) // Adds a structured log to the env diff --git a/core/vm/jit_test.go b/core/vm/jit_test.go index 8c45f2ce7..cb09e179d 100644 --- a/core/vm/jit_test.go +++ b/core/vm/jit_test.go @@ -152,9 +152,7 @@ func (self *Env) SetDepth(i int) { self.depth = i } func (self *Env) CanTransfer(from common.Address, balance *big.Int) bool { return true } -func (self *Env) Transfer(from, to Account, amount *big.Int) error { - return nil -} +func (self *Env) Transfer(from, to Account, amount *big.Int) {} func (self *Env) Call(caller ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) { return nil, nil } diff --git a/core/vm_env.go b/core/vm_env.go index 467e34c6b..715fde52f 100644 --- a/core/vm_env.go +++ b/core/vm_env.go @@ -81,8 +81,8 @@ func (self *VMEnv) SetSnapshot(copy vm.Database) { self.state.Set(copy.(*state.StateDB)) } -func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) error { - return Transfer(from, to, amount) +func (self *VMEnv) Transfer(from, to vm.Account, amount *big.Int) { + Transfer(from, to, amount) } func (self *VMEnv) Call(me vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) { diff --git a/tests/util.go b/tests/util.go index fb9e518c8..bbc671169 100644 --- a/tests/util.go +++ b/tests/util.go @@ -209,11 +209,11 @@ func (self *Env) SetSnapshot(copy vm.Database) { self.state.Set(copy.(*state.StateDB)) } -func (self *Env) Transfer(from, to vm.Account, amount *big.Int) error { +func (self *Env) Transfer(from, to vm.Account, amount *big.Int) { if self.skipTransfer { - return nil + return } - return core.Transfer(from, to, amount) + core.Transfer(from, to, amount) } func (self *Env) Call(caller vm.ContractRef, addr common.Address, data []byte, gas, price, value *big.Int) ([]byte, error) { |