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
40e3d2ab
Commit
40e3d2ab
authored
Jul 02, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changed CREATE
parent
6748158a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
24 deletions
+35
-24
vm.go
ethchain/vm.go
+35
-24
No files found.
ethchain/vm.go
View file @
40e3d2ab
...
...
@@ -617,48 +617,59 @@ func (vm *Vm) RunClosure(closure *Closure) (ret []byte, err error) {
case
CREATE
:
require
(
3
)
value
:=
stack
.
Pop
()
size
,
offset
:=
stack
.
Popn
()
var
(
err
error
value
=
stack
.
Pop
()
size
,
offset
=
stack
.
Popn
()
// Snapshot the current stack so we are able to
// revert back to it later.
snapshot
:=
vm
.
state
.
Copy
()
// Snapshot the current stack so we are able to
// revert back to it later.
snapshot
=
vm
.
state
.
Copy
()
)
// Generate a new address
addr
:=
ethcrypto
.
CreateAddress
(
closure
.
caller
.
Address
(),
closure
.
caller
.
N
())
for
i
:=
int64
(
0
);
vm
.
state
.
GetStateObject
(
addr
)
!=
nil
;
i
++
{
t
:=
new
(
big
.
Int
)
.
Set
(
closure
.
caller
.
N
())
addr
=
ethcrypto
.
CreateAddress
(
closure
.
caller
.
Address
(),
t
.
Add
(
t
,
big
.
NewInt
(
i
)))
}
vm
.
Printf
(
" (*) %x"
,
addr
)
.
Endl
()
// Create a new contract
contract
:=
vm
.
state
.
NewStateObject
(
addr
)
contract
.
Amount
=
value
// Set the init script
contract
.
initScript
=
ethutil
.
BigD
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()))
.
Bytes
()
// Transfer all remaining gas to the new
// contract so it may run the init script
gas
:=
new
(
big
.
Int
)
.
Set
(
closure
.
Gas
)
// Create the closure
c
:=
NewClosure
(
closure
.
caller
,
closure
.
Object
(),
contract
.
initScript
,
vm
.
state
,
gas
,
closure
.
Price
)
// Call the closure and set the return value as
// main script.
var
err
error
c
.
Script
,
gas
,
err
=
c
.
Call
(
vm
,
nil
)
if
contract
.
Amount
.
Cmp
(
value
)
>=
0
{
closure
.
object
.
SubAmount
(
value
)
contract
.
AddAmount
(
value
)
// Set the init script
contract
.
initScript
=
ethutil
.
BigD
(
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()))
.
Bytes
()
// Transfer all remaining gas to the new
// contract so it may run the init script
gas
:=
new
(
big
.
Int
)
.
Set
(
closure
.
Gas
)
closure
.
UseGas
(
closure
.
Gas
)
// Create the closure
c
:=
NewClosure
(
closure
,
contract
,
contract
.
initScript
,
vm
.
state
,
gas
,
closure
.
Price
)
// Call the closure and set the return value as
// main script.
c
.
Script
,
err
,
_
=
Call
(
vm
,
c
,
nil
)
}
else
{
err
=
fmt
.
Errorf
(
"Insufficient funds to transfer value. Req %v, has %v"
,
value
,
closure
.
object
.
Amount
)
}
if
err
!=
nil
{
stack
.
Push
(
ethutil
.
BigFalse
)
// Revert the state as it was before.
vm
.
state
.
Set
(
snapshot
)
vm
.
Printf
(
"CREATE err %v"
,
err
)
}
else
{
stack
.
Push
(
ethutil
.
BigD
(
addr
))
vm
.
Printf
(
"CREATE success"
)
}
vm
.
Endl
()
case
CALL
:
require
(
7
)
...
...
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