client.go | 11 ----------- connection.go | 2 +- torrent.go | 11 +++++++++++ diff --git a/client.go b/client.go index 9c0aa622155e8503eadd70fbc589c112cd55c341..4250ef4f43428f11a54cf4133254037e7f83a04f 100644 --- a/client.go +++ b/client.go @@ -34,17 +34,6 @@ pp "github.com/anacrolix/torrent/peer_protocol" "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 60ebb2326595ecde988052a76265e6a294130fa3..945fc879958c80235658a1a32e8f99fa42e1ab94 100644 --- a/connection.go +++ b/connection.go @@ -987,7 +987,7 @@ // 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 cdeb7ceed510483cfbcbd1ad64989263cecf68dc..6702be8510e9ba5576a8f318ce53becc13c2f8df 100644 --- a/torrent.go +++ b/torrent.go @@ -1546,3 +1546,14 @@ ret = append(ret, c) } 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) +}