]> Sergey Matveev's repositories - btrtrc.git/blobdiff - client.go
Reintroduce connection piece inclinations, and begin caching piece priorities
[btrtrc.git] / client.go
index 2daff28265c416fb5cf8360e635c052cfbfe5bfd..2def4f902b94b60b6e75a2690f2f70f2c2b27331 100644 (file)
--- a/client.go
+++ b/client.go
@@ -1184,9 +1184,7 @@ func (me *Client) peerGotPiece(t *torrent, c *connection, piece int) error {
                }
                c.PeerPieces[piece] = true
        }
-       if t.wantPiece(piece) {
-               c.updateRequests()
-       }
+       c.updatePiecePriority(piece)
        return nil
 }
 
@@ -1625,6 +1623,7 @@ func (me *Client) deleteConnection(t *torrent, c *connection) bool {
 func (me *Client) dropConnection(t *torrent, c *connection) {
        me.event.Broadcast()
        c.Close()
+
        if me.deleteConnection(t, c) {
                me.openNewConns(t)
        }
@@ -2055,6 +2054,7 @@ func (cl *Client) AddTorrentSpec(spec *TorrentSpec) (T Torrent, new bool, err er
                }
                // TODO: Tidy this up?
                t = newTorrent(spec.InfoHash)
+               t.cl = cl
                if spec.ChunkSize != 0 {
                        t.chunkSize = pp.Integer(spec.ChunkSize)
                }