ethpipe => xeth (eXtended ETHereum)

This commit is contained in:
obscuren
2014-10-31 14:30:08 +01:00
parent 8826e9694c
commit 0ed1a8b50a
19 changed files with 112 additions and 108 deletions

View File

@ -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)

View File

@ -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{
JSPipe: ethpipe.NewJSPipe(lib.eth),
JSXEth: xeth.NewJSXEth(lib.eth),
eth: lib.eth,
watcherQuitChan: make(chan bool),
filters: make(map[string]*chain.Filter),

View File

@ -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())
}

View File

@ -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)
}

View File

@ -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)
}

View File

@ -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{JSPipe: 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{JSXEth: 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.JSPipe.Transact(
return self.JSXEth.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.JSPipe.Execute(
return self.JSXEth.Execute(
object["to"],
object["value"],
object["gas"],

View File

@ -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 {

View File

@ -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) {