return
}
+// Marks the pieces in the given region for download.
func (t Torrent) SetRegionPriority(off, len int64) {
t.cl.mu.Lock()
defer t.cl.mu.Unlock()
post chan pp.Message
writeCh chan []byte
- // The connections preferred order to download pieces.
+ // The connection's preferred order to download pieces. The index is the
+ // piece, the value is its priority.
piecePriorities []int
// The piece request order based on piece priorities.
pieceRequestOrder *pieceordering.Instance
// Priority regions not to scale. Within each region, piece is randomized
// according to connection.
+ // <-request first -- last->
// [ Now ]
// [ Next ]
// [ Readahead ]
// Maintains piece integers by their ascending assigned keys.
type Instance struct {
- sl *skiplist.SkipList
+ // Contains the ascending priority keys. The keys contain a slice of piece
+ // indices.
+ sl *skiplist.SkipList
+ // Maps from piece index back to its key, so that it can be remove
+ // efficiently from the skip list.
pieceKeys map[int]int
}
me.shuffleItem(key)
}
+// Shuffle the piece indices that share a given key.
func (me *Instance) shuffleItem(key int) {
_item, ok := me.sl.Get(key)
if !ok {
pp "github.com/anacrolix/torrent/peer_protocol"
)
+// Piece priority describes the importance of obtaining a particular piece.
+
type piecePriority byte
const (
)
type piece struct {
- Hash pieceSum
- // Chunks we don't have. The offset and length can be determined by our
+ Hash pieceSum // The completed piece SHA1 hash, from the metainfo "pieces" field.
+ // Chunks we don't have. The offset and length can be determined by the
// request chunkSize in use.
PendingChunkSpecs []bool
Hashing bool