reader.go | 10 ++++++++++ t.go | 8 ++++++++ diff --git a/reader.go b/reader.go index b73b8bad4aeb57865086189a67f76ca26bc82616..1c8bce797dc4d9b9450ca5a865cc039b5b0a64b0 100644 --- a/reader.go +++ b/reader.go @@ -44,6 +44,11 @@ func (r *Reader) SetResponsive() { r.responsive = true } +// Disable responsive mode. +func (r *Reader) SetNonResponsive() { + r.responsive = false +} + // Configure the number of bytes ahead of a read that should also be // prioritized in preparation for further reads. func (r *Reader) SetReadahead(readahead int64) { @@ -53,6 +58,11 @@ r.mu.Unlock() r.t.cl.mu.Lock() defer r.t.cl.mu.Unlock() r.posChanged() +} + +// Return reader's current position. +func (r *Reader) CurrentPos() int64 { + return r.pos } func (r *Reader) readable(off int64) (ret bool) { diff --git a/t.go b/t.go index ed810a5fd08d98d3d1f50babbc1063105d7c851e..3fe2ae79ad37afaa453ddf8c25fb5eae34cce6d3 100644 --- a/t.go +++ b/t.go @@ -61,6 +61,14 @@ func (t *Torrent) NumPieces() int { return t.numPieces() } +// Get missing bytes count for specific piece. +func (t *Torrent) PieceBytesMissing(piece int) int64 { + t.cl.mu.Lock() + defer t.cl.mu.Unlock() + + return int64(t.pieces[piece].bytesLeft()) +} + // Drop the torrent from the client, and close it. It's always safe to do // this. No data corruption can, or should occur to either the torrent's data, // or connected peers.