Skip to content

Commit

Permalink
more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
cenkalti committed Feb 18, 2019
1 parent 57baeda commit cf4d979
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion internal/peerconn/peerreader/peerreader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down

0 comments on commit cf4d979

Please sign in to comment.