From: Matt Joiner Date: Thu, 1 Feb 2018 07:49:53 +0000 (+1100) Subject: When seeding, connections are not just useful when they're interested X-Git-Tag: v1.0.0~234 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=186c5df3d3d2bc7528f01ce0b8ce34668daffced;p=btrtrc.git When seeding, connections are not just useful when they're interested Improves peer selection when seeding is enabled, we're still downloading. --- diff --git a/connection.go b/connection.go index f53402b4..4147cd76 100644 --- a/connection.go +++ b/connection.go @@ -794,7 +794,7 @@ func (cn *connection) readBytes(n int64) { } } -// Returns whether the connection is currently useful to us. We're seeding and +// Returns whether the connection could be useful to us. We're seeding and // they want data, we don't have metainfo and they can provide it, etc. func (c *connection) useful() bool { t := c.t @@ -804,10 +804,13 @@ func (c *connection) useful() bool { if !t.haveInfo() { return c.supportsExtension("ut_metadata") } - if t.seeding() { - return c.PeerInterested + if t.seeding() && c.PeerInterested { + return true + } + if c.peerHasWantedPieces() { + return true } - return c.peerHasWantedPieces() + return false } func (c *connection) lastHelpful() (ret time.Time) {