Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
Geth-Modification
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
张蕾
Geth-Modification
Commits
3ff6c9bb
Commit
3ff6c9bb
authored
Feb 13, 2015
by
Jeffrey Wilcke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #309 from fjl/peer-window
Fix Mist Peers Window
parents
49a739c8
8464e43e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
43 additions
and
25 deletions
+43
-25
main.qml
cmd/mist/assets/qml/main.qml
+8
-15
gui.go
cmd/mist/gui.go
+29
-5
ui_lib.go
cmd/mist/ui_lib.go
+0
-5
protocol.go
p2p/protocol.go
+6
-0
No files found.
cmd/mist/assets/qml/main.qml
View file @
3ff6c9bb
...
@@ -341,7 +341,7 @@ ApplicationWindow {
...
@@ -341,7 +341,7 @@ ApplicationWindow {
}
}
Label
{
Label
{
id
:
peerLabel
id
:
peer
Counter
Label
font.pixelSize
:
10
font.pixelSize
:
10
text
:
"0 / 0"
text
:
"0 / 0"
}
}
...
@@ -926,7 +926,6 @@ ApplicationWindow {
...
@@ -926,7 +926,6 @@ ApplicationWindow {
}
}
}
}
function
setWalletValue
(
value
)
{
function
setWalletValue
(
value
)
{
walletValueLabel
.
text
=
value
walletValueLabel
.
text
=
value
}
}
...
@@ -936,17 +935,11 @@ ApplicationWindow {
...
@@ -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
)
{
// 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
),
latency
:
peer
.
latency
,
version
:
peer
.
version
,
caps
:
peer
.
caps
})
}
function
resetPeers
()
{
function
setPeerCounters
(
text
)
{
peer
Model
.
clear
()
peer
CounterLabel
.
text
=
text
}
}
function
timeAgo
(
unixTs
){
function
timeAgo
(
unixTs
){
...
@@ -984,9 +977,9 @@ ApplicationWindow {
...
@@ -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
:
2
60
;
role
:
"version"
;
title
:
"Version
"
}
TableViewColumn
{
width
:
2
80
;
role
:
"nodeID"
;
title
:
"Node ID
"
}
TableViewColumn
{
width
:
180
;
role
:
"caps"
;
title
:
"Capabilities"
}
TableViewColumn
{
width
:
180
;
role
:
"caps"
;
title
:
"Capabilities"
}
}
}
}
}
}
}
...
...
cmd/mist/gui.go
View file @
3ff6c9bb
...
@@ -31,6 +31,7 @@ import (
...
@@ -31,6 +31,7 @@ import (
"os"
"os"
"path"
"path"
"runtime"
"runtime"
"sort"
"strconv"
"strconv"
"time"
"time"
...
@@ -449,6 +450,7 @@ func (gui *Gui) update() {
...
@@ -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
...
@@ -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
{
...
...
cmd/mist/ui_lib.go
View file @
3ff6c9bb
...
@@ -73,11 +73,6 @@ func (self *UiLib) Notef(args []interface{}) {
...
@@ -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
)
...
...
p2p/protocol.go
View file @
3ff6c9bb
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{} {
...
@@ -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
)
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment