]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Make downloadedChunk a method of connection
authorMatt Joiner <anacrolix@gmail.com>
Tue, 22 Nov 2016 03:17:30 +0000 (14:17 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 22 Nov 2016 03:17:30 +0000 (14:17 +1100)
connection.go

index be44a29048b5e0791088a21c965a14d334e040a1..7eb9ec3572a76bc56cecd4f48abd8f5643edfc84 100644 (file)
@@ -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)))