Move method queuePieceCheck
This commit is contained in:
parent
d48c7c8e36
commit
186b5073d2
11
client.go
11
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 {
|
||||
|
|
|
@ -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 {
|
||||
|
|
11
torrent.go
11
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)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue