]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Separate things in Peer that belong in PeerConn
authorMatt Joiner <anacrolix@gmail.com>
Tue, 1 Jul 2025 03:28:58 +0000 (13:28 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Tue, 1 Jul 2025 03:28:58 +0000 (13:28 +1000)
peer.go

diff --git a/peer.go b/peer.go
index 26880bf361cdcd4b27a1764e5a306085acced07d..93116246afa3b34792cb2d951bd1904bafe373cc 100644 (file)
--- a/peer.go
+++ b/peer.go
@@ -37,9 +37,24 @@ type (
                peerImpl  newHotPeerImpl
                callbacks *Callbacks
 
-               outgoing   bool
-               Network    string
-               RemoteAddr PeerRemoteAddr
+               RemoteAddr              PeerRemoteAddr
+               Discovery               PeerSource
+               trusted                 bool
+               closed                  chansync.SetOnce
+               lastUsefulChunkReceived time.Time
+
+               lastStartedExpectingToReceiveChunks time.Time
+               cumulativeExpectedToReceiveChunks   time.Duration
+               // Pieces we've accepted chunks for from the peer.
+               peerTouchedPieces map[pieceIndex]struct{}
+
+               logger  log.Logger
+               slogger *slog.Logger
+
+               // Belongs in PeerConn:
+
+               outgoing bool
+               Network  string
                // The local address as observed by the remote peer. WebRTC seems to get this right without needing hints from the
                // config.
                localPublicAddr peerLocalPublicAddr
@@ -47,17 +62,13 @@ type (
                // True if the connection is operating over MSE obfuscation.
                headerEncrypted bool
                cryptoMethod    mse.CryptoMethod
-               Discovery       PeerSource
-               trusted         bool
-               closed          chansync.SetOnce
                // Set true after we've added our ConnStats generated during handshake to
                // other ConnStat instances as determined when the *Torrent became known.
                reconciledHandshakeStats bool
 
-               lastMessageReceived     time.Time
-               completedHandshake      time.Time
-               lastUsefulChunkReceived time.Time
-               lastChunkSent           time.Time
+               lastMessageReceived time.Time
+               completedHandshake  time.Time
+               lastChunkSent       time.Time
 
                // Stuff controlled by the local peer.
                needRequestUpdate updateRequestReason
@@ -69,9 +80,6 @@ type (
                lastBecameInterested time.Time
                priorInterest        time.Duration
 
-               lastStartedExpectingToReceiveChunks time.Time
-               cumulativeExpectedToReceiveChunks   time.Duration
-
                choking bool
 
                // Stuff controlled by the remote peer.
@@ -83,14 +91,10 @@ type (
                // communication with the peer. Generally only useful until we have the
                // torrent info.
                peerMinPieces pieceIndex
-               // Pieces we've accepted chunks for from the peer.
-               peerTouchedPieces map[pieceIndex]struct{}
-               peerAllowedFast   typedRoaring.Bitmap[pieceIndex]
 
-               PeerMaxRequests maxRequests // Maximum pending requests the peer allows.
+               peerAllowedFast typedRoaring.Bitmap[pieceIndex]
 
-               logger  log.Logger
-               slogger *slog.Logger
+               PeerMaxRequests maxRequests // Maximum pending requests the peer allows.
        }
 
        PeerSource string