const (
pieceHash = crypto.SHA1
defaultChunkSize = 0x4000 // 16KiB
-
+
// Arbitrary maximum of "metadata_size" (see https://www.bittorrent.org/beps/bep_0009.html)
// This value is 2x what libtorrent-rasterbar uses, which should be plenty
- maxMetadataSize uint32 = 8*1024*1024
+ maxMetadataSize uint32 = 8 * 1024 * 1024
)
// These are our extended message IDs. Peers will use these values to
}
type reader struct {
- t *Torrent
+ t *Torrent
// Adjust the read/seek window to handle Readers locked to File extents and the like.
offset, length int64
-
+
// Function to dynamically calculate readahead. If nil, readahead is static.
readaheadFunc func() int64
-
+
// Required when modifying pos and readahead.
- mu sync.Locker
+ mu sync.Locker
readahead, pos int64
// Position that reads have continued contiguously from.
// after a seek or with a new reader at the starting position.
reading bool
responsive bool
-
}
var _ io.ReadSeekCloser = (*reader)(nil)
t.cl.rLock()
ps = t.pieceState(piece)
t.cl.rUnlock()
- return
+ return
}
// The number of pieces in the torrent. This requires that the info has been