7 pp "github.com/anacrolix/torrent/peer_protocol"
10 type ConnStats struct {
11 // Torrent "piece" messages, or data chunks.
12 ChunksWritten int64 // Num piece messages sent.
14 // Total bytes on the wire. Includes handshakes and encryption.
17 // Data bytes, actual torrent data.
18 DataBytesWritten int64
22 func (cs *ConnStats) wroteMsg(msg *pp.Message) {
26 cs.DataBytesWritten += int64(len(msg.Piece))
30 func (cs *ConnStats) readMsg(msg *pp.Message) {
34 cs.DataBytesRead += int64(len(msg.Piece))
38 func (cs *ConnStats) wroteBytes(n int64) {
42 func (cs *ConnStats) readBytes(n int64) {
46 type connStatsReadWriter struct {
52 func (me connStatsReadWriter) Write(b []byte) (n int, err error) {
53 n, err = me.rw.Write(b)
55 me.c.wroteBytes(int64(n))
60 func (me connStatsReadWriter) Read(b []byte) (n int, err error) {
61 n, err = me.rw.Read(b)
63 me.c.readBytes(int64(n))