]> Sergey Matveev's repositories - btrtrc.git/blobdiff - peer.go
Relax TestTcpSimultaneousOpen
[btrtrc.git] / peer.go
diff --git a/peer.go b/peer.go
index e88485b296e5b93c44c8d91597c1f413192200f8..d59c5c4c336ac594b871a48dafd489f9e114a382 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -21,7 +21,7 @@ import (
        "github.com/anacrolix/torrent/mse"
        pp "github.com/anacrolix/torrent/peer_protocol"
        request_strategy "github.com/anacrolix/torrent/request-strategy"
-       "github.com/anacrolix/torrent/typed-roaring"
+       typedRoaring "github.com/anacrolix/torrent/typed-roaring"
 )
 
 type (
@@ -86,7 +86,6 @@ type (
                peerChoking           bool
                peerRequests          map[Request]*peerRequestState
                PeerPrefersEncryption bool // as indicated by 'e' field in extension handshake
-               PeerListenPort        int
                // The highest possible number of pieces the torrent could have based on
                // communication with the peer. Generally only useful until we have the
                // torrent info.
@@ -117,6 +116,7 @@ type (
 )
 
 const (
+       PeerSourceUtHolepunch     = "C"
        PeerSourceTracker         = "Tr"
        PeerSourceIncoming        = "I"
        PeerSourceDhtGetPeers     = "Hg" // Peers we found by searching a DHT.
@@ -324,6 +324,9 @@ func (p *Peer) close() {
        if p.updateRequestsTimer != nil {
                p.updateRequestsTimer.Stop()
        }
+       for _, prs := range p.peerRequests {
+               prs.allocReservation.Drop()
+       }
        p.peerImpl.onClose()
        if p.t != nil {
                p.t.decPeerPieceAvailability(p)
@@ -519,7 +522,7 @@ func (cn *Peer) peerPiecesChanged() {
 func (cn *Peer) postHandshakeStats(f func(*ConnStats)) {
        t := cn.t
        f(&t.stats)
-       f(&t.cl.stats)
+       f(&t.cl.connStats)
 }
 
 // All ConnStats that include this connection. Some objects are not known