Skip to content

Commit 2eab964

Browse files
committed
Switched over to ethpipe
1 parent 8f1b461 commit 2eab964

File tree

5 files changed

+22
-46
lines changed

5 files changed

+22
-46
lines changed

ethereal/html_container.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"path/filepath"
1111

1212
"github.com/ethereum/eth-go/ethchain"
13-
"github.com/ethereum/eth-go/ethpub"
13+
"github.com/ethereum/eth-go/ethpipe"
1414
"github.com/ethereum/eth-go/ethstate"
1515
"github.com/ethereum/eth-go/ethutil"
1616
"github.com/ethereum/go-ethereum/javascript"
@@ -121,7 +121,7 @@ func (app *HtmlApplication) Window() *qml.Window {
121121
}
122122

123123
func (app *HtmlApplication) NewBlock(block *ethchain.Block) {
124-
b := &ethpub.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
124+
b := &ethpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
125125
app.webView.Call("onNewBlockCb", b)
126126
}
127127

ethereal/qml_container.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"runtime"
66

77
"github.com/ethereum/eth-go/ethchain"
8-
"github.com/ethereum/eth-go/ethpub"
8+
"github.com/ethereum/eth-go/ethpipe"
99
"github.com/ethereum/eth-go/ethstate"
1010
"github.com/ethereum/eth-go/ethutil"
1111
"gopkg.in/qml.v1"
@@ -49,18 +49,10 @@ func (app *QmlApplication) NewWatcher(quitChan chan bool) {
4949

5050
// Events
5151
func (app *QmlApplication) NewBlock(block *ethchain.Block) {
52-
pblock := &ethpub.PBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
52+
pblock := &ethpipe.JSBlock{Number: int(block.BlockInfo().Number), Hash: ethutil.Bytes2Hex(block.Hash())}
5353
app.win.Call("onNewBlockCb", pblock)
5454
}
5555

56-
func (app *QmlApplication) ObjectChanged(stateObject *ethstate.StateObject) {
57-
app.win.Call("onObjectChangeCb", ethpub.NewPStateObject(stateObject))
58-
}
59-
60-
func (app *QmlApplication) StorageChanged(storageObject *ethstate.StorageState) {
61-
app.win.Call("onStorageChangeCb", ethpub.NewPStorageState(storageObject))
62-
}
63-
6456
func (self *QmlApplication) Messages(msgs ethstate.Messages, id string) {
6557
fmt.Println("IMPLEMENT QML APPLICATION MESSAGES METHOD")
6658
}

javascript/javascript_runtime.go

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import (
1010
"github.com/ethereum/eth-go"
1111
"github.com/ethereum/eth-go/ethchain"
1212
"github.com/ethereum/eth-go/ethlog"
13-
"github.com/ethereum/eth-go/ethpub"
13+
"github.com/ethereum/eth-go/ethpipe"
1414
"github.com/ethereum/eth-go/ethreact"
1515
"github.com/ethereum/eth-go/ethstate"
1616
"github.com/ethereum/eth-go/ethutil"
@@ -23,7 +23,7 @@ var jsrelogger = ethlog.NewLogger("JSRE")
2323
type JSRE struct {
2424
ethereum *eth.Ethereum
2525
Vm *otto.Otto
26-
lib *ethpub.PEthereum
26+
pipe *ethpipe.JSPipe
2727

2828
blockChan chan ethreact.Event
2929
changeChan chan ethreact.Event
@@ -50,7 +50,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
5050
re := &JSRE{
5151
ethereum,
5252
otto.New(),
53-
ethpub.New(ethereum),
53+
ethpipe.NewJSPipe(ethereum),
5454
make(chan ethreact.Event, 10),
5555
make(chan ethreact.Event, 10),
5656
make(chan bool),
@@ -71,7 +71,7 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
7171
reactor := ethereum.Reactor()
7272
reactor.Subscribe("newBlock", re.blockChan)
7373

74-
re.Bind("eth", &JSEthereum{re.lib, re.Vm, ethereum})
74+
re.Bind("eth", &JSEthereum{re.pipe, re.Vm, ethereum})
7575

7676
re.initStdFuncs()
7777

@@ -123,18 +123,6 @@ out:
123123
case block := <-self.blockChan:
124124
if _, ok := block.Resource.(*ethchain.Block); ok {
125125
}
126-
case object := <-self.changeChan:
127-
if stateObject, ok := object.Resource.(*ethstate.StateObject); ok {
128-
for _, cb := range self.objectCb[ethutil.Bytes2Hex(stateObject.Address())] {
129-
val, _ := self.Vm.ToValue(ethpub.NewPStateObject(stateObject))
130-
cb.Call(cb, val)
131-
}
132-
} else if storageObject, ok := object.Resource.(*ethstate.StorageState); ok {
133-
for _, cb := range self.objectCb[ethutil.Bytes2Hex(storageObject.StateAddress)+ethutil.Bytes2Hex(storageObject.Address)] {
134-
val, _ := self.Vm.ToValue(ethpub.NewPStorageState(storageObject))
135-
cb.Call(cb, val)
136-
}
137-
}
138126
}
139127
}
140128
}

javascript/types.go

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,20 @@ import (
55

66
"github.com/ethereum/eth-go"
77
"github.com/ethereum/eth-go/ethchain"
8-
"github.com/ethereum/eth-go/ethpub"
8+
"github.com/ethereum/eth-go/ethpipe"
99
"github.com/ethereum/eth-go/ethstate"
1010
"github.com/ethereum/eth-go/ethutil"
1111
"github.com/obscuren/otto"
1212
)
1313

1414
type JSStateObject struct {
15-
*ethpub.PStateObject
15+
*ethpipe.JSObject
1616
eth *JSEthereum
1717
}
1818

1919
func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value {
2020
cb := call.Argument(0)
21-
self.PStateObject.EachStorage(func(key string, value *ethutil.Value) {
21+
self.JSObject.EachStorage(func(key string, value *ethutil.Value) {
2222
value.Decode()
2323

2424
cb.Call(self.eth.toVal(self), self.eth.toVal(key), self.eth.toVal(ethutil.Bytes2Hex(value.Bytes())))
@@ -30,12 +30,12 @@ func (self *JSStateObject) EachStorage(call otto.FunctionCall) otto.Value {
3030
// The JSEthereum object attempts to wrap the PEthereum object and returns
3131
// meaningful javascript objects
3232
type JSBlock struct {
33-
*ethpub.PBlock
33+
*ethpipe.JSBlock
3434
eth *JSEthereum
3535
}
3636

3737
func (self *JSBlock) GetTransaction(hash string) otto.Value {
38-
return self.eth.toVal(self.PBlock.GetTransaction(hash))
38+
return self.eth.toVal(self.JSBlock.GetTransaction(hash))
3939
}
4040

4141
type JSMessage struct {
@@ -67,33 +67,29 @@ func NewJSMessage(message *ethstate.Message) JSMessage {
6767
}
6868

6969
type JSEthereum struct {
70-
*ethpub.PEthereum
70+
*ethpipe.JSPipe
7171
vm *otto.Otto
7272
ethereum *eth.Ethereum
7373
}
7474

7575
func (self *JSEthereum) GetBlock(hash string) otto.Value {
76-
return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self})
76+
return self.toVal(&JSBlock{self.JSPipe.GetBlockByHash(hash), self})
7777
}
7878

7979
func (self *JSEthereum) GetPeers() otto.Value {
80-
return self.toVal(self.PEthereum.GetPeers())
80+
return self.toVal(self.JSPipe.GetPeers())
8181
}
8282

8383
func (self *JSEthereum) GetKey() otto.Value {
84-
return self.toVal(self.PEthereum.GetKey())
84+
return self.toVal(self.JSPipe.GetKey())
8585
}
8686

8787
func (self *JSEthereum) GetStateObject(addr string) otto.Value {
88-
return self.toVal(&JSStateObject{self.PEthereum.GetStateObject(addr), self})
89-
}
90-
91-
func (self *JSEthereum) GetStateKeyVals(addr string) otto.Value {
92-
return self.toVal(self.PEthereum.GetStateObject(addr).StateKeyVal(false))
88+
return self.toVal(&JSStateObject{ethpipe.NewJSObject(self.JSPipe.World().SafeGet(ethutil.Hex2Bytes(addr))), self})
9389
}
9490

9591
func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr string) otto.Value {
96-
r, err := self.PEthereum.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
92+
r, err := self.JSPipe.Transact(key, recipient, valueStr, gasStr, gasPriceStr, dataStr)
9793
if err != nil {
9894
fmt.Println(err)
9995

@@ -104,7 +100,7 @@ func (self *JSEthereum) Transact(key, recipient, valueStr, gasStr, gasPriceStr,
104100
}
105101

106102
func (self *JSEthereum) Create(key, valueStr, gasStr, gasPriceStr, scriptStr string) otto.Value {
107-
r, err := self.PEthereum.Create(key, valueStr, gasStr, gasPriceStr, scriptStr)
103+
r, err := self.JSPipe.Transact(key, "", valueStr, gasStr, gasPriceStr, scriptStr)
108104

109105
if err != nil {
110106
fmt.Println(err)

utils/cmd.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
"github.com/ethereum/eth-go/ethdb"
1919
"github.com/ethereum/eth-go/ethlog"
2020
"github.com/ethereum/eth-go/ethminer"
21-
"github.com/ethereum/eth-go/ethpub"
21+
"github.com/ethereum/eth-go/ethpipe"
2222
"github.com/ethereum/eth-go/ethrpc"
2323
"github.com/ethereum/eth-go/ethutil"
2424
"github.com/ethereum/eth-go/ethwire"
@@ -228,7 +228,7 @@ func KeyTasks(keyManager *ethcrypto.KeyManager, KeyRing string, GenAddr bool, Se
228228

229229
func StartRpc(ethereum *eth.Ethereum, RpcPort int) {
230230
var err error
231-
ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpub.New(ethereum), RpcPort)
231+
ethereum.RpcServer, err = ethrpc.NewJsonRpcServer(ethpipe.NewJSPipe(ethereum), RpcPort)
232232
if err != nil {
233233
logger.Errorf("Could not start RPC interface (port %v): %v", RpcPort, err)
234234
} else {

0 commit comments

Comments
 (0)