]> Sergey Matveev's repositories - btrtrc.git/commitdiff
Disable update requests timer
authorMatt Joiner <anacrolix@gmail.com>
Wed, 11 May 2022 06:08:19 +0000 (16:08 +1000)
committerMatt Joiner <anacrolix@gmail.com>
Thu, 12 May 2022 00:37:36 +0000 (10:37 +1000)
client.go
peerconn.go
requesting.go

index b498339ec5268779d53024126cb99b56a89797b9..71f37e3cde8d2c91ad06c752e568033fc433c63c 100644 (file)
--- a/client.go
+++ b/client.go
@@ -991,7 +991,9 @@ func (p *Peer) initUpdateRequestsTimer() {
                        panic(p.updateRequestsTimer)
                }
        }
-       p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+       if enableUpdateRequestsTimer {
+               p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+       }
 }
 
 const peerUpdateRequestsTimerReason = "updateRequestsTimer"
index 0b2d85f650c11a31f3370c80ae24039d85df7edd..554da65f2eb844279c14213825c8f67eb038078c 100644 (file)
@@ -503,7 +503,7 @@ var (
 
 // The actual value to use as the maximum outbound requests.
 func (cn *Peer) nominalMaxRequests() maxRequests {
-       return maxRequests(maxInt(1, minInt(cn.PeerMaxRequests, cn.peakRequests*2, maxLocalToRemoteRequests)))
+       return maxInt(1, minInt(cn.PeerMaxRequests, cn.peakRequests*2, maxLocalToRemoteRequests))
 }
 
 func (cn *Peer) totalExpectingTime() (ret time.Duration) {
index 98e9e88bf34048a6ae8ec6ddaaaefd49c8a9dc02..f1831346e816cc2508d96e8e3b79ff055ac31cbd 100644 (file)
@@ -312,9 +312,14 @@ func (p *Peer) applyRequestState(next desiredRequestState) {
        p.peakRequests = newPeakRequests
        p.needRequestUpdate = ""
        p.lastRequestUpdate = time.Now()
-       p.updateRequestsTimer.Reset(updateRequestsTimerDuration)
+       if enableUpdateRequestsTimer {
+               p.updateRequestsTimer.Reset(updateRequestsTimerDuration)
+       }
 }
 
 // This could be set to 10s to match the unchoke/request update interval recommended by some
 // specifications. I've set it shorter to trigger it more often for testing for now.
-const updateRequestsTimerDuration = 3 * time.Second
+const (
+       updateRequestsTimerDuration = 3 * time.Second
+       enableUpdateRequestsTimer   = false
+)