diff --git a/config/internal.go b/config/internal.go index dcd834e701c..a860c02c9cc 100644 --- a/config/internal.go +++ b/config/internal.go @@ -12,4 +12,5 @@ type InternalBitswap struct { EngineBlockstoreWorkerCount OptionalInteger EngineTaskWorkerCount OptionalInteger MaxOutstandingBytesPerPeer OptionalInteger + ProviderSearchDelay OptionalDuration } diff --git a/core/node/bitswap.go b/core/node/bitswap.go index 2b9cf641a1b..42b948f7520 100644 --- a/core/node/bitswap.go +++ b/core/node/bitswap.go @@ -2,6 +2,7 @@ package node import ( "context" + "time" "github.com/ipfs/go-bitswap" "github.com/ipfs/go-bitswap/network" @@ -21,6 +22,7 @@ const ( DefaultTaskWorkerCount = 8 DefaultEngineTaskWorkerCount = 8 DefaultMaxOutstandingBytesPerPeer = 1 << 20 + DefaultProviderSearchDelay = 1000 * time.Millisecond ) type bitswapOptionsOut struct { @@ -40,6 +42,7 @@ func BitswapOptions(cfg *config.Config, provide bool) interface{} { opts := []bitswap.Option{ bitswap.ProvideEnabled(provide), + bitswap.ProviderSearchDelay(internalBsCfg.ProviderSearchDelay.WithDefault(DefaultProviderSearchDelay)), // See https://github.com/ipfs/go-ipfs/issues/8807 for rationale bitswap.EngineBlockstoreWorkerCount(int(internalBsCfg.EngineBlockstoreWorkerCount.WithDefault(DefaultEngineBlockstoreWorkerCount))), bitswap.TaskWorkerCount(int(internalBsCfg.TaskWorkerCount.WithDefault(DefaultTaskWorkerCount))), bitswap.EngineTaskWorkerCount(int(internalBsCfg.EngineTaskWorkerCount.WithDefault(DefaultEngineTaskWorkerCount))),