panic(p.updateRequestsTimer)
}
}
- p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+ if enableUpdateRequestsTimer {
+ p.updateRequestsTimer = time.AfterFunc(math.MaxInt64, p.updateRequestsTimerFunc)
+ }
}
const peerUpdateRequestsTimerReason = "updateRequestsTimer"
// 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) {
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
+)