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
98f1ee94
Commit
98f1ee94
authored
Jun 25, 2014
by
zelig
Browse files
Options
Browse Files
Download
Plain Diff
merge upstream
parents
a02edf7a
b0dc50c2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
42 deletions
+11
-42
state_object.go
ethchain/state_object.go
+0
-1
vm.go
ethchain/vm.go
+7
-4
ethereum.go
ethereum.go
+0
-18
script.go
ethutil/script.go
+4
-19
No files found.
ethchain/state_object.go
View file @
98f1ee94
...
...
@@ -91,7 +91,6 @@ func (c *StateObject) SetAddr(addr []byte, value interface{}) {
func
(
c
*
StateObject
)
SetStorage
(
num
*
big
.
Int
,
val
*
ethutil
.
Value
)
{
addr
:=
ethutil
.
BigToBytes
(
num
,
256
)
// FIXME This should be handled in the Trie it self
if
val
.
BigInt
()
.
Cmp
(
ethutil
.
Big0
)
==
0
{
c
.
state
.
trie
.
Delete
(
string
(
addr
))
...
...
ethchain/vm.go
View file @
98f1ee94
...
...
@@ -109,11 +109,11 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
require
:=
func
(
m
int
)
{
if
stack
.
Len
()
<
m
{
isRequireError
=
true
panic
(
fmt
.
Sprintf
(
"stack = %d, req = %d"
,
stack
.
Len
(),
m
))
panic
(
fmt
.
Sprintf
(
"stack
err
= %d, req = %d"
,
stack
.
Len
(),
m
))
}
}
//
Instruction poi
nter
//
Program cou
nter
pc
:=
big
.
NewInt
(
0
)
// Current step count
step
:=
0
...
...
@@ -596,16 +596,18 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
// Generate a new address
addr
:=
ethutil
.
CreateAddress
(
closure
.
caller
.
Address
(),
closure
.
caller
.
N
())
vm
.
Printf
(
" (*) %x"
,
addr
)
.
Endl
()
// Create a new contract
contract
:=
vm
.
state
.
NewStateObject
(
addr
)
contract
.
Amount
=
value
// Set the init script
contract
.
initScript
=
mem
.
Get
(
offset
.
Int64
(),
size
.
Int64
()
)
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(gas)
// Create the closure
c
:=
NewClosure
(
closure
.
caller
,
...
...
@@ -616,6 +618,7 @@ func (vm *Vm) RunClosure(closure *Closure, hook DebugHook) (ret []byte, err erro
closure
.
Price
)
// Call the closure and set the return value as
// main script.
var
err
error
c
.
Script
,
gas
,
err
=
c
.
Call
(
vm
,
nil
,
hook
)
if
err
!=
nil
{
...
...
ethereum.go
View file @
98f1ee94
...
...
@@ -115,24 +115,6 @@ func New(caps Caps, usePnp bool) (*Ethereum, error) {
return
ethereum
,
nil
}
// Replay block
func
(
self
*
Ethereum
)
BlockDo
(
hash
[]
byte
)
error
{
block
:=
self
.
blockChain
.
GetBlock
(
hash
)
if
block
==
nil
{
return
fmt
.
Errorf
(
"unknown block %x"
,
hash
)
}
parent
:=
self
.
blockChain
.
GetBlock
(
block
.
PrevHash
)
_
,
err
:=
self
.
stateManager
.
ApplyDiff
(
parent
.
State
(),
parent
,
block
)
if
err
!=
nil
{
return
err
}
return
nil
}
func
(
s
*
Ethereum
)
Reactor
()
*
ethutil
.
ReactorEngine
{
return
s
.
reactor
}
...
...
ethutil/script.go
View file @
98f1ee94
...
...
@@ -3,6 +3,7 @@ package ethutil
import
(
"fmt"
"github.com/obscuren/mutan"
"github.com/obscuren/mutan/backends"
"github.com/obscuren/serpent-go"
"strings"
)
...
...
@@ -19,7 +20,9 @@ func Compile(script string) (ret []byte, err error) {
return
byteCode
,
nil
}
else
{
byteCode
,
errors
:=
mutan
.
Compile
(
strings
.
NewReader
(
script
),
false
)
compiler
:=
mutan
.
NewCompiler
(
backend
.
NewEthereumBackend
())
byteCode
,
errors
:=
compiler
.
Compile
(
strings
.
NewReader
(
script
))
//byteCode, errors := mutan.Compile(strings.NewReader(script), false)
if
len
(
errors
)
>
0
{
var
errs
string
for
_
,
er
:=
range
errors
{
...
...
@@ -33,21 +36,3 @@ func Compile(script string) (ret []byte, err error) {
return
byteCode
,
nil
}
}
func
CompileScript
(
script
string
)
([]
byte
,
[]
byte
,
error
)
{
// Preprocess
mainInput
,
initInput
:=
mutan
.
PreParse
(
script
)
// Compile main script
mainScript
,
err
:=
Compile
(
mainInput
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
// Compile init script
initScript
,
err
:=
Compile
(
initInput
)
if
err
!=
nil
{
return
nil
,
nil
,
err
}
return
mainScript
,
initScript
,
nil
}
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