From 0938b56829b9cbe8804a4ca85b14534908dbdfbc Mon Sep 17 00:00:00 2001 From: obscuren Date: Fri, 30 May 2014 13:04:23 +0200 Subject: Update peer info --- ethereal/ui/gui.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) (limited to 'ethereal') diff --git a/ethereal/ui/gui.go b/ethereal/ui/gui.go index d08c1b118..7c37e2d62 100644 --- a/ethereal/ui/gui.go +++ b/ethereal/ui/gui.go @@ -109,9 +109,11 @@ func (gui *Gui) showWallet(context *qml.Context) (*qml.Window, error) { win := gui.createWindow(component) - go gui.setInitialBlockChain() - go gui.loadAddressBook() - go gui.readPreviousTransactions() + gui.setInitialBlockChain() + gui.loadAddressBook() + gui.readPreviousTransactions() + gui.setPeerInfo() + go gui.update() return win, nil @@ -206,11 +208,13 @@ 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() @@ -259,10 +263,16 @@ func (gui *Gui) update() { } 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") -- cgit