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
0ed1a8b5
Commit
0ed1a8b5
authored
Oct 31, 2014
by
obscuren
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ethpipe => xeth (eXtended ETHereum)
parent
8826e969
Changes
19
Hide whitespace changes
Inline
Side-by-side
Showing
19 changed files
with
112 additions
and
108 deletions
+112
-108
bindings.go
cmd/mist/bindings.go
+2
-2
ext_app.go
cmd/mist/ext_app.go
+3
-3
gui.go
cmd/mist/gui.go
+11
-11
html_container.go
cmd/mist/html_container.go
+2
-2
qml_container.go
cmd/mist/qml_container.go
+2
-2
ui_lib.go
cmd/mist/ui_lib.go
+8
-8
cmd.go
cmd/utils/cmd.go
+2
-2
websockets.go
cmd/utils/websockets.go
+2
-2
javascript_runtime.go
javascript/javascript_runtime.go
+3
-3
types.go
javascript/types.go
+11
-11
packages.go
rpc/packages.go
+2
-2
server.go
rpc/server.go
+3
-3
config.go
xeth/config.go
+2
-2
hexface.go
xeth/hexface.go
+31
-31
js_types.go
xeth/js_types.go
+1
-1
object.go
xeth/object.go
+1
-1
pipe.go
xeth/pipe.go
+21
-17
vm_env.go
xeth/vm_env.go
+1
-1
world.go
xeth/world.go
+4
-4
No files found.
cmd/mist/bindings.go
View file @
0ed1a8b5
...
...
@@ -24,9 +24,9 @@ import (
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/xeth"
)
type
plugin
struct
{
...
...
@@ -46,7 +46,7 @@ func (gui *Gui) LogPrint(level logger.LogLevel, msg string) {
}
*/
}
func
(
gui
*
Gui
)
Transact
(
recipient
,
value
,
gas
,
gasPrice
,
d
string
)
(
*
ethpipe
.
JSReceipt
,
error
)
{
func
(
gui
*
Gui
)
Transact
(
recipient
,
value
,
gas
,
gasPrice
,
d
string
)
(
*
xeth
.
JSReceipt
,
error
)
{
var
data
string
if
len
(
recipient
)
==
0
{
code
,
err
:=
ethutil
.
Compile
(
d
,
false
)
...
...
cmd/mist/ext_app.go
View file @
0ed1a8b5
...
...
@@ -21,11 +21,11 @@ import (
"encoding/json"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/ui/qt"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/qml.v1"
)
...
...
@@ -43,7 +43,7 @@ type AppContainer interface {
}
type
ExtApplication
struct
{
*
ethpipe
.
JSPipe
*
xeth
.
JSXEth
eth
chain
.
EthManager
events
event
.
Subscription
...
...
@@ -57,7 +57,7 @@ type ExtApplication struct {
func
NewExtApplication
(
container
AppContainer
,
lib
*
UiLib
)
*
ExtApplication
{
return
&
ExtApplication
{
JS
Pipe
:
ethpipe
.
NewJSPipe
(
lib
.
eth
),
JS
XEth
:
xeth
.
NewJSXEth
(
lib
.
eth
),
eth
:
lib
.
eth
,
watcherQuitChan
:
make
(
chan
bool
),
filters
:
make
(
map
[
string
]
*
chain
.
Filter
),
...
...
cmd/mist/gui.go
View file @
0ed1a8b5
...
...
@@ -34,10 +34,10 @@ import (
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethminer"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethwire"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/qml.v1"
)
...
...
@@ -84,7 +84,7 @@ type Gui struct {
logLevel
logger
.
LogLevel
open
bool
pipe
*
ethpipe
.
JSPipe
pipe
*
xeth
.
JSXEth
Session
string
clientIdentity
*
ethwire
.
SimpleClientIdentity
...
...
@@ -103,7 +103,7 @@ func NewWindow(ethereum *eth.Ethereum, config *ethutil.ConfigManager, clientIden
panic
(
err
)
}
pipe
:=
ethpipe
.
NewJSPipe
(
ethereum
)
pipe
:=
xeth
.
NewJSXEth
(
ethereum
)
gui
:=
&
Gui
{
eth
:
ethereum
,
txDb
:
db
,
pipe
:
pipe
,
logLevel
:
logger
.
LogLevel
(
logLevel
),
Session
:
session
,
open
:
false
,
clientIdentity
:
clientIdentity
,
config
:
config
,
plugins
:
make
(
map
[
string
]
plugin
)}
data
,
_
:=
ethutil
.
ReadAllFile
(
path
.
Join
(
ethutil
.
Config
.
ExecPath
,
"plugins.json"
))
json
.
Unmarshal
([]
byte
(
data
),
&
gui
.
plugins
)
...
...
@@ -117,11 +117,11 @@ func (gui *Gui) Start(assetPath string) {
// Register ethereum functions
qml
.
RegisterTypes
(
"Ethereum"
,
1
,
0
,
[]
qml
.
TypeSpec
{{
Init
:
func
(
p
*
ethpipe
.
JSBlock
,
obj
qml
.
Object
)
{
p
.
Number
=
0
;
p
.
Hash
=
""
},
Init
:
func
(
p
*
xeth
.
JSBlock
,
obj
qml
.
Object
)
{
p
.
Number
=
0
;
p
.
Hash
=
""
},
},
{
Init
:
func
(
p
*
ethpipe
.
JSTransaction
,
obj
qml
.
Object
)
{
p
.
Value
=
""
;
p
.
Hash
=
""
;
p
.
Address
=
""
},
Init
:
func
(
p
*
xeth
.
JSTransaction
,
obj
qml
.
Object
)
{
p
.
Value
=
""
;
p
.
Hash
=
""
;
p
.
Address
=
""
},
},
{
Init
:
func
(
p
*
ethpipe
.
KeyVal
,
obj
qml
.
Object
)
{
p
.
Key
=
""
;
p
.
Value
=
""
},
Init
:
func
(
p
*
xeth
.
KeyVal
,
obj
qml
.
Object
)
{
p
.
Key
=
""
;
p
.
Value
=
""
},
}})
// Create a new QML engine
gui
.
engine
=
qml
.
NewEngine
()
...
...
@@ -287,7 +287,7 @@ func (gui *Gui) loadAddressBook() {
}
func
(
gui
*
Gui
)
insertTransaction
(
window
string
,
tx
*
chain
.
Transaction
)
{
pipe
:=
ethpipe
.
New
(
gui
.
eth
)
pipe
:=
xeth
.
New
(
gui
.
eth
)
nameReg
:=
pipe
.
World
()
.
Config
()
.
Get
(
"NameReg"
)
addr
:=
gui
.
address
()
...
...
@@ -299,7 +299,7 @@ func (gui *Gui) insertTransaction(window string, tx *chain.Transaction) {
}
var
(
ptx
=
ethpipe
.
NewJSTx
(
tx
,
pipe
.
World
()
.
State
())
ptx
=
xeth
.
NewJSTx
(
tx
,
pipe
.
World
()
.
State
())
send
=
nameReg
.
Storage
(
tx
.
Sender
())
rec
=
nameReg
.
Storage
(
tx
.
Recipient
)
s
,
r
string
...
...
@@ -346,7 +346,7 @@ func (gui *Gui) readPreviousTransactions() {
func
(
gui
*
Gui
)
processBlock
(
block
*
chain
.
Block
,
initial
bool
)
{
name
:=
strings
.
Trim
(
gui
.
pipe
.
World
()
.
Config
()
.
Get
(
"NameReg"
)
.
Storage
(
block
.
Coinbase
)
.
Str
(),
"
\x00
"
)
b
:=
ethpipe
.
NewJSBlock
(
block
)
b
:=
xeth
.
NewJSBlock
(
block
)
b
.
Name
=
name
gui
.
getObjectByName
(
"chainView"
)
.
Call
(
"addBlock"
,
b
,
initial
)
...
...
@@ -451,12 +451,12 @@ func (gui *Gui) update() {
if
bytes
.
Compare
(
tx
.
Sender
(),
gui
.
address
())
==
0
{
object
.
SubAmount
(
tx
.
Value
)
//gui.getObjectByName("transactionView").Call("addTx",
ethpipe
.NewJSTx(tx), "send")
//gui.getObjectByName("transactionView").Call("addTx",
xeth
.NewJSTx(tx), "send")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
else
if
bytes
.
Compare
(
tx
.
Recipient
,
gui
.
address
())
==
0
{
object
.
AddAmount
(
tx
.
Value
)
//gui.getObjectByName("transactionView").Call("addTx",
ethpipe
.NewJSTx(tx), "recv")
//gui.getObjectByName("transactionView").Call("addTx",
xeth
.NewJSTx(tx), "recv")
gui
.
txDb
.
Put
(
tx
.
Hash
(),
tx
.
RlpEncode
())
}
...
...
cmd/mist/html_container.go
View file @
0ed1a8b5
...
...
@@ -28,10 +28,10 @@ import (
"path/filepath"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/xeth"
"github.com/howeyc/fsnotify"
"gopkg.in/qml.v1"
)
...
...
@@ -139,7 +139,7 @@ func (app *HtmlApplication) Window() *qml.Window {
}
func
(
app
*
HtmlApplication
)
NewBlock
(
block
*
chain
.
Block
)
{
b
:=
&
ethpipe
.
JSBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
())}
b
:=
&
xeth
.
JSBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
())}
app
.
webView
.
Call
(
"onNewBlockCb"
,
b
)
}
...
...
cmd/mist/qml_container.go
View file @
0ed1a8b5
...
...
@@ -22,9 +22,9 @@ import (
"runtime"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/qml.v1"
)
...
...
@@ -66,7 +66,7 @@ func (app *QmlApplication) NewWatcher(quitChan chan bool) {
// Events
func
(
app
*
QmlApplication
)
NewBlock
(
block
*
chain
.
Block
)
{
pblock
:=
&
ethpipe
.
JSBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
())}
pblock
:=
&
xeth
.
JSBlock
{
Number
:
int
(
block
.
BlockInfo
()
.
Number
),
Hash
:
ethutil
.
Bytes2Hex
(
block
.
Hash
())}
app
.
win
.
Call
(
"onNewBlockCb"
,
pblock
)
}
...
...
cmd/mist/ui_lib.go
View file @
0ed1a8b5
...
...
@@ -27,11 +27,11 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/javascript"
"github.com/ethereum/go-ethereum/ui/qt"
"github.com/ethereum/go-ethereum/xeth"
"gopkg.in/qml.v1"
)
...
...
@@ -42,7 +42,7 @@ type memAddr struct {
// UI Library that has some basic functionality exposed
type
UiLib
struct
{
*
ethpipe
.
JSPipe
*
xeth
.
JSXEth
engine
*
qml
.
Engine
eth
*
eth
.
Ethereum
connected
bool
...
...
@@ -58,7 +58,7 @@ type UiLib struct {
}
func
NewUiLib
(
engine
*
qml
.
Engine
,
eth
*
eth
.
Ethereum
,
assetPath
string
)
*
UiLib
{
return
&
UiLib
{
JS
Pipe
:
ethpipe
.
NewJSPipe
(
eth
),
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
eth
),
filterCallbacks
:
make
(
map
[
int
][]
int
)}
//, filters: make(map[int]*ethpipe
.JSFilter)}
return
&
UiLib
{
JS
XEth
:
xeth
.
NewJSXEth
(
eth
),
engine
:
engine
,
eth
:
eth
,
assetPath
:
assetPath
,
jsEngine
:
javascript
.
NewJSRE
(
eth
),
filterCallbacks
:
make
(
map
[
int
][]
int
)}
//, filters: make(map[int]*xeth
.JSFilter)}
}
func
(
self
*
UiLib
)
Notef
(
args
[]
interface
{})
{
...
...
@@ -214,7 +214,7 @@ func (self *UiLib) StartDebugger() {
func
(
self
*
UiLib
)
NewFilter
(
object
map
[
string
]
interface
{})
(
id
int
)
{
filter
:=
qt
.
NewFilterFromMap
(
object
,
self
.
eth
)
filter
.
MessageCallback
=
func
(
messages
ethstate
.
Messages
)
{
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
ethpipe
.
ToJSMessages
(
messages
),
id
)
self
.
win
.
Root
()
.
Call
(
"invokeFilterCallback"
,
xeth
.
ToJSMessages
(
messages
),
id
)
}
id
=
self
.
eth
.
InstallFilter
(
filter
)
return
id
...
...
@@ -232,7 +232,7 @@ func (self *UiLib) NewFilterString(typ string) (id int) {
func
(
self
*
UiLib
)
Messages
(
id
int
)
*
ethutil
.
List
{
filter
:=
self
.
eth
.
GetFilter
(
id
)
if
filter
!=
nil
{
messages
:=
ethpipe
.
ToJSMessages
(
filter
.
Find
())
messages
:=
xeth
.
ToJSMessages
(
filter
.
Find
())
return
messages
}
...
...
@@ -295,10 +295,10 @@ func mapToTxParams(object map[string]interface{}) map[string]string {
return
conv
}
func
(
self
*
UiLib
)
Transact
(
params
map
[
string
]
interface
{})
(
*
ethpipe
.
JSReceipt
,
error
)
{
func
(
self
*
UiLib
)
Transact
(
params
map
[
string
]
interface
{})
(
*
xeth
.
JSReceipt
,
error
)
{
object
:=
mapToTxParams
(
params
)
return
self
.
JS
Pipe
.
Transact
(
return
self
.
JS
XEth
.
Transact
(
object
[
"from"
],
object
[
"to"
],
object
[
"value"
],
...
...
@@ -320,7 +320,7 @@ func (self *UiLib) Compile(code string) (string, error) {
func
(
self
*
UiLib
)
Call
(
params
map
[
string
]
interface
{})
(
string
,
error
)
{
object
:=
mapToTxParams
(
params
)
return
self
.
JS
Pipe
.
Execute
(
return
self
.
JS
XEth
.
Execute
(
object
[
"to"
],
object
[
"value"
],
object
[
"gas"
],
...
...
cmd/utils/cmd.go
View file @
0ed1a8b5
...
...
@@ -17,11 +17,11 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/ethminer"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ethwire"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/xeth"
)
var
clilogger
=
logger
.
NewLogger
(
"CLI"
)
...
...
@@ -244,7 +244,7 @@ func KeyTasks(keyManager *crypto.KeyManager, KeyRing string, GenAddr bool, Secre
func
StartRpc
(
ethereum
*
eth
.
Ethereum
,
RpcPort
int
)
{
var
err
error
ethereum
.
RpcServer
,
err
=
rpc
.
NewJsonRpcServer
(
ethpipe
.
NewJSPipe
(
ethereum
),
RpcPort
)
ethereum
.
RpcServer
,
err
=
rpc
.
NewJsonRpcServer
(
xeth
.
NewJSXEth
(
ethereum
),
RpcPort
)
if
err
!=
nil
{
clilogger
.
Errorf
(
"Could not start RPC interface (port %v): %v"
,
RpcPort
,
err
)
}
else
{
...
...
cmd/utils/websockets.go
View file @
0ed1a8b5
...
...
@@ -2,9 +2,9 @@ package utils
import
(
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/websocket"
"github.com/ethereum/go-ethereum/xeth"
)
func
args
(
v
...
interface
{})
[]
interface
{}
{
...
...
@@ -21,7 +21,7 @@ func NewWebSocketServer(eth *eth.Ethereum) *WebSocketServer {
}
func
(
self
*
WebSocketServer
)
Serv
()
{
pipe
:=
ethpipe
.
NewJSPipe
(
self
.
ethereum
)
pipe
:=
xeth
.
NewJSXEth
(
self
.
ethereum
)
wsServ
:=
websocket
.
NewServer
(
"/eth"
,
":40404"
)
wsServ
.
MessageFunc
(
func
(
c
*
websocket
.
Client
,
msg
*
websocket
.
Message
)
{
...
...
javascript/javascript_runtime.go
View file @
0ed1a8b5
...
...
@@ -10,11 +10,11 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/chain"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/xeth"
"github.com/obscuren/otto"
)
...
...
@@ -23,7 +23,7 @@ var jsrelogger = logger.NewLogger("JSRE")
type
JSRE
struct
{
ethereum
*
eth
.
Ethereum
Vm
*
otto
.
Otto
pipe
*
ethpipe
.
JSPipe
pipe
*
xeth
.
JSXEth
events
event
.
Subscription
...
...
@@ -48,7 +48,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
re
:=
&
JSRE
{
ethereum
,
otto
.
New
(),
ethpipe
.
NewJSPipe
(
ethereum
),
xeth
.
NewJSXEth
(
ethereum
),
nil
,
make
(
map
[
string
][]
otto
.
Value
),
}
...
...
javascript/types.go
View file @
0ed1a8b5
...
...
@@ -4,15 +4,15 @@ import (
"fmt"
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethstate"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/ui"
"github.com/ethereum/go-ethereum/xeth"
"github.com/obscuren/otto"
)
type
JSStateObject
struct
{
*
ethpipe
.
JSObject
*
xeth
.
JSObject
eth
*
JSEthereum
}
...
...
@@ -30,7 +30,7 @@ func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value {
// The JSEthereum object attempts to wrap the PEthereum object and returns
// meaningful javascript objects
type
JSBlock
struct
{
*
ethpipe
.
JSBlock
*
xeth
.
JSBlock
eth
*
JSEthereum
}
...
...
@@ -67,33 +67,33 @@ func NewJSMessage(message *ethstate.Message) JSMessage {
}
type
JSEthereum
struct
{
*
ethpipe
.
JSPipe
*
xeth
.
JSXEth
vm
*
otto
.
Otto
ethereum
*
eth
.
Ethereum
}
func
(
self
*
JSEthereum
)
GetBlock
(
hash
string
)
otto
.
Value
{
return
self
.
toVal
(
&
JSBlock
{
self
.
JS
Pipe
.
BlockByHash
(
hash
),
self
})
return
self
.
toVal
(
&
JSBlock
{
self
.
JS
XEth
.
BlockByHash
(
hash
),
self
})
}
func
(
self
*
JSEthereum
)
GetPeers
()
otto
.
Value
{
return
self
.
toVal
(
self
.
JS
Pipe
.
Peers
())
return
self
.
toVal
(
self
.
JS
XEth
.
Peers
())
}
func
(
self
*
JSEthereum
)
GetKey
()
otto
.
Value
{
return
self
.
toVal
(
self
.
JS
Pipe
.
Key
())
return
self
.
toVal
(
self
.
JS
XEth
.
Key
())
}
func
(
self
*
JSEthereum
)
GetStateObject
(
addr
string
)
otto
.
Value
{
return
self
.
toVal
(
&
JSStateObject
{
ethpipe
.
NewJSObject
(
self
.
JSPipe
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))),
self
})
return
self
.
toVal
(
&
JSStateObject
{
xeth
.
NewJSObject
(
self
.
JSXEth
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))),
self
})
}
func
(
self
*
JSEthereum
)
Peers
()
otto
.
Value
{
return
self
.
toVal
(
self
.
JS
Pipe
.
Peers
())
return
self
.
toVal
(
self
.
JS
XEth
.
Peers
())
}
func
(
self
*
JSEthereum
)
Transact
(
key
,
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
string
)
otto
.
Value
{
r
,
err
:=
self
.
JS
Pipe
.
Transact
(
key
,
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
)
r
,
err
:=
self
.
JS
XEth
.
Transact
(
key
,
recipient
,
valueStr
,
gasStr
,
gasPriceStr
,
dataStr
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
...
...
@@ -104,7 +104,7 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr,
}
func
(
self
*
JSEthereum
)
Create
(
key
,
valueStr
,
gasStr
,
gasPriceStr
,
scriptStr
string
)
otto
.
Value
{
r
,
err
:=
self
.
JS
Pipe
.
Transact
(
key
,
""
,
valueStr
,
gasStr
,
gasPriceStr
,
scriptStr
)
r
,
err
:=
self
.
JS
XEth
.
Transact
(
key
,
""
,
valueStr
,
gasStr
,
gasPriceStr
,
scriptStr
)
if
err
!=
nil
{
fmt
.
Println
(
err
)
...
...
rpc/packages.go
View file @
0ed1a8b5
...
...
@@ -6,12 +6,12 @@ import (
"math/big"
"strings"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/ethutil"
"github.com/ethereum/go-ethereum/xeth"
)
type
EthereumApi
struct
{
pipe
*
ethpipe
.
JSPipe
pipe
*
xeth
.
JSXEth
}
type
JsonArgs
interface
{
...
...
rpc/server.go
View file @
0ed1a8b5
...
...
@@ -6,8 +6,8 @@ import (
"net/rpc"
"net/rpc/jsonrpc"
"github.com/ethereum/go-ethereum/ethpipe"
"github.com/ethereum/go-ethereum/logger"
"github.com/ethereum/go-ethereum/xeth"
)
var
jsonlogger
=
logger
.
NewLogger
(
"JSON"
)
...
...
@@ -15,7 +15,7 @@ var jsonlogger = logger.NewLogger("JSON")
type
JsonRpcServer
struct
{
quit
chan
bool
listener
net
.
Listener
pipe
*
ethpipe
.
JSPipe
pipe
*
xeth
.
JSXEth
}
func
(
s
*
JsonRpcServer
)
exitHandler
()
{
...
...
@@ -52,7 +52,7 @@ func (s *JsonRpcServer) Start() {
}
}
func
NewJsonRpcServer
(
pipe
*
ethpipe
.
JSPipe
,
port
int
)
(
*
JsonRpcServer
,
error
)
{
func
NewJsonRpcServer
(
pipe
*
xeth
.
JSXEth
,
port
int
)
(
*
JsonRpcServer
,
error
)
{
sport
:=
fmt
.
Sprintf
(
":%d"
,
port
)
l
,
err
:=
net
.
Listen
(
"tcp"
,
sport
)
if
err
!=
nil
{
...
...
ethpipe
/config.go
→
xeth
/config.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
"github.com/ethereum/go-ethereum/ethutil"
var
cnfCtr
=
ethutil
.
Hex2Bytes
(
"661005d2720d855f1d9976f88bb10c1a3398c77f"
)
type
Config
struct
{
pipe
*
Pipe
pipe
*
XEth
}
func
(
self
*
Config
)
Get
(
name
string
)
*
Object
{
...
...
ethpipe/js_pip
e.go
→
xeth/hexfac
e.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
(
"bytes"
...
...
@@ -11,22 +11,22 @@ import (
"github.com/ethereum/go-ethereum/ethutil"
)
type
JS
Pipe
struct
{
*
Pipe
type
JS
XEth
struct
{
*
XEth
}
func
NewJS
Pipe
(
eth
chain
.
EthManager
)
*
JSPipe
{
return
&
JS
Pipe
{
New
(
eth
)}
func
NewJS
XEth
(
eth
chain
.
EthManager
)
*
JSXEth
{
return
&
JS
XEth
{
New
(
eth
)}
}
func
(
self
*
JS
Pipe
)
BlockByHash
(
strHash
string
)
*
JSBlock
{
func
(
self
*
JS
XEth
)
BlockByHash
(
strHash
string
)
*
JSBlock
{
hash
:=
ethutil
.
Hex2Bytes
(
strHash
)
block
:=
self
.
obj
.
ChainManager
()
.
GetBlock
(
hash
)
return
NewJSBlock
(
block
)
}
func
(
self
*
JS
Pipe
)
BlockByNumber
(
num
int32
)
*
JSBlock
{
func
(
self
*
JS
XEth
)
BlockByNumber
(
num
int32
)
*
JSBlock
{
if
num
==
-
1
{
return
NewJSBlock
(
self
.
obj
.
ChainManager
()
.
CurrentBlock
)
}
...
...
@@ -34,7 +34,7 @@ func (self *JSPipe) BlockByNumber(num int32) *JSBlock {
return
NewJSBlock
(
self
.
obj
.
ChainManager
()
.
GetBlockByNumber
(
uint64
(
num
)))
}
func
(
self
*
JS
Pipe
)
Block
(
v
interface
{})
*
JSBlock
{
func
(
self
*
JS
XEth
)
Block
(
v
interface
{})
*
JSBlock
{
if
n
,
ok
:=
v
.
(
int32
);
ok
{
return
self
.
BlockByNumber
(
n
)
}
else
if
str
,
ok
:=
v
.
(
string
);
ok
{
...
...
@@ -46,21 +46,21 @@ func (self *JSPipe) Block(v interface{}) *JSBlock {
return
nil
}
func
(
self
*
JS
Pipe
)
Key
()
*
JSKey
{
func
(
self
*
JS
XEth
)
Key
()
*
JSKey
{
return
NewJSKey
(
self
.
obj
.
KeyManager
()
.
KeyPair
())
}
func
(
self
*
JS
Pipe
)
StateObject
(
addr
string
)
*
JSObject
{
func
(
self
*
JS
XEth
)
StateObject
(
addr
string
)
*
JSObject
{
object
:=
&
Object
{
self
.
World
()
.
safeGet
(
ethutil
.
Hex2Bytes
(
addr
))}
return
NewJSObject
(
object
)
}
func
(
self
*
JS
Pipe
)
PeerCount
()
int
{
func
(
self
*
JS
XEth
)
PeerCount
()
int
{
return
self
.
obj
.
PeerCount
()
}
func
(
self
*
JS
Pipe
)
Peers
()
[]
JSPeer
{
func
(
self
*
JS
XEth
)
Peers
()
[]
JSPeer
{
var
peers
[]
JSPeer
for
peer
:=
self
.
obj
.
Peers
()
.
Front
();
peer
!=
nil
;
peer
=
peer
.
Next
()
{
p
:=
peer
.
Value
.
(
chain
.
Peer
)
...
...
@@ -73,47 +73,47 @@ func (self *JSPipe) Peers() []JSPeer {
return
peers
}
func
(
self
*
JS
Pipe
)
IsMining
()
bool
{
func
(
self
*
JS
XEth
)
IsMining
()
bool
{
return
self
.
obj
.
IsMining
()
}
func
(
self
*
JS
Pipe
)
IsListening
()
bool
{
func
(
self
*
JS
XEth
)
IsListening
()
bool
{
return
self
.
obj
.
IsListening
()
}
func
(
self
*
JS
Pipe
)
CoinBase
()
string
{
func
(
self
*
JS
XEth
)
CoinBase
()
string
{
return
ethutil
.
Bytes2Hex
(
self
.
obj
.
KeyManager
()
.
Address
())
}
func
(
self
*
JS
Pipe
)
NumberToHuman
(
balance
string
)
string
{
func
(
self
*
JS
XEth
)
NumberToHuman
(
balance
string
)
string
{
b
:=
ethutil
.
Big
(
balance
)
return
ethutil
.
CurrencyToString
(
b
)
}
func
(
self
*
JS
Pipe
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
func
(
self
*
JS
XEth
)
StorageAt
(
addr
,
storageAddr
string
)
string
{
storage
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Storage
(
ethutil
.
Hex2Bytes
(
storageAddr
))
return
ethutil
.
Bytes2Hex
(
storage
.
Bytes
())
}
func
(
self
*
JS
Pipe
)
BalanceAt
(
addr
string
)
string
{
func
(
self
*
JS
XEth
)
BalanceAt
(
addr
string
)
string
{
return
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
.
Balance
()
.
String
()
}
func
(
self
*
JS
Pipe
)
TxCountAt
(
address
string
)
int
{
func
(
self
*
JS
XEth
)
TxCountAt
(
address
string
)
int
{
return
int
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Nonce
)
}
func
(
self
*
JS
Pipe
)
CodeAt
(
address
string
)
string
{
func
(
self
*
JS
XEth
)
CodeAt
(
address
string
)
string
{
return
ethutil
.
Bytes2Hex
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Code
)
}
func
(
self
*
JS
Pipe
)
IsContract
(
address
string
)
bool
{
func
(
self
*
JS
XEth
)
IsContract
(
address
string
)
bool
{
return
len
(
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
address
))
.
Code
)
>
0
}
func
(
self
*
JS
Pipe
)
SecretToAddress
(
key
string
)
string
{
func
(
self
*
JS
XEth
)
SecretToAddress
(
key
string
)
string
{
pair
,
err
:=
crypto
.
NewKeyPairFromSec
(
ethutil
.
Hex2Bytes
(
key
))
if
err
!=
nil
{
return
""
...
...
@@ -122,7 +122,7 @@ func (self *JSPipe) SecretToAddress(key string) string {
return
ethutil
.
Bytes2Hex
(
pair
.
Address
())
}
func
(
self
*
JS
Pipe
)
Execute
(
addr
,
value
,
gas
,
price
,
data
string
)
(
string
,
error
)
{
func
(
self
*
JS
XEth
)
Execute
(
addr
,
value
,
gas
,
price
,
data
string
)
(
string
,
error
)
{
ret
,
err
:=
self
.
ExecuteObject
(
&
Object
{
self
.
World
()
.
safeGet
(
ethutil
.
Hex2Bytes
(
addr
))},
ethutil
.
Hex2Bytes
(
data
),
...
...
@@ -139,7 +139,7 @@ type KeyVal struct {
Value
string
`json:"value"`
}
func
(
self
*
JS
Pipe
)
EachStorage
(
addr
string
)
string
{
func
(
self
*
JS
XEth
)
EachStorage
(
addr
string
)
string
{
var
values
[]
KeyVal
object
:=
self
.
World
()
.
SafeGet
(
ethutil
.
Hex2Bytes
(
addr
))
object
.
EachStorage
(
func
(
name
string
,
value
*
ethutil
.
Value
)
{
...
...
@@ -155,13 +155,13 @@ func (self *JSPipe) EachStorage(addr string) string {
return
string
(
valuesJson
)
}
func
(
self
*
JS
Pipe
)
ToAscii
(
str
string
)
string
{
func
(
self
*
JS
XEth
)
ToAscii
(
str
string
)
string
{
padded
:=
ethutil
.
RightPadBytes
([]
byte
(
str
),
32
)
return
"0x"
+
ethutil
.
Bytes2Hex
(
padded
)
}
func
(
self
*
JS
Pipe
)
FromAscii
(
str
string
)
string
{
func
(
self
*
JS
XEth
)
FromAscii
(
str
string
)
string
{
if
ethutil
.
IsHex
(
str
)
{
str
=
str
[
2
:
]
}
...
...
@@ -169,7 +169,7 @@ func (self *JSPipe) FromAscii(str string) string {
return
string
(
bytes
.
Trim
(
ethutil
.
Hex2Bytes
(
str
),
"
\x00
"
))
}
func
(
self
*
JS
Pipe
)
FromNumber
(
str
string
)
string
{
func
(
self
*
JS
XEth
)
FromNumber
(
str
string
)
string
{
if
ethutil
.
IsHex
(
str
)
{
str
=
str
[
2
:
]
}
...
...
@@ -177,7 +177,7 @@ func (self *JSPipe) FromNumber(str string) string {
return
ethutil
.
BigD
(
ethutil
.
Hex2Bytes
(
str
))
.
String
()
}
func
(
self
*
JS
Pipe
)
Transact
(
key
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
*
JSReceipt
,
error
)
{
func
(
self
*
JS
XEth
)
Transact
(
key
,
toStr
,
valueStr
,
gasStr
,
gasPriceStr
,
codeStr
string
)
(
*
JSReceipt
,
error
)
{
var
hash
[]
byte
var
contractCreation
bool
if
len
(
toStr
)
==
0
{
...
...
@@ -239,14 +239,14 @@ func (self *JSPipe) Transact(key, toStr, valueStr, gasStr, gasPriceStr, codeStr
return
NewJSReciept
(
contractCreation
,
tx
.
CreationAddress
(
self
.
World
()
.
State
()),
tx
.
Hash
(),
keyPair
.
Address
()),
nil
}
func
(
self
*
JS
Pipe
)
PushTx
(
txStr
string
)
(
*
JSReceipt
,
error
)
{
func
(
self
*
JS
XEth
)
PushTx
(
txStr
string
)
(
*
JSReceipt
,
error
)
{
tx
:=
chain
.
NewTransactionFromBytes
(
ethutil
.
Hex2Bytes
(
txStr
))
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
return
NewJSReciept
(
tx
.
CreatesContract
(),
tx
.
CreationAddress
(
self
.
World
()
.
State
()),
tx
.
Hash
(),
tx
.
Sender
()),
nil
}
func
(
self
*
JS
Pipe
)
CompileMutan
(
code
string
)
string
{
data
,
err
:=
self
.
Pipe
.
CompileMutan
(
code
)
func
(
self
*
JS
XEth
)
CompileMutan
(
code
string
)
string
{
data
,
err
:=
self
.
XEth
.
CompileMutan
(
code
)
if
err
!=
nil
{
return
err
.
Error
()
}
...
...
ethpipe
/js_types.go
→
xeth
/js_types.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
(
"fmt"
...
...
ethpipe
/object.go
→
xeth
/object.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
(
"github.com/ethereum/go-ethereum/ethstate"
...
...
ethpipe
/pipe.go
→
xeth
/pipe.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
/*
* eXtended ETHereum
*/
import
(
"fmt"
...
...
@@ -12,13 +16,13 @@ import (
"github.com/ethereum/go-ethereum/vm"
)
var
pipelogger
=
logger
.
NewLogger
(
"
PIPE
"
)
var
pipelogger
=
logger
.
NewLogger
(
"
XETH
"
)
type
VmVars
struct
{
State
*
ethstate
.
State
}
type
Pipe
struct
{
type
XEth
struct
{
obj
chain
.
EthManager
stateManager
*
chain
.
StateManager
blockChain
*
chain
.
ChainManager
...
...
@@ -27,8 +31,8 @@ type Pipe struct {
Vm
VmVars
}
func
New
(
obj
chain
.
EthManager
)
*
Pipe
{
pipe
:=
&
Pipe
{
func
New
(
obj
chain
.
EthManager
)
*
XEth
{
pipe
:=
&
XEth
{
obj
:
obj
,
stateManager
:
obj
.
StateManager
(),
blockChain
:
obj
.
ChainManager
(),
...
...
@@ -38,19 +42,19 @@ func New(obj chain.EthManager) *Pipe {
return
pipe
}
func
(
self
*
Pipe
)
Balance
(
addr
[]
byte
)
*
ethutil
.
Value
{
func
(
self
*
XEth
)
Balance
(
addr
[]
byte
)
*
ethutil
.
Value
{
return
ethutil
.
NewValue
(
self
.
World
()
.
safeGet
(
addr
)
.
Balance
)
}
func
(
self
*
Pipe
)
Nonce
(
addr
[]
byte
)
uint64
{
func
(
self
*
XEth
)
Nonce
(
addr
[]
byte
)
uint64
{
return
self
.
World
()
.
safeGet
(
addr
)
.
Nonce
}
func
(
self
*
Pipe
)
Execute
(
addr
[]
byte
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
Execute
(
addr
[]
byte
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
return
self
.
ExecuteObject
(
&
Object
{
self
.
World
()
.
safeGet
(
addr
)},
data
,
value
,
gas
,
price
)
}
func
(
self
*
Pipe
)
ExecuteObject
(
object
*
Object
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
ExecuteObject
(
object
*
Object
,
data
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
)
([]
byte
,
error
)
{
var
(
initiator
=
ethstate
.
NewStateObject
(
self
.
obj
.
KeyManager
()
.
KeyPair
()
.
Address
())
block
=
self
.
blockChain
.
CurrentBlock
...
...
@@ -68,15 +72,15 @@ func (self *Pipe) ExecuteObject(object *Object, data []byte, value, gas, price *
return
ret
,
err
}
func
(
self
*
Pipe
)
Block
(
hash
[]
byte
)
*
chain
.
Block
{
func
(
self
*
XEth
)
Block
(
hash
[]
byte
)
*
chain
.
Block
{
return
self
.
blockChain
.
GetBlock
(
hash
)
}
func
(
self
*
Pipe
)
Storage
(
addr
,
storageAddr
[]
byte
)
*
ethutil
.
Value
{
func
(
self
*
XEth
)
Storage
(
addr
,
storageAddr
[]
byte
)
*
ethutil
.
Value
{
return
self
.
World
()
.
safeGet
(
addr
)
.
GetStorage
(
ethutil
.
BigD
(
storageAddr
))
}
func
(
self
*
Pipe
)
ToAddress
(
priv
[]
byte
)
[]
byte
{
func
(
self
*
XEth
)
ToAddress
(
priv
[]
byte
)
[]
byte
{
pair
,
err
:=
crypto
.
NewKeyPairFromSec
(
priv
)
if
err
!=
nil
{
return
nil
...
...
@@ -85,11 +89,11 @@ func (self *Pipe) ToAddress(priv []byte) []byte {
return
pair
.
Address
()
}
func
(
self
*
Pipe
)
Exists
(
addr
[]
byte
)
bool
{
func
(
self
*
XEth
)
Exists
(
addr
[]
byte
)
bool
{
return
self
.
World
()
.
Get
(
addr
)
!=
nil
}
func
(
self
*
Pipe
)
TransactString
(
key
*
crypto
.
KeyPair
,
rec
string
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
TransactString
(
key
*
crypto
.
KeyPair
,
rec
string
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
// Check if an address is stored by this address
var
hash
[]
byte
addr
:=
self
.
World
()
.
Config
()
.
Get
(
"NameReg"
)
.
StorageString
(
rec
)
.
Bytes
()
...
...
@@ -104,7 +108,7 @@ func (self *Pipe) TransactString(key *crypto.KeyPair, rec string, value, gas, pr
return
self
.
Transact
(
key
,
hash
,
value
,
gas
,
price
,
data
)
}
func
(
self
*
Pipe
)
Transact
(
key
*
crypto
.
KeyPair
,
rec
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
Transact
(
key
*
crypto
.
KeyPair
,
rec
[]
byte
,
value
,
gas
,
price
*
ethutil
.
Value
,
data
[]
byte
)
([]
byte
,
error
)
{
var
hash
[]
byte
var
contractCreation
bool
if
rec
==
nil
{
...
...
@@ -151,7 +155,7 @@ func (self *Pipe) Transact(key *crypto.KeyPair, rec []byte, value, gas, price *e
return
tx
.
Hash
(),
nil
}
func
(
self
*
Pipe
)
PushTx
(
tx
*
chain
.
Transaction
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
PushTx
(
tx
*
chain
.
Transaction
)
([]
byte
,
error
)
{
self
.
obj
.
TxPool
()
.
QueueTransaction
(
tx
)
if
tx
.
Recipient
==
nil
{
addr
:=
tx
.
CreationAddress
(
self
.
World
()
.
State
())
...
...
@@ -161,7 +165,7 @@ func (self *Pipe) PushTx(tx *chain.Transaction) ([]byte, error) {
return
tx
.
Hash
(),
nil
}
func
(
self
*
Pipe
)
CompileMutan
(
code
string
)
([]
byte
,
error
)
{
func
(
self
*
XEth
)
CompileMutan
(
code
string
)
([]
byte
,
error
)
{
data
,
err
:=
ethutil
.
Compile
(
code
,
false
)
if
err
!=
nil
{
return
nil
,
err
...
...
ethpipe
/vm_env.go
→
xeth
/vm_env.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
(
"math/big"
...
...
ethpipe
/world.go
→
xeth
/world.go
View file @
0ed1a8b5
package
ethpipe
package
xeth
import
(
"container/list"
...
...
@@ -7,18 +7,18 @@ import (
)
type
World
struct
{
pipe
*
Pipe
pipe
*
XEth
cfg
*
Config
}
func
NewWorld
(
pipe
*
Pipe
)
*
World
{
func
NewWorld
(
pipe
*
XEth
)
*
World
{
world
:=
&
World
{
pipe
,
nil
}
world
.
cfg
=
&
Config
{
pipe
}
return
world
}
func
(
self
*
Pipe
)
World
()
*
World
{
func
(
self
*
XEth
)
World
()
*
World
{
return
self
.
world
}
...
...
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