connection.go | 8 ++++++-- torrent.go | 4 ---- diff --git a/connection.go b/connection.go index 39fc46cbbf8e59eda974df978b6d9a9eb1c521c8..aca2b348587a1b16ac155aaddda38d0a768b5260 100644 --- a/connection.go +++ b/connection.go @@ -698,7 +698,7 @@ } if t.seeding() { return c.PeerInterested } - return t.connHasWantedPieces(c) + return c.peerHasWantedPieces() } func (c *connection) lastHelpful() (ret time.Time) { @@ -1023,7 +1023,7 @@ if !c.PeerInterested { return } seeding := t.seeding() - if !seeding && !t.connHasWantedPieces(c) { + if !seeding && !c.peerHasWantedPieces() { // There's no reason to upload to this peer. return } @@ -1079,3 +1079,7 @@ func (cn *connection) netGoodPiecesDirtied() int { return cn.goodPiecesDirtied - cn.badPiecesDirtied } + +func (c *connection) peerHasWantedPieces() bool { + return !c.pieceRequestOrder.IsEmpty() +} diff --git a/torrent.go b/torrent.go index 337040f5dd7303376748ffa021fb42d1d433c26c..8230acbfd574ad7164c44b28b55d304713c82644 100644 --- a/torrent.go +++ b/torrent.go @@ -713,10 +713,6 @@ return index < begin || index >= end }) } -func (t *Torrent) connHasWantedPieces(c *connection) bool { - return !c.pieceRequestOrder.IsEmpty() -} - // The worst connection is one that hasn't been sent, or sent anything useful // for the longest. A bad connection is one that usually sends us unwanted // pieces, or has been in worser half of the established connections for more