]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Record webseed request result bytes against client stats
authorMatt Joiner <anacrolix@gmail.com>
Mon, 25 Oct 2021 05:17:55 +0000 (16:17 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 25 Oct 2021 05:17:55 +0000 (16:17 +1100)
Should fix the issue where webseeds cause >100% useful data readings.

peerconn.go
webseed-peer.go

index c1b98c2ade52405b3989fba3e736840db60069df..e17d211680bb7a1e8aa0f19bf654b26326ac1b1f 100644 (file)
@@ -869,7 +869,7 @@ func (cn *PeerConn) wroteBytes(n int64) {
        cn.allStats(add(n, func(cs *ConnStats) *Count { return &cs.BytesWritten }))
 }
 
-func (cn *PeerConn) readBytes(n int64) {
+func (cn *Peer) readBytes(n int64) {
        cn.allStats(add(n, func(cs *ConnStats) *Count { return &cs.BytesRead }))
 }
 
index fb981585be2b6925311e34e58e54db649f3285a7..71cdfcb4c7ce43f62b34ad9dc36b0ad9d375b0ed 100644 (file)
@@ -126,6 +126,7 @@ func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest webseed.Re
        // sure if we can divine which errors indicate cancellation on our end without hitting the
        // network though.
        ws.peer.doChunkReadStats(int64(len(result.Bytes)))
+       ws.peer.readBytes(int64(len(result.Bytes)))
        ws.peer.t.cl.lock()
        defer ws.peer.t.cl.unlock()
        if result.Err != nil {