]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Move peerGotPiece
authorMatt Joiner <anacrolix@gmail.com>
Mon, 21 Mar 2016 03:17:15 +0000 (14:17 +1100)
committerMatt Joiner <anacrolix@gmail.com>
Mon, 21 Mar 2016 03:17:15 +0000 (14:17 +1100)
client.go
connection.go

index 1831e2c5d5d7422215fa19a9286f3b5c08d98a4f..447958e63ca35f7cad6870c32184c6d7d08cc1a2 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1147,26 +1147,6 @@ func (me *Client) sendInitialMessages(conn *connection, torrent *torrent) {
        }
 }
 
-func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) error {
-       if !c.peerHasAll {
-               if t.haveInfo() {
-                       if c.PeerPieces == nil {
-                               c.PeerPieces = make([]bool, t.numPieces())
-                       }
-               } else {
-                       for piece >= len(c.PeerPieces) {
-                               c.PeerPieces = append(c.PeerPieces, false)
-                       }
-               }
-               if piece >= len(c.PeerPieces) {
-                       return errors.New("peer got out of range piece index")
-               }
-               c.PeerPieces[piece] = true
-       }
-       c.updatePiecePriority(piece)
-       return nil
-}
-
 func (me *Client) peerUnchoked(torrent *torrent, conn *connection) {
        conn.updateRequests()
 }
index 1323acfaef631a025e5d805aed3746a6fde1207b..1db26869db248fed427fd9be5be6e992b5700991 100644 (file)
@@ -625,3 +625,23 @@ func (c *connection) discardPieceInclination() {
        c.t.putPieceInclination(c.pieceInclination)
        c.pieceInclination = nil
 }
+
+func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) error {
+       if !c.peerHasAll {
+               if t.haveInfo() {
+                       if c.PeerPieces == nil {
+                               c.PeerPieces = make([]bool, t.numPieces())
+                       }
+               } else {
+                       for piece >= len(c.PeerPieces) {
+                               c.PeerPieces = append(c.PeerPieces, false)
+                       }
+               }
+               if piece >= len(c.PeerPieces) {
+                       return errors.New("peer got out of range piece index")
+               }
+               c.PeerPieces[piece] = true
+       }
+       c.updatePiecePriority(piece)
+       return nil
+}