connection.go | 11 +++++------ diff --git a/connection.go b/connection.go index 63bb58fce0c8839faac231d76ca122ae6098bdf0..3e29e3197786cda84c7a8f06190e35de51672cce 100644 --- a/connection.go +++ b/connection.go @@ -17,7 +17,6 @@ "github.com/anacrolix/missinggo" "github.com/anacrolix/missinggo/bitmap" "github.com/anacrolix/missinggo/prioritybitmap" - "github.com/anacrolix/missinggo/slices" "github.com/bradfitz/iter" "github.com/anacrolix/torrent/bencode" @@ -684,10 +683,10 @@ } return t.connHasWantedPieces(c) } -func (c *connection) lastHelpful() time.Time { - lasts := []time.Time{c.lastUsefulChunkReceived} - if c.t.seeding() { - lasts = append(lasts, c.lastChunkSent) +func (c *connection) lastHelpful() (ret time.Time) { + ret = c.lastUsefulChunkReceived + if c.t.seeding() && c.lastChunkSent.After(ret) { + ret = c.lastChunkSent } - return missinggo.Max(time.Time.Before, slices.ToEmptyInterface(lasts)...).(time.Time) + return }