From: Matt Joiner Date: Mon, 25 Oct 2021 05:17:55 +0000 (+1100) Subject: Record webseed request result bytes against client stats X-Git-Tag: v1.34.0^2~8 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=28726f737c444037116c9d3896229580aea2c2d4;p=btrtrc.git Record webseed request result bytes against client stats Should fix the issue where webseeds cause >100% useful data readings. --- diff --git a/peerconn.go b/peerconn.go index c1b98c2a..e17d2116 100644 --- a/peerconn.go +++ b/peerconn.go @@ -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 })) } diff --git a/webseed-peer.go b/webseed-peer.go index fb981585..71cdfcb4 100644 --- a/webseed-peer.go +++ b/webseed-peer.go @@ -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 {