"github.com/anacrolix/missinggo"
"github.com/anacrolix/missinggo/bitmap"
+ "github.com/anacrolix/missinggo/itertools"
"github.com/anacrolix/missinggo/prioritybitmap"
"github.com/bradfitz/iter"
})
}
-func (cn *connection) requestPiecePendingChunks(piece int) (again bool) {
- return cn.t.connRequestPiecePendingChunks(cn, piece)
+func (c *connection) requestPiecePendingChunks(piece int) (again bool) {
+ if !c.PeerHasPiece(piece) {
+ return true
+ }
+ chunkIndices := c.t.pieces[piece].undirtiedChunkIndices().ToSortedSlice()
+ return itertools.ForPerm(len(chunkIndices), func(i int) bool {
+ req := request{pp.Integer(piece), c.t.chunkIndexSpec(chunkIndices[i], piece)}
+ return c.Request(req)
+ })
}
func (cn *connection) stopRequestingPiece(piece int) {
"github.com/anacrolix/missinggo"
"github.com/anacrolix/missinggo/bitmap"
- "github.com/anacrolix/missinggo/itertools"
"github.com/anacrolix/missinggo/perf"
"github.com/anacrolix/missinggo/pubsub"
"github.com/anacrolix/missinggo/slices"
t.unpendPieces(&bm)
}
-func (t *Torrent) connRequestPiecePendingChunks(c *connection, piece int) (more bool) {
- if !c.PeerHasPiece(piece) {
- return true
- }
- chunkIndices := t.pieces[piece].undirtiedChunkIndices().ToSortedSlice()
- return itertools.ForPerm(len(chunkIndices), func(i int) bool {
- req := request{pp.Integer(piece), t.chunkIndexSpec(chunkIndices[i], piece)}
- return c.Request(req)
- })
-}
-
func (t *Torrent) pendRequest(req request) {
ci := chunkIndex(req.chunkSpec, t.chunkSize)
t.pieces[req.Index].pendChunkIndex(ci)