Skip to content

feat(bitswap/client): MinTimeout for DontHaveTimeoutConfig #865

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand All @@ -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
}
Expand Down
Loading