"time"
"github.com/anacrolix/missinggo"
- "github.com/anacrolix/missinggo/itertools"
"github.com/anacrolix/missinggo/prioritybitmap"
"github.com/anacrolix/torrent/bencode"
}
func (c *connection) fillRequests() {
- itertools.ForIterable(&c.pieceRequestOrder, func(_piece interface{}) (more bool) {
- return c.requestPiecePendingChunks(_piece.(int))
+ c.pieceRequestOrder.IterTyped(func(piece int) (more bool) {
+ return c.requestPiecePendingChunks(piece)
})
}
"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/bradfitz/iter"
}
func (t *torrent) connHasWantedPieces(c *connection) bool {
- for it := t.pendingPieces.IterTyped(); it.Next(); {
- if c.PeerHasPiece(it.ValueInt()) {
- it.Stop()
- return true
- }
- }
- return !t.forReaderOffsetPieces(func(begin, end int) (again bool) {
- for i := begin; i < end; i++ {
- if c.PeerHasPiece(i) {
- return false
- }
- }
- return true
- })
+ return !c.pieceRequestOrder.IsEmpty()
}
func (t *torrent) extentPieces(off, _len int64) (pieces []int) {
func (t *torrent) updatePiecePriorities() {
newPrios := make([]piecePriority, t.numPieces())
- itertools.ForIterable(&t.pendingPieces, func(value interface{}) (next bool) {
- newPrios[value.(int)] = PiecePriorityNormal
+ t.pendingPieces.IterTyped(func(piece int) (more bool) {
+ newPrios[piece] = PiecePriorityNormal
return true
})
t.forReaderOffsetPieces(func(begin, end int) (next bool) {