1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-08-06 19:44:01 +08:00

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
This commit is contained in:
Marcin Rataj
2025-04-09 21:17:19 +02:00
committed by GitHub
parent ee7fef251c
commit fe3106f9a6
4 changed files with 22 additions and 12 deletions

View File

@ -28,6 +28,7 @@ const (
DefaultEngineTaskWorkerCount = 8
DefaultMaxOutstandingBytesPerPeer = 1 << 20
DefaultProviderSearchDelay = 1000 * time.Millisecond
DefaultMaxProviders = 10 // matching BitswapClientDefaultMaxProviders from https://github.com/ipfs/boxo/blob/v0.29.1/bitswap/internal/defaults/defaults.go#L15
DefaultWantHaveReplaceSize = 1024
)
@ -79,11 +80,13 @@ func Bitswap(provide bool) interface{} {
var provider routing.ContentDiscovery
if provide {
// We need to hardcode the default because it is an
// internal setting in boxo.
var maxProviders int = DefaultMaxProviders
if in.Cfg.Internal.Bitswap != nil {
maxProviders = int(in.Cfg.Internal.Bitswap.ProviderSearchMaxResults.WithDefault(DefaultMaxProviders))
}
pqm, err := rpqm.New(bitswapNetwork,
in.Rt,
rpqm.WithMaxProviders(10),
rpqm.WithMaxProviders(maxProviders),
rpqm.WithIgnoreProviders(in.Cfg.Routing.IgnoreProviders...),
)
if err != nil {