forked from cerc-io/plugeth
Merge branch 'develop' of github.com-obscure:ethereum/go-ethereum into develop
This commit is contained in:
commit
65159d65c8
@ -341,7 +341,7 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Label {
|
Label {
|
||||||
id: peerLabel
|
id: peerCounterLabel
|
||||||
font.pixelSize: 10
|
font.pixelSize: 10
|
||||||
text: "0 / 0"
|
text: "0 / 0"
|
||||||
}
|
}
|
||||||
@ -926,7 +926,6 @@ ApplicationWindow {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function setWalletValue(value) {
|
function setWalletValue(value) {
|
||||||
walletValueLabel.text = value
|
walletValueLabel.text = value
|
||||||
}
|
}
|
||||||
@ -936,17 +935,11 @@ ApplicationWindow {
|
|||||||
var view = mainView.addPlugin(name)
|
var view = mainView.addPlugin(name)
|
||||||
}
|
}
|
||||||
|
|
||||||
function setPeers(text) {
|
function clearPeers() { peerModel.clear() }
|
||||||
peerLabel.text = text
|
function addPeer(peer) { peerModel.append(peer) }
|
||||||
}
|
|
||||||
|
|
||||||
function addPeer(peer) {
|
function setPeerCounters(text) {
|
||||||
// We could just append the whole peer object but it cries if you try to alter them
|
peerCounterLabel.text = text
|
||||||
peerModel.append({ip: peer.ip, port: peer.port, lastResponse:timeAgo(peer.lastSend), latency: peer.latency, version: peer.version, caps: peer.caps})
|
|
||||||
}
|
|
||||||
|
|
||||||
function resetPeers(){
|
|
||||||
peerModel.clear()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function timeAgo(unixTs){
|
function timeAgo(unixTs){
|
||||||
@ -984,9 +977,9 @@ ApplicationWindow {
|
|||||||
anchors.fill: parent
|
anchors.fill: parent
|
||||||
id: peerTable
|
id: peerTable
|
||||||
model: peerModel
|
model: peerModel
|
||||||
TableViewColumn{width: 200; role: "ip" ; title: "IP" }
|
TableViewColumn{width: 180; role: "addr" ; title: "Remote Address" }
|
||||||
TableViewColumn{width: 260; role: "version" ; title: "Version" }
|
TableViewColumn{width: 280; role: "nodeID" ; title: "Node ID" }
|
||||||
TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" }
|
TableViewColumn{width: 180; role: "caps" ; title: "Capabilities" }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,6 +31,7 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
"sort"
|
||||||
"strconv"
|
"strconv"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
@ -449,6 +450,7 @@ func (gui *Gui) update() {
|
|||||||
|
|
||||||
case <-peerUpdateTicker.C:
|
case <-peerUpdateTicker.C:
|
||||||
gui.setPeerInfo()
|
gui.setPeerInfo()
|
||||||
|
|
||||||
case <-generalUpdateTicker.C:
|
case <-generalUpdateTicker.C:
|
||||||
statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number().String()
|
statusText := "#" + gui.eth.ChainManager().CurrentBlock().Number().String()
|
||||||
lastBlockLabel.Set("text", statusText)
|
lastBlockLabel.Set("text", statusText)
|
||||||
@ -499,12 +501,34 @@ NumGC: %d
|
|||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type qmlpeer struct{ Addr, NodeID, Caps string }
|
||||||
|
|
||||||
|
type peersByID []*qmlpeer
|
||||||
|
|
||||||
|
func (s peersByID) Len() int { return len(s) }
|
||||||
|
func (s peersByID) Less(i, j int) bool { return s[i].NodeID < s[j].NodeID }
|
||||||
|
func (s peersByID) Swap(i, j int) { s[i], s[j] = s[j], s[i] }
|
||||||
|
|
||||||
func (gui *Gui) setPeerInfo() {
|
func (gui *Gui) setPeerInfo() {
|
||||||
gui.win.Root().Call("setPeers", fmt.Sprintf("%d / %d", gui.eth.PeerCount(), gui.eth.MaxPeers))
|
peers := gui.eth.Peers()
|
||||||
gui.win.Root().Call("resetPeers")
|
qpeers := make(peersByID, len(peers))
|
||||||
//for _, peer := range gui.xeth.Peers() {
|
for i, p := range peers {
|
||||||
//gui.win.Root().Call("addPeer", peer)
|
qpeers[i] = &qmlpeer{
|
||||||
//}
|
NodeID: p.ID().String(),
|
||||||
|
Addr: p.RemoteAddr().String(),
|
||||||
|
Caps: fmt.Sprint(p.Caps()),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// we need to sort the peers because they jump around randomly
|
||||||
|
// otherwise. order returned by eth.Peers is random because they
|
||||||
|
// are taken from a map.
|
||||||
|
sort.Sort(qpeers)
|
||||||
|
|
||||||
|
gui.win.Root().Call("setPeerCounters", fmt.Sprintf("%d / %d", len(peers), gui.eth.MaxPeers()))
|
||||||
|
gui.win.Root().Call("clearPeers")
|
||||||
|
for _, p := range qpeers {
|
||||||
|
gui.win.Root().Call("addPeer", p)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (gui *Gui) privateKey() string {
|
func (gui *Gui) privateKey() string {
|
||||||
|
@ -73,11 +73,6 @@ func (self *UiLib) Notef(args []interface{}) {
|
|||||||
guilogger.Infoln(args...)
|
guilogger.Infoln(args...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (self *UiLib) PastPeers() *ethutil.List {
|
|
||||||
return ethutil.NewList([]string{})
|
|
||||||
//return ethutil.NewList(eth.PastPeers())
|
|
||||||
}
|
|
||||||
|
|
||||||
func (self *UiLib) ImportTx(rlpTx string) {
|
func (self *UiLib) ImportTx(rlpTx string) {
|
||||||
tx := types.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
|
tx := types.NewTransactionFromBytes(ethutil.Hex2Bytes(rlpTx))
|
||||||
err := self.eth.TxPool().Add(tx)
|
err := self.eth.TxPool().Add(tx)
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package p2p
|
package p2p
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
// Protocol represents a P2P subprotocol implementation.
|
// Protocol represents a P2P subprotocol implementation.
|
||||||
type Protocol struct {
|
type Protocol struct {
|
||||||
// Name should contain the official protocol name,
|
// Name should contain the official protocol name,
|
||||||
@ -37,6 +39,10 @@ func (cap Cap) RlpData() interface{} {
|
|||||||
return []interface{}{cap.Name, cap.Version}
|
return []interface{}{cap.Name, cap.Version}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cap Cap) String() string {
|
||||||
|
return fmt.Sprintf("%s/%d", cap.Name, cap.Version)
|
||||||
|
}
|
||||||
|
|
||||||
type capsByName []Cap
|
type capsByName []Cap
|
||||||
|
|
||||||
func (cs capsByName) Len() int { return len(cs) }
|
func (cs capsByName) Len() int { return len(cs) }
|
||||||
|
Loading…
Reference in New Issue
Block a user