1
0
mirror of https://github.com/libp2p/go-libp2p-core.git synced 2025-04-27 17:00:21 +08:00

Add API to reset bandwidth counters

This commit is contained in:
Roman Proskuryakov 2019-11-01 04:25:27 +03:00
parent f94ed8d804
commit 7dbbdcc417
3 changed files with 20 additions and 0 deletions

4
go.mod
View File

@ -18,4 +18,8 @@ require (
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550
)
//replace github.com/libp2p/go-flow-metrics v0.0.1 => github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4 // Stebalien's version
replace github.com/libp2p/go-flow-metrics v0.0.1 => github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222 // kpp's version
go 1.12

4
go.sum
View File

@ -59,6 +59,10 @@ github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+o
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23 h1:FOOIBWrEkLgmlgGfMuZT83xIwfPDxEI2OHu6xUmJMFE=
github.com/kkdai/bstream v0.0.0-20161212061736-f391b8402d23/go.mod h1:J+Gs4SYgM6CZQHDETBtE9HaSEkGmuNXF86RwHhHUvq4=
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222 h1:6Pnw+RUnFR7FY6wEQbqFj+aPrp7bMptn02jEAruMPLk=
github.com/kpp/go-flow-metrics v0.0.2-0.20191031231915-edeb2d90f222/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4 h1:wZFgH2qCaRIN+wb0B8e2HuI2JzdrLOMvVxU0cqvZB2g=
github.com/kpp/go-flow-metrics v0.0.2-0.20191101005412-ce5ebda5e4a4/go.mod h1:HeoSNUrOJVK1jEpDqVEiUOIXqhbnS27omG0uWU5slZs=
github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI=
github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo=
github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ=

View File

@ -151,3 +151,15 @@ func (bwc *BandwidthCounter) GetBandwidthByProtocol() map[protocol.ID]Stats {
return protocols
}
// Reset clears all stats.
func (bwc *BandwidthCounter) Reset() {
bwc.totalIn.Reset()
bwc.totalOut.Reset()
bwc.protocolIn.Clear()
bwc.protocolOut.Clear()
bwc.peerIn.Clear()
bwc.peerOut.Clear()
}