]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Rename Torrent.connHasWantedPieces->connection.peerHasWantedPieces
authorMatt Joiner <anacrolix@gmail.com>
Thu, 17 Aug 2017 15:48:19 +0000 (01:48 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 17 Aug 2017 15:48:19 +0000 (01:48 +1000)
connection.go
torrent.go

index 39fc46cbbf8e59eda974df978b6d9a9eb1c521c8..aca2b348587a1b16ac155aaddda38d0a768b5260 100644 (file)
@@ -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()
+}
index 337040f5dd7303376748ffa021fb42d1d433c26c..8230acbfd574ad7164c44b28b55d304713c82644 100644 (file)
@@ -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