Skip to content

Commit

Permalink
refactor: remove unused OnDontHaveTimeout from cfg
Browse files Browse the repository at this point in the history
After closer inspection it is not used for anything.  The one passed to
`newDontHaveTimeoutMgr` as a separate argument is used instead.
  • Loading branch information
lidel committed Dec 13, 2024
1 parent ba60cc4 commit 068cd7b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,18 @@ The following emojis are used to highlight certain changes:
### Added

- `bitswap/client`: Improved timeout configuration for block requests
- Exposed `DontHaveTimeoutConfig` to hold configuration values for `dontHaveTimeoutMgr` which controls how long to wait for requested block, and if timeout should emit a synthetic DontHave response
- Exposed `DontHaveTimeoutConfig` to hold configuration values for `dontHaveTimeoutMgr` which controls how long to wait for requested block before emitting a synthetic DontHave response
- Added `DefaultDontHaveTimeoutConfig()` to return a `DontHaveTimeoutConfig` populated with default values
- Added optional `WithDontHaveTimeoutConfig` to allow passing a custom `DontHaveTimeoutConfig`
- If `DontHaveTimeoutConfig.onDontHaveTimeout` is `nil`, then `dontaHaveTimeoutMgr` is disabled and synthetic DontHave won't be emitted on timeout
- Setting `SetSendDontHaves(false)` works the same as before. Behind the scenes, it will disable `dontHaveTimeoutMgr` by passing a `nil` `onDontHaveTimeout` to `newDontHaveTimeoutMgr`.


### Changed

### Removed



### Fixed

### Security
Expand Down
7 changes: 0 additions & 7 deletions bitswap/client/internal/messagequeue/donthavetimeoutmgr.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ import (
)

type DontHaveTimeoutConfig struct {
// OnDontHaveTimeout is the function called when DontHaveTimeout hits.
OnDontHaveTimeout func([]cid.Cid)

// DontHaveTimeout is used to simulate a DONT_HAVE when communicating with
// a peer whose Bitswap client doesn't support the DONT_HAVE response,
// or when the peer takes too long to respond.
Expand Down Expand Up @@ -49,10 +46,6 @@ type DontHaveTimeoutConfig struct {
clock clock.Clock
}

func (c *DontHaveTimeoutConfig) Enabled() bool {
return c.OnDontHaveTimeout != nil
}

func DefaultDontHaveTimeoutConfig() *DontHaveTimeoutConfig {
cfg := DontHaveTimeoutConfig{
DontHaveTimeout: 5 * time.Second,
Expand Down

0 comments on commit 068cd7b

Please sign in to comment.