Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
bba4dcb7
Commit
bba4dcb7
authored
9 years ago
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1880 from Gustav-Simonsson/core_transfer
core, core/vm, cmd/evm: remove redundant balance check
parents
37abbcb5
e1616f77
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
10 additions
and
19 deletions
+10
-19
main.go
cmd/evm/main.go
+2
-2
execution.go
core/execution.go
+1
-8
environment.go
core/vm/environment.go
+1
-1
jit_test.go
core/vm/jit_test.go
+1
-3
vm_env.go
core/vm_env.go
+2
-2
util.go
tests/util.go
+3
-3
No files found.
cmd/evm/main.go
View file @
bba4dcb7
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
core/execution.go
View file @
bba4dcb7
...
...
@@ -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
}
This diff is collapsed.
Click to expand it.
core/vm/environment.go
View file @
bba4dcb7
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
core/vm/jit_test.go
View file @
bba4dcb7
...
...
@@ -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
}
...
...
This diff is collapsed.
Click to expand it.
core/vm_env.go
View file @
bba4dcb7
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
tests/util.go
View file @
bba4dcb7
...
...
@@ -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
)
{
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment