Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
go-libp2p
Commits
bafe1b04
Commit
bafe1b04
authored
Jul 01, 2015
by
Lars Gierth
Browse files
swarm: fix peers_total metric
License: MIT Signed-off-by:
Lars Gierth
<
larsg@systemli.org
>
parent
910ebfe9
Changes
2
Hide whitespace changes
Inline
Side-by-side
net/swarm/swarm.go
View file @
bafe1b04
...
...
@@ -289,11 +289,11 @@ func (n *ps2netNotifee) ClosedStream(s *ps.Stream) {
type
metricsNotifiee
Swarm
func
(
nn
*
metricsNotifiee
)
Connected
(
n
inet
.
Network
,
v
inet
.
Conn
)
{
peersTotalGauge
(
n
.
LocalPeer
())
.
Inc
(
)
peersTotalGauge
(
n
.
LocalPeer
())
.
Set
(
float64
(
len
(
n
.
Conns
()))
)
}
func
(
nn
*
metricsNotifiee
)
Disconnected
(
n
inet
.
Network
,
v
inet
.
Conn
)
{
peersTotalGauge
(
n
.
LocalPeer
())
.
Dec
(
)
peersTotalGauge
(
n
.
LocalPeer
())
.
Set
(
float64
(
len
(
n
.
Conns
()))
)
}
func
(
nn
*
metricsNotifiee
)
OpenedStream
(
n
inet
.
Network
,
v
inet
.
Stream
)
{}
...
...
net/swarm/swarm_net.go
View file @
bafe1b04
...
...
@@ -58,12 +58,12 @@ func (n *Network) LocalPeer() peer.ID {
return
n
.
Swarm
()
.
LocalPeer
()
}
// Peers returns the
connected peers
// Peers returns the
known peer IDs from the Peerstore
func
(
n
*
Network
)
Peers
()
[]
peer
.
ID
{
return
n
.
Swarm
()
.
Peers
()
}
// Peers returns the
connected
peers
// Peers returns the
Peerstore, which tracks known
peers
func
(
n
*
Network
)
Peerstore
()
peer
.
Peerstore
{
return
n
.
Swarm
()
.
peers
}
...
...
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