Commit bafe1b04 authored by Lars Gierth's avatar Lars Gierth
Browse files

swarm: fix peers_total metric



License: MIT
Signed-off-by: default avatarLars Gierth <larsg@systemli.org>
parent 910ebfe9
...@@ -289,11 +289,11 @@ func (n *ps2netNotifee) ClosedStream(s *ps.Stream) { ...@@ -289,11 +289,11 @@ func (n *ps2netNotifee) ClosedStream(s *ps.Stream) {
type metricsNotifiee Swarm type metricsNotifiee Swarm
func (nn *metricsNotifiee) Connected(n inet.Network, v inet.Conn) { 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) { 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) {} func (nn *metricsNotifiee) OpenedStream(n inet.Network, v inet.Stream) {}
......
...@@ -58,12 +58,12 @@ func (n *Network) LocalPeer() peer.ID { ...@@ -58,12 +58,12 @@ func (n *Network) LocalPeer() peer.ID {
return n.Swarm().LocalPeer() return n.Swarm().LocalPeer()
} }
// Peers returns the connected peers // Peers returns the known peer IDs from the Peerstore
func (n *Network) Peers() []peer.ID { func (n *Network) Peers() []peer.ID {
return n.Swarm().Peers() return n.Swarm().Peers()
} }
// Peers returns the connected peers // Peers returns the Peerstore, which tracks known peers
func (n *Network) Peerstore() peer.Peerstore { func (n *Network) Peerstore() peer.Peerstore {
return n.Swarm().peers return n.Swarm().peers
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment