]> Sergey Matveev's repositories - btrtrc.git/blobdiff - webseed-peer.go
Track chunks read for webseed peers too
[btrtrc.git] / webseed-peer.go
index 7af892f0ff09579a011f0a3b628a869456c135ee..f2ccbff5550df6cc414ad5f5f5b3e96dd35527af 100644 (file)
@@ -110,6 +110,10 @@ func (ws *webseedPeer) onClose() {
 
 func (ws *webseedPeer) requestResultHandler(r Request, webseedRequest webseed.Request) {
        result := <-webseedRequest.Result
+       // We do this here rather than inside receiveChunk, since we want to count errors too. I'm not
+       // 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.t.cl.lock()
        defer ws.peer.t.cl.unlock()
        if result.Err != nil {