good morning!!!!

Skip to content
Snippets Groups Projects
Commit 95a48cea authored by Jeffrey Wilcke's avatar Jeffrey Wilcke
Browse files

Peer amount update

parent aaac0c99
No related branches found
No related tags found
No related merge requests found
network.png

2.83 KiB

......@@ -9,6 +9,7 @@ import (
"github.com/ethereum/eth-go/ethutil"
"github.com/niemeyer/qml"
"strings"
"time"
)
type Gui struct {
......@@ -55,6 +56,7 @@ func (ui *Gui) Start() {
ui.eth.BlockManager.SecondaryBlockProcessor = ui
go ui.setInitialBlockChain()
go ui.updatePeers()
ui.win.Show()
ui.win.Wait()
......@@ -73,6 +75,13 @@ func (ui *Gui) ProcessBlock(block *ethchain.Block) {
ui.win.Root().Call("addBlock", NewBlockFromBlock(block))
}
func (ui *Gui) updatePeers() {
for {
ui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", ui.eth.Peers().Len(), ui.eth.MaxPeers))
time.Sleep(1 * time.Second)
}
}
type Tester struct {
root qml.Object
}
......
......@@ -71,11 +71,30 @@ ApplicationWindow {
statusBar: StatusBar {
RowLayout {
anchors.fill: parent
Label { text: "0.0.1" }
Label {
anchors.right: peerImage.left
anchors.rightMargin: 5
id: peerLabel
font.pixelSize: 8
text: "0 / 0"
}
Image {
id: peerImage
anchors.right: parent.right
width: 10; height: 10
source: "network.png"
}
}
}
function addBlock(block) {
blockModel.insert(0, {number: block.number, hash: block.hash})
}
function setPeers(text) {
peerLabel.text = text
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment