r.SetReadahead(ps.Readahead)
}
assertReadAllGreeting(t, r)
- assert.True(t, 13 <= seederTorrent.Stats().DataBytesWritten)
+ assert.True(t, 13 <= seederTorrent.Stats().BytesWrittenData)
assert.True(t, 8 <= seederTorrent.Stats().ChunksWritten)
- assert.True(t, 13 <= leecherTorrent.Stats().DataBytesRead)
+ assert.True(t, 13 <= leecherTorrent.Stats().BytesReadData)
assert.True(t, 8 <= leecherTorrent.Stats().ChunksRead)
// Try reading through again for the cases where the torrent data size
// exceeds the size of the cache.
// is things sent to the peer, and Read is stuff received from them.
type ConnStats struct {
// Total bytes on the wire. Includes handshakes and encryption.
- BytesWritten int64
- BytesRead int64
+ BytesWritten int64
+ BytesWrittenData int64
- // The rest of the stats only occur on connections after handshakes.
+ BytesRead int64
+ BytesReadData int64
+ BytesReadUsefulData int64
ChunksWritten int64
ChunksReadUseful int64
ChunksReadUnwanted int64
- DataBytesWritten int64
- DataBytesRead int64
- UsefulDataBytesRead int64
-
// Number of pieces data was written to, that subsequently passed verification.
- GoodPiecesDirtied int64
+ PiecesDirtiedGood int64
// Number of pieces data was written to, that subsequently failed
// verification. Note that a connection may not have been the sole dirtier
// of a piece.
- BadPiecesDirtied int64
+ PiecesDirtiedBad int64
}
func (cs *ConnStats) wroteMsg(msg *pp.Message) {
switch msg.Type {
case pp.Piece:
cs.ChunksWritten++
- cs.DataBytesWritten += int64(len(msg.Piece))
+ cs.BytesWrittenData += int64(len(msg.Piece))
}
}
switch msg.Type {
case pp.Piece:
cs.ChunksRead++
- cs.DataBytesRead += int64(len(msg.Piece))
+ cs.BytesReadData += int64(len(msg.Piece))
}
}
return false
}
// Don't upload more than 100 KiB more than we download.
- if c.stats.DataBytesWritten >= c.stats.DataBytesRead+100<<10 {
+ if c.stats.BytesWrittenData >= c.stats.BytesReadData+100<<10 {
return false
}
return true
}
func (cn *connection) netGoodPiecesDirtied() int64 {
- return cn.stats.GoodPiecesDirtied - cn.stats.BadPiecesDirtied
+ return cn.stats.PiecesDirtiedGood - cn.stats.PiecesDirtiedBad
}
func (c *connection) peerHasWantedPieces() bool {
p.everHashed = true
if correct {
for _, c := range touchers {
- c.stats.GoodPiecesDirtied++
+ c.stats.PiecesDirtiedGood++
}
err := p.Storage().MarkComplete()
if err != nil {
if len(touchers) != 0 {
for _, c := range touchers {
// Y u do dis peer?!
- c.stats.BadPiecesDirtied++
+ c.stats.PiecesDirtiedBad++
}
slices.Sort(touchers, connLessTrusted)
if t.cl.config.Debug {