From: Matt Joiner Date: Thu, 17 Aug 2017 15:48:19 +0000 (+1000) Subject: Rename Torrent.connHasWantedPieces->connection.peerHasWantedPieces X-Git-Tag: v1.0.0~442 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=493916c2794e3ed8c1867cb5d6b3d7aa84a1875a;p=btrtrc.git Rename Torrent.connHasWantedPieces->connection.peerHasWantedPieces --- diff --git a/connection.go b/connection.go index 39fc46cb..aca2b348 100644 --- a/connection.go +++ b/connection.go @@ -698,7 +698,7 @@ func (c *connection) useful() bool { if t.seeding() { return c.PeerInterested } - return t.connHasWantedPieces(c) + return c.peerHasWantedPieces() } func (c *connection) lastHelpful() (ret time.Time) { @@ -1023,7 +1023,7 @@ func (c *connection) upload() { 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) Drop() { 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 337040f5..8230acbf 100644 --- a/torrent.go +++ b/torrent.go @@ -713,10 +713,6 @@ func (t *Torrent) wantPieceIndex(index int) bool { }) } -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