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
65a802c6
Commit
65a802c6
authored
Sep 22, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Re-wrote Call and Execute to use the new vm messages
parent
151f9c7f
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
21 deletions
+39
-21
js_pipe.go
ethpipe/js_pipe.go
+23
-7
pipe.go
ethpipe/pipe.go
+16
-14
No files found.
ethpipe/js_pipe.go
View file @
65a802c6
...
...
@@ -85,10 +85,6 @@ func (self *JSPipe) CoinBase() string {
return
ethutil
.
Bytes2Hex
(
self
.
obj
.
KeyManager
()
.
Address
())
}
func
(
self
*
JSPipe
)
BalanceAt
(
addr
string
)
string
{
return
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Balance
.
String
()
}
func
(
self
*
JSPipe
)
NumberToHuman
(
balance
string
)
string
{
b
:=
ethutil
.
Big
(
balance
)
...
...
@@ -101,10 +97,18 @@ func (self *JSPipe) StorageAt(addr, storageAddr string) string {
return
ethutil
.
Bytes2Hex
(
storage
.
Bytes
())
}
func
(
self
*
JSPipe
)
BalanceAt
(
addr
string
)
string
{
return
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Balance
.
String
()
}
func
(
self
*
JSPipe
)
TxCountAt
(
address
string
)
int
{
return
int
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Nonce
)
}
func
(
self
*
JSPipe
)
CodeAt
(
address
string
)
string
{
return
ethutil
.
Bytes2Hex
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Code
)
}
func
(
self
*
JSPipe
)
IsContract
(
address
string
)
bool
{
return
len
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Code
)
>
0
}
...
...
@@ -118,6 +122,18 @@ func (self *JSPipe) SecretToAddress(key string) string {
return
ethutil
.
Bytes2Hex
(
pair
.
Address
())
}
func
(
self
*
JSPipe
)
Execute
(
addr
,
value
,
gas
,
price
,
data
string
)
(
string
,
error
)
{
ret
,
err
:=
self
.
ExecuteObject
(
&
Object
{
self
.
World
()
.
safeGet
(
ethutil
.
Hex2Bytes
(
addr
))},
ethutil
.
Hex2Bytes
(
data
),
ethutil
.
NewValue
(
value
),
ethutil
.
NewValue
(
gas
),
ethutil
.
NewValue
(
price
),
)
return
ethutil
.
Bytes2Hex
(
ret
),
err
}
type
KeyVal
struct
{
Key
string
`json:"key"`
Value
string
`json:"value"`
...
...
ethpipe/pipe.go
View file @
65a802c6
package
ethpipe
import
(
"fmt"
"strings"
"github.com/ethereum/eth-go/ethchain"
...
...
@@ -51,18 +52,19 @@ func (self *Pipe) Execute(addr []byte, data []byte, value, gas, price *ethutil.V
func
(
self
*
Pipe
)
ExecuteObject
(
object
*
Object
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
var
(
initiator
=
ethstate
.
NewStateObject
([]
byte
{
0
}
)
initiator
=
ethstate
.
NewStateObject
(
self
.
obj
.
KeyManager
()
.
KeyPair
()
.
Address
()
)
block
=
self
.
blockChain
.
CurrentBlock
stateObject
=
object
.
StateObject
)
if
self
.
Vm
.
State
==
nil
{
self
.
Vm
.
State
=
self
.
World
()
.
State
()
.
Copy
()
}
vm
:=
ethvm
.
New
(
NewEnv
(
self
.
Vm
.
State
,
block
,
value
.
BigInt
(),
initiator
.
Address
()))
vm
.
Verbose
=
true
msg
:=
ethvm
.
NewMessage
(
vm
,
object
.
Address
(),
data
,
gas
.
BigInt
(),
price
.
BigInt
(),
value
.
BigInt
())
ret
,
err
:=
msg
.
Exec
(
object
.
Address
(),
initiator
)
closure
:=
ethvm
.
NewClosure
(
&
ethstate
.
Message
{},
initiator
,
stateObject
,
object
.
Code
,
gas
.
BigInt
(),
price
.
BigInt
())
ret
,
_
,
err
:=
closure
.
Call
(
vm
,
data
)
fmt
.
Println
(
"returned from call"
,
ret
,
err
)
return
ret
,
err
}
...
...
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