Move method queuePieceCheck

This commit is contained in:
Matt Joiner 2017-01-01 11:02:37 +11:00
parent d48c7c8e36
commit 186b5073d2
3 changed files with 12 additions and 12 deletions

View File

@ -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 {

View File

@ -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 {

View File

@ -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)
}