From: Matt Joiner Date: Tue, 1 Jul 2025 03:28:58 +0000 (+1000) Subject: Separate things in Peer that belong in PeerConn X-Git-Tag: v1.59.0~56 X-Git-Url: http://www.git.stargrave.org/?a=commitdiff_plain;h=517a81e90d6cac4e6f6ca6ac52aa62fa10fa78b5;p=btrtrc.git Separate things in Peer that belong in PeerConn --- diff --git a/peer.go b/peer.go index 26880bf3..93116246 100644 --- 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