2
0
mirror of synced 2025-02-23 14:18:13 +00:00

Implement a public Peer.DownloadRate (#750)

This commit is contained in:
Nathanael Demacon 2022-05-23 02:42:51 +02:00 committed by GitHub
parent eeb021b134
commit ed1fe91dd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -351,6 +351,13 @@ func (cn *Peer) downloadRate() float64 {
return float64(num) / cn.totalExpectingTime().Seconds()
}
func (cn *Peer) DownloadRate() float64 {
cn.locker().Lock()
defer cn.locker().Unlock()
return cn.downloadRate()
}
func (cn *Peer) iterContiguousPieceRequests(f func(piece pieceIndex, count int)) {
var last Option[pieceIndex]
var count int