]> Sergey Matveev's repositories - btrtrc.git/blob - conn_stats.go
Add counters for uploads
[btrtrc.git] / conn_stats.go
1 package torrent
2
3 import (
4         pp "github.com/anacrolix/torrent/peer_protocol"
5 )
6
7 type ConnStats struct {
8         ChunksSent    int64 // Num piece messages sent.
9         BytesSent     int64 // Total bytes sent.
10         DataBytesSent int64 // Data-only bytes sent.
11 }
12
13 func (cs *ConnStats) wroteMsg(msg pp.Message) {
14         switch msg.Type {
15         case pp.Piece:
16                 cs.ChunksSent++
17                 cs.DataBytesSent += int64(len(msg.Piece))
18         }
19 }
20
21 func (cs *ConnStats) wroteBytes(b []byte) {
22         cs.BytesSent += int64(len(b))
23 }