From 28726f737c444037116c9d3896229580aea2c2d4 Mon Sep 17 00:00:00 2001 From: Matt Joiner Date: Mon, 25 Oct 2021 16:17:55 +1100 Subject: [PATCH] Record webseed request result bytes against client stats Should fix the issue where webseeds cause >100% useful data readings. --- peerconn.go | 2 +- webseed-peer.go | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) 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 {