Added Peer Window
This commit is contained in:
parent
98811f11e5
commit
a6f4eef1da
@ -45,6 +45,13 @@ ApplicationWindow {
|
|||||||
addPeerWin.visible = true
|
addPeerWin.visible = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
MenuItem {
|
||||||
|
text: "Show Peers"
|
||||||
|
shortcut: "Ctrl+e"
|
||||||
|
onTriggered: {
|
||||||
|
peerWindow.visible = true
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu {
|
Menu {
|
||||||
@ -359,6 +366,10 @@ ApplicationWindow {
|
|||||||
id: peerImage
|
id: peerImage
|
||||||
anchors.right: parent.right
|
anchors.right: parent.right
|
||||||
width: 10; height: 10
|
width: 10; height: 10
|
||||||
|
MouseArea {
|
||||||
|
onDoubleClicked: peerWindow.visible = true
|
||||||
|
anchors.fill: parent
|
||||||
|
}
|
||||||
source: ui.assetPath("network.png")
|
source: ui.assetPath("network.png")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -623,6 +634,20 @@ ApplicationWindow {
|
|||||||
function setPeers(text) {
|
function setPeers(text) {
|
||||||
peerLabel.text = text
|
peerLabel.text = text
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function addPeer(peer) {
|
||||||
|
// We could just append the whole peer object but it cries if you try to alter them
|
||||||
|
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), version: peer.version})
|
||||||
|
}
|
||||||
|
|
||||||
|
function resetPeers(){
|
||||||
|
peerModel.clear()
|
||||||
|
}
|
||||||
|
|
||||||
|
function timeAgo(unixTs){
|
||||||
|
var lapsed = (Date.now() - new Date(unixTs*1000)) / 1000
|
||||||
|
return (lapsed + " seconds ago")
|
||||||
|
}
|
||||||
function convertToPretty(unixTs){
|
function convertToPretty(unixTs){
|
||||||
var a = new Date(unixTs*1000);
|
var a = new Date(unixTs*1000);
|
||||||
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
|
||||||
@ -635,6 +660,30 @@ ApplicationWindow {
|
|||||||
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
|
var time = date+' '+month+' '+year+' '+hour+':'+min+':'+sec ;
|
||||||
return time;
|
return time;
|
||||||
}
|
}
|
||||||
|
// ******************************************
|
||||||
|
// Windows
|
||||||
|
// ******************************************
|
||||||
|
Window {
|
||||||
|
id: peerWindow
|
||||||
|
height: 200
|
||||||
|
width: 500
|
||||||
|
Rectangle {
|
||||||
|
anchors.fill: parent
|
||||||
|
property var peerModel: ListModel {
|
||||||
|
id: peerModel
|
||||||
|
}
|
||||||
|
TableView {
|
||||||
|
anchors.fill: parent
|
||||||
|
id: peerTable
|
||||||
|
model: peerModel
|
||||||
|
TableViewColumn{width: 120; role: "ip" ; title: "IP" }
|
||||||
|
TableViewColumn{width: 60; role: "port" ; title: "Port" }
|
||||||
|
TableViewColumn{width: 120; role: "lastResponse"; title: "Last event" }
|
||||||
|
TableViewColumn{width: 180; role: "version" ; title: "Version" }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// *******************************************
|
// *******************************************
|
||||||
// Components
|
// Components
|
||||||
// *******************************************
|
// *******************************************
|
||||||
@ -810,7 +859,6 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// New Transaction component
|
// New Transaction component
|
||||||
Component {
|
Component {
|
||||||
id: newTransaction
|
id: newTransaction
|
||||||
|
@ -12,6 +12,7 @@ import (
|
|||||||
"github.com/go-qml/qml"
|
"github.com/go-qml/qml"
|
||||||
"math/big"
|
"math/big"
|
||||||
"strings"
|
"strings"
|
||||||
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
type Gui struct {
|
type Gui struct {
|
||||||
@ -91,7 +92,7 @@ func (gui *Gui) Start(assetPath string) {
|
|||||||
ethutil.Config.Log.AddLogSystem(gui)
|
ethutil.Config.Log.AddLogSystem(gui)
|
||||||
}
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'")
|
ethutil.Config.Log.Infoln("FATAL: asset not found: you can set an alternative asset path on on the command line using option 'asset_path'", err)
|
||||||
|
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -235,6 +236,8 @@ func (gui *Gui) update() {
|
|||||||
reactor.Subscribe("object:"+string(namereg), objectChan)
|
reactor.Subscribe("object:"+string(namereg), objectChan)
|
||||||
reactor.Subscribe("peerList", peerChan)
|
reactor.Subscribe("peerList", peerChan)
|
||||||
|
|
||||||
|
ticker := time.NewTicker(5 * time.Second)
|
||||||
|
|
||||||
state := gui.eth.StateManager().TransState()
|
state := gui.eth.StateManager().TransState()
|
||||||
|
|
||||||
unconfirmedFunds := new(big.Int)
|
unconfirmedFunds := new(big.Int)
|
||||||
@ -284,12 +287,19 @@ func (gui *Gui) update() {
|
|||||||
gui.loadAddressBook()
|
gui.loadAddressBook()
|
||||||
case <-peerChan:
|
case <-peerChan:
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
|
case <-ticker.C:
|
||||||
|
gui.setPeerInfo()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) setPeerInfo() {
|
func (gui *Gui) setPeerInfo() {
|
||||||
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
||||||
|
|
||||||
|
gui.win.Root().Call("resetPeers")
|
||||||
|
for _, peer := range gui.pub.GetPeers() {
|
||||||
|
gui.win.Root().Call("addPeer", peer)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Logging functions that log directly to the GUI interface
|
// Logging functions that log directly to the GUI interface
|
||||||
|
@ -66,6 +66,10 @@ func (self *JSEthereum) GetBlock(hash string) otto.Value {
|
|||||||
return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self})
|
return self.toVal(&JSBlock{self.PEthereum.GetBlock(hash), self})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *JSEthereum) GetPeers() otto.Value {
|
||||||
|
return self.toVal(self.PEthereum.GetPeers())
|
||||||
|
}
|
||||||
|
|
||||||
func (self *JSEthereum) GetKey() otto.Value {
|
func (self *JSEthereum) GetKey() otto.Value {
|
||||||
return self.toVal(self.PEthereum.GetKey())
|
return self.toVal(self.PEthereum.GetKey())
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user