2
0
mirror of synced 2025-02-24 14:48:27 +00:00
torrent/conn_stats.go
2016-07-05 15:52:33 +10:00

24 lines
470 B
Go

package torrent
import (
pp "github.com/anacrolix/torrent/peer_protocol"
)
type ConnStats struct {
ChunksSent int64 // Num piece messages sent.
BytesSent int64 // Total bytes sent.
DataBytesSent int64 // Data-only bytes sent.
}
func (cs *ConnStats) wroteMsg(msg pp.Message) {
switch msg.Type {
case pp.Piece:
cs.ChunksSent++
cs.DataBytesSent += int64(len(msg.Piece))
}
}
func (cs *ConnStats) wroteBytes(b []byte) {
cs.BytesSent += int64(len(b))
}