}
const (
- PiecePriorityNone piecePriority = iota // Not wanted.
+ PiecePriorityNone piecePriority = iota // Not wanted. Must be the zero value.
PiecePriorityNormal // Wanted.
PiecePriorityHigh // Wanted a lot.
PiecePriorityReadahead // May be required soon.
hash metainfo.Hash
t *Torrent
index int
+ files []*File
// Chunks we've written to since the last check. The chunk offset and
// length can be determined by the request chunkSize in use.
dirtyChunks bitmap.Bitmap
func (p *Piece) queuedForHash() bool {
return p.t.piecesQueuedForHash.Get(p.index)
}
+
+func (p *Piece) torrentBeginOffset() int64 {
+ return int64(p.index) * p.t.info.PieceLength
+}
+
+func (p *Piece) torrentEndOffset() int64 {
+ return p.torrentBeginOffset() + int64(p.length())
+}