diff --git a/CHANGELOG.md b/CHANGELOG.md index a6ae441c9..e270cee0d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ The following emojis are used to highlight certain changes: ## [Unreleased] +- feat(bitswap/client): MinTimeout for DontHaveTimeoutConfig [#865](https://github.com/ipfs/boxo/pull/865) - ✨ `httpnet`: Transparent HTTP-block retrieval support over Trustless Gateways [#747]((https://github.com/ipfs/boxo/pull/747): - Complements Bitswap as a block-retrieval mechanism, implementing `bitswap/network`. - Understands peers found in provider records with `/.../http` endpoints (trustless gateway). diff --git a/bitswap/client/internal/messagequeue/donthavetimeoutmgr.go b/bitswap/client/internal/messagequeue/donthavetimeoutmgr.go index 93845369c..b27e666dc 100644 --- a/bitswap/client/internal/messagequeue/donthavetimeoutmgr.go +++ b/bitswap/client/internal/messagequeue/donthavetimeoutmgr.go @@ -25,7 +25,8 @@ type DontHaveTimeoutConfig struct { // MaxTimeout is the maximum allowed timeout, regardless of latency MaxTimeout time.Duration - + // MinTimeout is the minimum allowed timeout, regardless of latency + MinTimeout time.Duration // PingLatencyMultiplier is multiplied by the average ping time to // get an upper bound on how long we expect to wait for a peer's response // to arrive @@ -363,6 +364,8 @@ func (dhtm *dontHaveTimeoutMgr) calculateTimeoutFromPingLatency(latency time.Dur timeout := dhtm.config.MaxExpectedWantProcessTime + time.Duration(dhtm.config.PingLatencyMultiplier)*latency if timeout > dhtm.config.MaxTimeout { timeout = dhtm.config.MaxTimeout + } else if timeout < dhtm.config.MinTimeout { + timeout = dhtm.config.MinTimeout } return timeout } @@ -372,6 +375,8 @@ func (dhtm *dontHaveTimeoutMgr) calculateTimeoutFromMessageLatency() time.Durati timeout := dhtm.messageLatency.latency * time.Duration(dhtm.config.MessageLatencyMultiplier) if timeout > dhtm.config.MaxTimeout { timeout = dhtm.config.MaxTimeout + } else if timeout < dhtm.config.MinTimeout { + timeout = dhtm.config.MinTimeout } return timeout }