aboutsummaryrefslogtreecommitdiffstats
path: root/ethereal/ui
diff options
context:
space:
mode:
authorobscuren <geffobscura@gmail.com>2014-05-30 22:58:17 +0800
committerobscuren <geffobscura@gmail.com>2014-05-30 22:58:17 +0800
commit5f28013f7937cf2264ec646bdc04bc55f26bad77 (patch)
tree9f34f820c3667cd586d8f09ef7954bb10eb2c3d5 /ethereal/ui
parentf0f205004cb4157b50692b056f64bf846ee8c2e0 (diff)
parent65c5a20e1c04c996f96f81cd959ab986b8482b6a (diff)
downloaddexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar.gz
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar.bz2
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar.lz
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar.xz
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.tar.zst
dexon-5f28013f7937cf2264ec646bdc04bc55f26bad77.zip
Merge branch 'develop'
Diffstat (limited to 'ethereal/ui')
-rw-r--r--ethereal/ui/debugger.go2
-rw-r--r--ethereal/ui/gui.go50
2 files changed, 49 insertions, 3 deletions
diff --git a/ethereal/ui/debugger.go b/ethereal/ui/debugger.go
index 9bca7e4fe..a6b8e16d0 100644
--- a/ethereal/ui/debugger.go
+++ b/ethereal/ui/debugger.go
@@ -71,6 +71,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
var err error
script := ethutil.StringToByteFunc(scriptStr, func(s string) (ret []byte) {
ret, err = ethutil.Compile(s)
+ fmt.Printf("%x\n", ret)
return
})
@@ -82,6 +83,7 @@ func (self *DebuggerWindow) Debug(valueStr, gasStr, gasPriceStr, scriptStr, data
dis := ethchain.Disassemble(script)
self.win.Root().Call("clearAsm")
+ self.win.Root().Call("clearLog")
for _, str := range dis {
self.win.Root().Call("setAsm", str)
diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go
index 1698f5de0..d6430d1fe 100644
--- a/ethereal/ui/gui.go
+++ b/ethereal/ui/gui.go
@@ -8,6 +8,7 @@ import (
"github.com/ethereum/eth-go/ethdb"
"github.com/ethereum/eth-go/ethpub"
"github.com/ethereum/eth-go/ethutil"
+ "github.com/ethereum/go-ethereum/utils"
"github.com/go-qml/qml"
"math/big"
"strings"
@@ -66,7 +67,6 @@ func (gui *Gui) Start(assetPath string) {
}})
ethutil.Config.SetClientString(fmt.Sprintf("/Ethereal v%s", version))
- ethutil.Config.Log.Infoln("[GUI] Starting GUI")
// Create a new QML engine
gui.engine = qml.NewEngine()
context := gui.engine.Context()
@@ -93,12 +93,28 @@ func (gui *Gui) Start(assetPath string) {
panic(err)
}
+ ethutil.Config.Log.AddLogSystem(gui)
+ ethutil.Config.Log.Infoln("[GUI] Starting GUI")
+
win.Show()
win.Wait()
gui.eth.Stop()
}
+func (gui *Gui) ToggleMining() {
+ var txt string
+ if gui.eth.Mining {
+ utils.StopMining(gui.eth)
+ txt = "Start mining"
+ } else {
+ utils.StartMining(gui.eth)
+ txt = "Stop mining"
+ }
+
+ gui.win.Root().Set("miningButtonText", txt)
+}
+
func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
component, err := gui.engine.LoadFile(gui.uiLib.AssetPath("qml/wallet.qml"))
if err != nil {
@@ -107,8 +123,11 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) {
win := gui.createWindow(component)
- go gui.setInitialBlockChain()
- go gui.readPreviousTransactions()
+ gui.setInitialBlockChain()
+ gui.loadAddressBook()
+ gui.readPreviousTransactions()
+ gui.setPeerInfo()
+
go gui.update()
return win, nil
@@ -145,6 +164,19 @@ func (gui *Gui) setInitialBlockChain() {
}
}
+type address struct {
+ Name, Address string
+}
+
+var namereg = ethutil.FromHex("bb5f186604d057c1c5240ca2ae0f6430138ac010")
+
+func (gui *Gui) loadAddressBook() {
+ gui.win.Root().Call("clearAddress")
+ gui.eth.StateManager().CurrentState().GetStateObject(namereg).State().EachStorage(func(name string, value *ethutil.Value) {
+ gui.win.Root().Call("addAddress", struct{ Name, Address string }{name, ethutil.Hex(value.Bytes())})
+ })
+}
+
func (gui *Gui) readPreviousTransactions() {
it := gui.txDb.Db().NewIterator(nil, nil)
for it.Next() {
@@ -189,10 +221,14 @@ func (gui *Gui) update() {
blockChan := make(chan ethutil.React, 1)
txChan := make(chan ethutil.React, 1)
+ objectChan := make(chan ethutil.React, 1)
+ peerChan := make(chan ethutil.React, 1)
reactor.Subscribe("newBlock", blockChan)
reactor.Subscribe("newTx:pre", txChan)
reactor.Subscribe("newTx:post", txChan)
+ reactor.Subscribe("object:"+string(namereg), objectChan)
+ reactor.Subscribe("peerList", peerChan)
state := gui.eth.StateManager().TransState()
@@ -239,10 +275,18 @@ func (gui *Gui) update() {
state.UpdateStateObject(object)
}
+ case <-objectChan:
+ gui.loadAddressBook()
+ case <-peerChan:
+ gui.setPeerInfo()
}
}
}
+func (gui *Gui) setPeerInfo() {
+ gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
+}
+
// Logging functions that log directly to the GUI interface
func (gui *Gui) Println(v ...interface{}) {
str := strings.TrimRight(fmt.Sprintln(v...), "\n")