feat(config): expose ProviderSearchMaxResults (#10773)
Replacing hardcoded integer with named default and expose config option for adjusting it, like we do in Rainbow https://github.com/ipfs/kubo/pull/10765/files#r2025455848
Marcin Rataj committed
Apr 9, 2025 at 21:17 UTC
fe3106f9a645f3a5bc348b94454012d0dd90b448
4 files changed
+22
-12
config/internal.go
+1
@@ -14,5 +14,6 @@ type InternalBitswap struct {
14
EngineTaskWorkerCount OptionalInteger
15
MaxOutstandingBytesPerPeer OptionalInteger
16
ProviderSearchDelay OptionalDuration
17
+ ProviderSearchMaxResults OptionalInteger
18
WantHaveReplaceSize OptionalInteger
19
}
core/node/bitswap.go
+6
-3
@@ -28,6 +28,7 @@ const (
28
DefaultEngineTaskWorkerCount = 8
29
DefaultMaxOutstandingBytesPerPeer = 1 << 20
30
DefaultProviderSearchDelay = 1000 * time.Millisecond
31
+ DefaultMaxProviders = 10 // matching BitswapClientDefaultMaxProviders from https://github.com/ipfs/boxo/blob/v0.29.1/bitswap/internal/defaults/defaults.go#L15
32
DefaultWantHaveReplaceSize = 1024
33
)
34
@@ -79,11 +80,13 @@ func Bitswap(provide bool) interface{} {
80
81
var provider routing.ContentDiscovery
82
if provide {
82
- // We need to hardcode the default because it is an
83
- // internal setting in boxo.
83
+ var maxProviders int = DefaultMaxProviders
84
+ if in.Cfg.Internal.Bitswap != nil {
85
+ maxProviders = int(in.Cfg.Internal.Bitswap.ProviderSearchMaxResults.WithDefault(DefaultMaxProviders))
86
+ }
87
pqm, err := rpqm.New(bitswapNetwork,
88
in.Rt,
86
- rpqm.WithMaxProviders(10),
89
+ rpqm.WithMaxProviders(maxProviders),
90
rpqm.WithIgnoreProviders(in.Cfg.Routing.IgnoreProviders...),
91
)
92
if err != nil {
docs/changelogs/v0.35.md
+4
-6
@@ -11,7 +11,7 @@ This release was brought to you by the [Shipyard](http://ipshipyard.com/) team.
11
- [Overview](#overview)
12
- [🔦 Highlights](#-highlights)
13
- [Dedicated `Reprovider.Strategy` for MFS](#dedicated-reproviderstrategy-for-mfs)
14
- - [`Routing.IgnoreProviders`](#routingignoreproviders)
14
+ - [Additional new configuration options](#additional-new-configuration-options)
15
- [Grid view in WebUI](#grid-view-in-webui)
16
- [📦️ Important dependency updates](#-important-dependency-updates)
17
- [📝 Changelog](#-changelog)
@@ -31,12 +31,10 @@ Users relying on the `pinned` strategy can switch to `pinned+mfs` and use MFS al
31
32
See [`Reprovider.Strategy`](https://github.com/ipfs/kubo/blob/master/docs/config.md#reproviderstrategy) for more details.
33
34
-#### `Routing.IgnoreProviders`
34
+#### Additional new configuration options
35
36
-This new option allows ignoring specific peer IDs when returned by the content
37
-routing system as providers of content. See the
38
-[documentation](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingignoreproviders)
39
-for for information.
36
+- [`Internal.Bitswap.ProviderSearchMaxResults`](https://github.com/ipfs/kubo/blob/master/docs/config.md##internalbitswapprovidersearchmaxresults) for adjusting the maximum number of providers bitswap client should aim at before it stops searching for new ones.
37
+- [`Routing.IgnoreProviders`](https://github.com/ipfs/kubo/blob/master/docs/config.md#routingignoreproviders) allows ignoring specific peer IDs when returned by the content routing system as providers of content.
38
39
#### Grid view in WebUI
40
docs/config.md
+11
-3
@@ -79,7 +79,8 @@ config file at runtime.
79
- [`Internal.Bitswap.EngineBlockstoreWorkerCount`](#internalbitswapengineblockstoreworkercount)
80
- [`Internal.Bitswap.EngineTaskWorkerCount`](#internalbitswapenginetaskworkercount)
81
- [`Internal.Bitswap.MaxOutstandingBytesPerPeer`](#internalbitswapmaxoutstandingbytesperpeer)
82
- - [`Internal.Bitswap.ProviderSearchDelay`](#internalbitswapprovidersearchdelay)
82
+ - [`Internal.Bitswap.ProviderSearchDelay`](#internalbitswapprovidersearchdelay)
83
+ - [`Internal.Bitswap.ProviderSearchMaxResults`](#internalbitswapprovidersearchmaxresults)
84
- [`Internal.UnixFSShardingSizeThreshold`](#internalunixfsshardingsizethreshold)
85
- [`Ipns`](#ipns)
86
- [`Ipns.RepublishPeriod`](#ipnsrepublishperiod)
@@ -119,7 +120,7 @@ config file at runtime.
120
- [`Routing.Type`](#routingtype)
121
- [`Routing.AcceleratedDHTClient`](#routingaccelerateddhtclient)
122
- [`Routing.LoopbackAddressesOnLanDHT`](#routingloopbackaddressesonlandht)
122
- - [`Routing.IgnoreProviders`](#routingignoreproviders)
123
+ - [`Routing.IgnoreProviders`](#routingignoreproviders)
124
- [`Routing.Routers`](#routingrouters)
125
- [`Routing.Routers: Type`](#routingrouters-type)
126
- [`Routing.Routers: Parameters`](#routingrouters-parameters)
@@ -1181,7 +1182,7 @@ deteriorate the quality provided to less aggressively-wanting peers.
1182
1183
Type: `optionalInteger` (byte count, `null` means default which is 1MB)
1184
1184
-### `Internal.Bitswap.ProviderSearchDelay`
1185
+#### `Internal.Bitswap.ProviderSearchDelay`
1186
1187
This parameter determines how long to wait before looking for providers outside of bitswap.
1188
Other routing systems like the Amino DHT are able to provide results in less than a second, so lowering
@@ -1189,6 +1190,13 @@ this number will allow faster peers lookups in some cases.
1190
1191
Type: `optionalDuration` (`null` means default which is 1s)
1192
1193
+#### `Internal.Bitswap.ProviderSearchMaxResults`
1194
+
1195
+Maximum number of providers bitswap client should aim at before it stops searching for new ones.
1196
+Setting to 0 means unlimited.
1197
+
1198
+Type: `optionalInteger` (`null` means default which is 10)
1199
+
1200
### `Internal.UnixFSShardingSizeThreshold`
1201
1202
The sharding threshold used internally to decide whether a UnixFS directory should be sharded or not.