1
0
mirror of https://github.com/libp2p/go-libp2p-peerstore.git synced 2025-03-24 13:10:06 +08:00
go-libp2p-peerstore/metrics.go

26 lines
723 B
Go
Raw Permalink Normal View History

2016-06-01 02:31:50 +08:00
package peerstore
2015-10-01 06:42:55 +08:00
import (
"time"
2016-06-01 02:31:50 +08:00
2022-08-18 20:53:06 +08:00
"github.com/libp2p/go-libp2p/core/peer"
"github.com/libp2p/go-libp2p/p2p/host/peerstore"
2015-10-01 06:42:55 +08:00
)
2021-10-23 20:31:58 +08:00
// LatencyEWMASmoothing governs the decay of the EWMA (the speed
2015-10-01 06:42:55 +08:00
// at which it changes). This must be a normalized (0-1) value.
// 1 is 100% change, 0 is no change.
2022-08-18 20:53:06 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore.LatencyEWMASmoothing instead
var LatencyEWMASmoothing = peerstore.LatencyEWMASmoothing
2015-10-01 06:42:55 +08:00
2022-08-18 20:53:06 +08:00
type metrics interface {
RecordLatency(peer.ID, time.Duration)
LatencyEWMA(peer.ID) time.Duration
RemovePeer(p peer.ID)
2015-10-01 06:42:55 +08:00
}
2022-08-18 20:53:06 +08:00
// Deprecated: use github.com/libp2p/go-libp2p/p2p/host/peerstore.NewMetrics instead
func NewMetrics() metrics {
return peerstore.NewMetrics()
2015-10-01 06:42:55 +08:00
}