From: Matt Joiner Date: Tue, 22 Nov 2016 03:17:30 +0000 (+1100) Subject: Make downloadedChunk a method of connection X-Git-Tag: v1.0.0~535 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=6f9bcff8b215b3d7c7f2c652d2f78720505cef54;p=btrtrc.git Make downloadedChunk a method of connection --- diff --git a/connection.go b/connection.go index be44a290..7eb9ec35 100644 --- a/connection.go +++ b/connection.go @@ -780,7 +780,7 @@ func (c *connection) mainReadLoop() error { case pp.HaveNone: err = c.peerSentHaveNone() case pp.Piece: - cl.downloadedChunk(t, c, &msg) + c.downloadedChunk(&msg) if len(msg.Piece) == int(t.chunkSize) { t.chunkPool.Put(msg.Piece) } @@ -928,7 +928,9 @@ func (cn *connection) rw() io.ReadWriter { } // Handle a received chunk from a peer. -func (cl *Client) downloadedChunk(t *Torrent, c *connection, msg *pp.Message) { +func (c *connection) downloadedChunk(msg *pp.Message) { + t := c.t + cl := t.cl chunksReceived.Add(1) req := newRequest(msg.Index, msg.Begin, pp.Integer(len(msg.Piece)))