From cf4d979669dd4a954ab0df62abb4cac5a1888afb Mon Sep 17 00:00:00 2001 From: Cenk Alti Date: Mon, 18 Feb 2019 16:03:13 +0300 Subject: [PATCH] more comments --- internal/peerconn/peerreader/peerreader.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/internal/peerconn/peerreader/peerreader.go b/internal/peerconn/peerreader/peerreader.go index 5e298998..0fc5072c 100644 --- a/internal/peerconn/peerreader/peerreader.go +++ b/internal/peerconn/peerreader/peerreader.go @@ -192,16 +192,19 @@ func (p *PeerReader) Run() { n, err = io.ReadFull(p.buf, data) if err != nil { if nerr, ok := err.(net.Error); ok && nerr.Timeout() { - // Peer couldn't send the block in allowed time. + // Peer didn't send the full block in allowed time. if n == 0 { + // Disconnect if no bytes received. return } + // Some bytes received, peer appears to be slow, keep receiving the rest. m += n data = data[n:] continue } return } + // Received full block. break } msg = Piece{PieceMessage: pm, buffer: buf, Data: data}