global.go | 4 ++-- reader.go | 9 ++++----- t.go | 2 +- diff --git a/global.go b/global.go index 4e48d0c550ea9eb5881ba2e60a1d29824764f68c..bd94fe55c45cb64021636f4b7fe91e306de83599 100644 --- a/global.go +++ b/global.go @@ -10,10 +10,10 @@ 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 diff --git a/reader.go b/reader.go index 3b407ce34f823f247cfbd2f789b13678c1b52bab..bdeb34f64812da2ed455d41d9009d278a6c58ec4 100644 --- a/reader.go +++ b/reader.go @@ -30,15 +30,15 @@ begin, end pieceIndex } 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. @@ -52,7 +52,6 @@ // Reads have been initiated since the last seek. This is used to prevent readaheads occurring // after a seek or with a new reader at the starting position. reading bool responsive bool - } var _ io.ReadSeekCloser = (*reader)(nil) diff --git a/t.go b/t.go index 2c076386b0856899d44fa657b74d2c92c51c4b14..51c76d5b0423fc3d59783630a15693780d00821e 100644 --- a/t.go +++ b/t.go @@ -78,7 +78,7 @@ func (t *Torrent) PieceState(piece pieceIndex) (ps PieceState) { 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