From: Matt Joiner Date: Sun, 1 Jan 2017 00:02:37 +0000 (+1100) Subject: Move method queuePieceCheck X-Git-Tag: v1.0.0~502 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=186b5073d2264cc1dc455093aeff18218ee22ca5;p=btrtrc.git Move method queuePieceCheck --- diff --git a/client.go b/client.go index 9c0aa622..4250ef4f 100644 --- a/client.go +++ b/client.go @@ -34,17 +34,6 @@ import ( "github.com/anacrolix/torrent/storage" ) -// Currently doesn't really queue, but should in the future. -func (cl *Client) queuePieceCheck(t *Torrent, pieceIndex int) { - piece := &t.pieces[pieceIndex] - if piece.QueuedForHash { - return - } - piece.QueuedForHash = true - t.publishPieceChange(pieceIndex) - go t.verifyPiece(pieceIndex) -} - // Clients contain zero or more Torrents. A Client manages a blocklist, the // TCP/UDP protocol ports, and DHT as desired. type Client struct { diff --git a/connection.go b/connection.go index 60ebb232..945fc879 100644 --- a/connection.go +++ b/connection.go @@ -987,7 +987,7 @@ func (c *connection) receiveChunk(msg *pp.Message) { // It's important that the piece is potentially queued before we check if // the piece is still wanted, because if it is queued, it won't be wanted. if t.pieceAllDirty(index) { - cl.queuePieceCheck(t, int(req.Index)) + t.queuePieceCheck(int(req.Index)) } if c.peerTouchedPieces == nil { diff --git a/torrent.go b/torrent.go index cdeb7cee..6702be85 100644 --- a/torrent.go +++ b/torrent.go @@ -1546,3 +1546,14 @@ func (t *Torrent) connsAsSlice() (ret []*connection) { } return } + +// Currently doesn't really queue, but should in the future. +func (t *Torrent) queuePieceCheck(pieceIndex int) { + piece := &t.pieces[pieceIndex] + if piece.QueuedForHash { + return + } + piece.QueuedForHash = true + t.publishPieceChange(pieceIndex) + go t.verifyPiece(pieceIndex) +}