Merge branch 'develop' of github.com:ethereum/go-ethereum into feature/ethutil-refactor
This commit is contained in:
commit
353ecbb7d7
@ -19,7 +19,7 @@ ApplicationWindow {
|
|||||||
property alias dataText: rawDataField.text
|
property alias dataText: rawDataField.text
|
||||||
|
|
||||||
onClosing: {
|
onClosing: {
|
||||||
compileTimer.stop()
|
//compileTimer.stop()
|
||||||
}
|
}
|
||||||
|
|
||||||
MenuBar {
|
MenuBar {
|
||||||
@ -112,13 +112,15 @@ ApplicationWindow {
|
|||||||
anchors.right: settings.left
|
anchors.right: settings.left
|
||||||
focus: true
|
focus: true
|
||||||
|
|
||||||
|
/*
|
||||||
Timer {
|
Timer {
|
||||||
id: compileTimer
|
id: compileTimer
|
||||||
interval: 500 ; running: true ; repeat: true
|
interval: 500 ; running: true ; repeat: true
|
||||||
onTriggered: {
|
onTriggered: {
|
||||||
dbg.compile(codeEditor.text)
|
dbg.autoComp(codeEditor.text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
Column {
|
Column {
|
||||||
|
@ -100,7 +100,7 @@ ApplicationWindow {
|
|||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
height: 200
|
height: 200
|
||||||
Image {
|
Image {
|
||||||
source: ui.assetPath("tx.png")
|
source: "../tx.png"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -110,7 +110,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
source: ui.assetPath("new.png")
|
source: "../new.png"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -120,7 +120,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Image {
|
Image {
|
||||||
source: ui.assetPath("net.png")
|
source: "../net.png"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -131,7 +131,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Image {
|
Image {
|
||||||
source: ui.assetPath("heart.png")
|
source: "../heart.png"
|
||||||
anchors.horizontalCenter: parent.horizontalCenter
|
anchors.horizontalCenter: parent.horizontalCenter
|
||||||
MouseArea {
|
MouseArea {
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
@ -436,7 +436,7 @@ ApplicationWindow {
|
|||||||
onDoubleClicked: peerWindow.visible = true
|
onDoubleClicked: peerWindow.visible = true
|
||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
}
|
}
|
||||||
source: ui.assetPath("network.png")
|
source: "../network.png"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -624,7 +624,7 @@ ApplicationWindow {
|
|||||||
width: 150
|
width: 150
|
||||||
fillMode: Image.PreserveAspectFit
|
fillMode: Image.PreserveAspectFit
|
||||||
smooth: true
|
smooth: true
|
||||||
source: ui.assetPath("facet.png")
|
source: "../facet.png"
|
||||||
x: 10
|
x: 10
|
||||||
y: 10
|
y: 10
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,7 @@ ApplicationWindow {
|
|||||||
experimental.preferences.javascriptEnabled: true
|
experimental.preferences.javascriptEnabled: true
|
||||||
experimental.preferences.navigatorQtObjectEnabled: true
|
experimental.preferences.navigatorQtObjectEnabled: true
|
||||||
experimental.preferences.developerExtrasEnabled: true
|
experimental.preferences.developerExtrasEnabled: true
|
||||||
experimental.userScripts: [ui.assetPath("ext/pre.js"), ui.assetPath("ext/big.js"), ui.assetPath("ext/string.js"), ui.assetPath("ext/ethereum.js")]
|
experimental.userScripts: ["../ext/pre.js", "../ext/big.js", "../ext/string.js", "../ext/ethereum.js"]
|
||||||
experimental.onMessageReceived: {
|
experimental.onMessageReceived: {
|
||||||
console.log("[onMessageReceived]: ", message.data)
|
console.log("[onMessageReceived]: ", message.data)
|
||||||
// TODO move to messaging.js
|
// TODO move to messaging.js
|
||||||
@ -191,6 +191,7 @@ ApplicationWindow {
|
|||||||
inspector.visible = false
|
inspector.visible = false
|
||||||
}else{
|
}else{
|
||||||
inspector.visible = true
|
inspector.visible = true
|
||||||
|
inspector.url = webview.experimental.remoteInspectorUrl
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
onDoubleClicked: {
|
onDoubleClicked: {
|
||||||
@ -224,7 +225,6 @@ ApplicationWindow {
|
|||||||
WebView {
|
WebView {
|
||||||
id: inspector
|
id: inspector
|
||||||
visible: false
|
visible: false
|
||||||
url: webview.experimental.remoteInspectorUrl
|
|
||||||
anchors {
|
anchors {
|
||||||
left: root.left
|
left: root.left
|
||||||
right: root.right
|
right: root.right
|
||||||
@ -238,7 +238,6 @@ ApplicationWindow {
|
|||||||
name: "inspectorShown"
|
name: "inspectorShown"
|
||||||
PropertyChanges {
|
PropertyChanges {
|
||||||
target: inspector
|
target: inspector
|
||||||
url: webview.experimental.remoteInspectorUrl
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
@ -74,6 +74,13 @@ func (self *DebuggerWindow) Compile(code string) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Used by QML
|
||||||
|
func (self *DebuggerWindow) AutoComp(code string) {
|
||||||
|
if self.Db.done {
|
||||||
|
self.Compile(code)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (self *DebuggerWindow) ClearLog() {
|
func (self *DebuggerWindow) ClearLog() {
|
||||||
self.win.Root().Call("clearLog")
|
self.win.Root().Call("clearLog")
|
||||||
}
|
}
|
||||||
@ -110,8 +117,6 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
self.SetAsm(script)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
gas = ethutil.Big(gasStr)
|
gas = ethutil.Big(gasStr)
|
||||||
gasPrice = ethutil.Big(gasPriceStr)
|
gasPrice = ethutil.Big(gasPriceStr)
|
||||||
@ -257,6 +262,10 @@ func (self *Debugger) StepHook(pc int, op ethchain.OpCode, mem *ethchain.Memory,
|
|||||||
return self.halting(pc, op, mem, stack, stateObject)
|
return self.halting(pc, op, mem, stack, stateObject)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *Debugger) SetCode(byteCode []byte) {
|
||||||
|
self.main.SetAsm(byteCode)
|
||||||
|
}
|
||||||
|
|
||||||
func (self *Debugger) BreakPoints() []int64 {
|
func (self *Debugger) BreakPoints() []int64 {
|
||||||
return self.breakPoints
|
return self.breakPoints
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethreact"
|
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
)
|
)
|
||||||
@ -25,8 +24,8 @@ type AppContainer interface {
|
|||||||
type ExtApplication struct {
|
type ExtApplication struct {
|
||||||
*ethpub.PEthereum
|
*ethpub.PEthereum
|
||||||
|
|
||||||
blockChan chan ethreact.Event
|
blockChan chan ethutil.React
|
||||||
changeChan chan ethreact.Event
|
changeChan chan ethutil.React
|
||||||
quitChan chan bool
|
quitChan chan bool
|
||||||
watcherQuitChan chan bool
|
watcherQuitChan chan bool
|
||||||
|
|
||||||
@ -38,8 +37,8 @@ type ExtApplication struct {
|
|||||||
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
|
func NewExtApplication(container AppContainer, lib *UiLib) *ExtApplication {
|
||||||
app := &ExtApplication{
|
app := &ExtApplication{
|
||||||
ethpub.NewPEthereum(lib.eth),
|
ethpub.NewPEthereum(lib.eth),
|
||||||
make(chan ethreact.Event),
|
make(chan ethutil.React, 1),
|
||||||
make(chan ethreact.Event),
|
make(chan ethutil.React, 1),
|
||||||
make(chan bool),
|
make(chan bool),
|
||||||
make(chan bool),
|
make(chan bool),
|
||||||
container,
|
container,
|
||||||
|
@ -52,8 +52,8 @@ func defaultAssetPath() string {
|
|||||||
assetPath = filepath.Join(exedir, "../Resources")
|
assetPath = filepath.Join(exedir, "../Resources")
|
||||||
case "linux":
|
case "linux":
|
||||||
assetPath = "/usr/share/ethereal"
|
assetPath = "/usr/share/ethereal"
|
||||||
case "window":
|
case "windows":
|
||||||
fallthrough
|
assetPath = "./assets"
|
||||||
default:
|
default:
|
||||||
assetPath = "."
|
assetPath = "."
|
||||||
}
|
}
|
||||||
|
123
ethereal/gui.go
123
ethereal/gui.go
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethdb"
|
"github.com/ethereum/eth-go/ethdb"
|
||||||
"github.com/ethereum/eth-go/ethlog"
|
"github.com/ethereum/eth-go/ethlog"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethreact"
|
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/eth-go/ethwire"
|
"github.com/ethereum/eth-go/ethwire"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
@ -144,7 +143,7 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
|
|||||||
gui.readPreviousTransactions()
|
gui.readPreviousTransactions()
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
|
|
||||||
gui.update()
|
go gui.update()
|
||||||
|
|
||||||
return win, nil
|
return win, nil
|
||||||
}
|
}
|
||||||
@ -267,68 +266,11 @@ func (gui *Gui) setWalletValue(amount, unconfirmedFunds *big.Int) {
|
|||||||
func (gui *Gui) update() {
|
func (gui *Gui) update() {
|
||||||
reactor := gui.eth.Reactor()
|
reactor := gui.eth.Reactor()
|
||||||
|
|
||||||
blockChan := make(chan ethreact.Event)
|
blockChan := make(chan ethutil.React, 1)
|
||||||
txChan := make(chan ethreact.Event)
|
txChan := make(chan ethutil.React, 1)
|
||||||
objectChan := make(chan ethreact.Event)
|
objectChan := make(chan ethutil.React, 1)
|
||||||
peerChan := make(chan ethreact.Event)
|
peerChan := make(chan ethutil.React, 1)
|
||||||
|
|
||||||
ticker := time.NewTicker(5 * time.Second)
|
|
||||||
|
|
||||||
state := gui.eth.StateManager().TransState()
|
|
||||||
|
|
||||||
unconfirmedFunds := new(big.Int)
|
|
||||||
gui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(state.GetAccount(gui.address()).Amount)))
|
|
||||||
|
|
||||||
go func() {
|
|
||||||
for {
|
|
||||||
select {
|
|
||||||
case b := <-blockChan:
|
|
||||||
block := b.Resource.(*ethchain.Block)
|
|
||||||
gui.processBlock(block, false)
|
|
||||||
if bytes.Compare(block.Coinbase, gui.address()) == 0 {
|
|
||||||
gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.address()).Amount, nil)
|
|
||||||
}
|
|
||||||
|
|
||||||
case txMsg := <-txChan:
|
|
||||||
tx := txMsg.Resource.(*ethchain.Transaction)
|
|
||||||
|
|
||||||
if txMsg.Name == "newTx:pre" {
|
|
||||||
object := state.GetAccount(gui.address())
|
|
||||||
|
|
||||||
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
|
|
||||||
gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "send")
|
|
||||||
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
|
||||||
|
|
||||||
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
|
|
||||||
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
|
|
||||||
gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "recv")
|
|
||||||
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
|
||||||
|
|
||||||
unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.setWalletValue(object.Amount, unconfirmedFunds)
|
|
||||||
} else {
|
|
||||||
object := state.GetAccount(gui.address())
|
|
||||||
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
|
|
||||||
object.SubAmount(tx.Value)
|
|
||||||
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
|
|
||||||
object.AddAmount(tx.Value)
|
|
||||||
}
|
|
||||||
|
|
||||||
gui.setWalletValue(object.Amount, nil)
|
|
||||||
|
|
||||||
state.UpdateStateObject(object)
|
|
||||||
}
|
|
||||||
case <-objectChan:
|
|
||||||
gui.loadAddressBook()
|
|
||||||
case <-peerChan:
|
|
||||||
gui.setPeerInfo()
|
|
||||||
case <-ticker.C:
|
|
||||||
gui.setPeerInfo()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}()
|
|
||||||
reactor.Subscribe("newBlock", blockChan)
|
reactor.Subscribe("newBlock", blockChan)
|
||||||
reactor.Subscribe("newTx:pre", txChan)
|
reactor.Subscribe("newTx:pre", txChan)
|
||||||
reactor.Subscribe("newTx:post", txChan)
|
reactor.Subscribe("newTx:post", txChan)
|
||||||
@ -339,6 +281,61 @@ func (gui *Gui) update() {
|
|||||||
}
|
}
|
||||||
reactor.Subscribe("peerList", peerChan)
|
reactor.Subscribe("peerList", peerChan)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
|
|
||||||
|
state := gui.eth.StateManager().TransState()
|
||||||
|
|
||||||
|
unconfirmedFunds := new(big.Int)
|
||||||
|
gui.win.Root().Call("setWalletValue", fmt.Sprintf("%v", ethutil.CurrencyToString(state.GetAccount(gui.address()).Amount)))
|
||||||
|
|
||||||
|
for {
|
||||||
|
select {
|
||||||
|
case b := <-blockChan:
|
||||||
|
block := b.Resource.(*ethchain.Block)
|
||||||
|
gui.processBlock(block, false)
|
||||||
|
if bytes.Compare(block.Coinbase, gui.address()) == 0 {
|
||||||
|
gui.setWalletValue(gui.eth.StateManager().CurrentState().GetAccount(gui.address()).Amount, nil)
|
||||||
|
}
|
||||||
|
|
||||||
|
case txMsg := <-txChan:
|
||||||
|
tx := txMsg.Resource.(*ethchain.Transaction)
|
||||||
|
|
||||||
|
if txMsg.Event == "newTx:pre" {
|
||||||
|
object := state.GetAccount(gui.address())
|
||||||
|
|
||||||
|
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
|
||||||
|
gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "send")
|
||||||
|
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
||||||
|
|
||||||
|
unconfirmedFunds.Sub(unconfirmedFunds, tx.Value)
|
||||||
|
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
|
||||||
|
gui.win.Root().Call("addTx", ethpub.NewPTx(tx), "recv")
|
||||||
|
gui.txDb.Put(tx.Hash(), tx.RlpEncode())
|
||||||
|
|
||||||
|
unconfirmedFunds.Add(unconfirmedFunds, tx.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
gui.setWalletValue(object.Amount, unconfirmedFunds)
|
||||||
|
} else {
|
||||||
|
object := state.GetAccount(gui.address())
|
||||||
|
if bytes.Compare(tx.Sender(), gui.address()) == 0 {
|
||||||
|
object.SubAmount(tx.Value)
|
||||||
|
} else if bytes.Compare(tx.Recipient, gui.address()) == 0 {
|
||||||
|
object.AddAmount(tx.Value)
|
||||||
|
}
|
||||||
|
|
||||||
|
gui.setWalletValue(object.Amount, nil)
|
||||||
|
|
||||||
|
state.UpdateStateObject(object)
|
||||||
|
}
|
||||||
|
case <-objectChan:
|
||||||
|
gui.loadAddressBook()
|
||||||
|
case <-peerChan:
|
||||||
|
gui.setPeerInfo()
|
||||||
|
case <-ticker.C:
|
||||||
|
gui.setPeerInfo()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) setPeerInfo() {
|
func (gui *Gui) setPeerInfo() {
|
||||||
|
@ -8,7 +8,6 @@ import (
|
|||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
"github.com/howeyc/fsnotify"
|
"github.com/howeyc/fsnotify"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
@ -59,7 +58,7 @@ func (app *HtmlApplication) RootFolder() string {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
return path.Dir(folder.RequestURI())
|
return path.Dir(ethutil.WindonizePath(folder.RequestURI()))
|
||||||
}
|
}
|
||||||
func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
|
func (app *HtmlApplication) RecursiveFolders() []os.FileInfo {
|
||||||
files, _ := ioutil.ReadDir(app.RootFolder())
|
files, _ := ioutil.ReadDir(app.RootFolder())
|
||||||
@ -77,11 +76,13 @@ func (app *HtmlApplication) NewWatcher(quitChan chan bool) {
|
|||||||
|
|
||||||
app.watcher, err = fsnotify.NewWatcher()
|
app.watcher, err = fsnotify.NewWatcher()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
logger.Infoln("Could not create new auto-reload watcher:", err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
err = app.watcher.Watch(app.RootFolder())
|
err = app.watcher.Watch(app.RootFolder())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err)
|
logger.Infoln("Could not start auto-reload watcher:", err)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
for _, folder := range app.RecursiveFolders() {
|
for _, folder := range app.RecursiveFolders() {
|
||||||
fullPath := app.RootFolder() + "/" + folder.Name()
|
fullPath := app.RootFolder() + "/" + folder.Name()
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
|
"runtime"
|
||||||
)
|
)
|
||||||
|
|
||||||
type QmlApplication struct {
|
type QmlApplication struct {
|
||||||
@ -20,7 +21,14 @@ func NewQmlApplication(path string, lib *UiLib) *QmlApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (app *QmlApplication) Create() error {
|
func (app *QmlApplication) Create() error {
|
||||||
component, err := app.engine.LoadFile(app.path)
|
path := string(app.path)
|
||||||
|
|
||||||
|
// For some reason for windows we get /c:/path/to/something, windows doesn't like the first slash but is fine with the others so we are removing it
|
||||||
|
if string(app.path[0]) == "/" && runtime.GOOS == "windows" {
|
||||||
|
path = app.path[1:]
|
||||||
|
}
|
||||||
|
|
||||||
|
component, err := app.engine.LoadFile(path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Warnln(err)
|
logger.Warnln(err)
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
var Identifier string
|
var Identifier string
|
||||||
var KeyRing string
|
var KeyRing string
|
||||||
|
var DiffTool bool
|
||||||
var KeyStore string
|
var KeyStore string
|
||||||
var StartRpc bool
|
var StartRpc bool
|
||||||
var RpcPort int
|
var RpcPort int
|
||||||
@ -66,6 +67,7 @@ func Init() {
|
|||||||
flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file")
|
flag.StringVar(&ConfigFile, "conf", defaultConfigFile, "config file")
|
||||||
flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)")
|
flag.StringVar(&DebugFile, "debug", "", "debug file (no debugging if not set)")
|
||||||
flag.IntVar(&LogLevel, "loglevel", int(ethlog.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)")
|
flag.IntVar(&LogLevel, "loglevel", int(ethlog.InfoLevel), "loglevel: 0-5: silent,error,warn,info,debug,debug detail)")
|
||||||
|
flag.BoolVar(&DiffTool, "difftool", false, "creates output for diff'ing. Sets LogLevel=0")
|
||||||
|
|
||||||
flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
|
flag.BoolVar(&StartMining, "mine", false, "start dagger mining")
|
||||||
flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console")
|
flag.BoolVar(&StartJsConsole, "js", false, "launches javascript console")
|
||||||
|
@ -6,7 +6,6 @@ import (
|
|||||||
"github.com/ethereum/eth-go/ethchain"
|
"github.com/ethereum/eth-go/ethchain"
|
||||||
"github.com/ethereum/eth-go/ethlog"
|
"github.com/ethereum/eth-go/ethlog"
|
||||||
"github.com/ethereum/eth-go/ethpub"
|
"github.com/ethereum/eth-go/ethpub"
|
||||||
"github.com/ethereum/eth-go/ethreact"
|
|
||||||
"github.com/ethereum/eth-go/ethutil"
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
"github.com/obscuren/otto"
|
"github.com/obscuren/otto"
|
||||||
@ -23,8 +22,8 @@ type JSRE struct {
|
|||||||
vm *otto.Otto
|
vm *otto.Otto
|
||||||
lib *ethpub.PEthereum
|
lib *ethpub.PEthereum
|
||||||
|
|
||||||
blockChan chan ethreact.Event
|
blockChan chan ethutil.React
|
||||||
changeChan chan ethreact.Event
|
changeChan chan ethutil.React
|
||||||
quitChan chan bool
|
quitChan chan bool
|
||||||
|
|
||||||
objectCb map[string][]otto.Value
|
objectCb map[string][]otto.Value
|
||||||
@ -49,8 +48,8 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
|
|||||||
ethereum,
|
ethereum,
|
||||||
otto.New(),
|
otto.New(),
|
||||||
ethpub.NewPEthereum(ethereum),
|
ethpub.NewPEthereum(ethereum),
|
||||||
make(chan ethreact.Event),
|
make(chan ethutil.React, 1),
|
||||||
make(chan ethreact.Event),
|
make(chan ethutil.React, 1),
|
||||||
make(chan bool),
|
make(chan bool),
|
||||||
make(map[string][]otto.Value),
|
make(map[string][]otto.Value),
|
||||||
}
|
}
|
||||||
@ -64,9 +63,6 @@ func NewJSRE(ethereum *eth.Ethereum) *JSRE {
|
|||||||
|
|
||||||
// We have to make sure that, whoever calls this, calls "Stop"
|
// We have to make sure that, whoever calls this, calls "Stop"
|
||||||
go re.mainLoop()
|
go re.mainLoop()
|
||||||
// Subscribe to events
|
|
||||||
reactor := ethereum.Reactor()
|
|
||||||
reactor.Subscribe("newBlock", re.blockChan)
|
|
||||||
|
|
||||||
re.Bind("eth", &JSEthereum{re.lib, re.vm})
|
re.Bind("eth", &JSEthereum{re.lib, re.vm})
|
||||||
|
|
||||||
@ -112,6 +108,10 @@ func (self *JSRE) Stop() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (self *JSRE) mainLoop() {
|
func (self *JSRE) mainLoop() {
|
||||||
|
// Subscribe to events
|
||||||
|
reactor := self.ethereum.Reactor()
|
||||||
|
reactor.Subscribe("newBlock", self.blockChan)
|
||||||
|
|
||||||
out:
|
out:
|
||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
|
@ -2,6 +2,7 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/ethereum/eth-go/ethlog"
|
"github.com/ethereum/eth-go/ethlog"
|
||||||
|
"github.com/ethereum/eth-go/ethutil"
|
||||||
"github.com/ethereum/go-ethereum/utils"
|
"github.com/ethereum/go-ethereum/utils"
|
||||||
"runtime"
|
"runtime"
|
||||||
)
|
)
|
||||||
@ -20,7 +21,14 @@ func main() {
|
|||||||
|
|
||||||
// precedence: code-internal flag default < config file < environment variables < command line
|
// precedence: code-internal flag default < config file < environment variables < command line
|
||||||
Init() // parsing command line
|
Init() // parsing command line
|
||||||
|
|
||||||
|
// If the difftool option is selected ignore all other log output
|
||||||
|
if DiffTool {
|
||||||
|
LogLevel = 0
|
||||||
|
}
|
||||||
|
|
||||||
utils.InitConfig(ConfigFile, Datadir, "ETH")
|
utils.InitConfig(ConfigFile, Datadir, "ETH")
|
||||||
|
ethutil.Config.Diff = DiffTool
|
||||||
|
|
||||||
utils.InitDataDir(Datadir)
|
utils.InitDataDir(Datadir)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user