From 6f9bcff8b215b3d7c7f2c652d2f78720505cef54 Mon Sep 17 00:00:00 2001
From: Matt Joiner <anacrolix@gmail.com>
Date: Tue, 22 Nov 2016 14:17:30 +1100
Subject: [PATCH] Make downloadedChunk a method of connection

---
 connection.go | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

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)))
-- 
2.51.0