diff --git a/bitswap/client/client.go b/bitswap/client/client.go index d75b7c861..f1308793d 100644 --- a/bitswap/client/client.go +++ b/bitswap/client/client.go @@ -44,10 +44,11 @@ var log = logging.Logger("bitswap-client") // bitswap instances type Option func(*Client) -// ProviderSearchDelay sets idle-delay value. When the session -// idles (does not receive any blocks) for this duration, a broadcast is -// triggered. The broadcast finds new peers and sends the wantlist. See -// [defaults.ProvSearchDelay] for the default (1s as of this writing). +// ProviderSearchDelay sets the initial dely before triggering a provider +// search to find more peers and broadcast the want list. It also partially +// controls re-broadcasts delay when the session idles (does not receive any +// blocks), but these have back-off logic to increase the interval. See +// [defaults.ProvSearchDelay] for the default. func ProviderSearchDelay(newProvSearchDelay time.Duration) Option { return func(bs *Client) { bs.provSearchDelay = newProvSearchDelay @@ -57,7 +58,7 @@ func ProviderSearchDelay(newProvSearchDelay time.Duration) Option { // RebroadcastDelay sets a custom delay for periodic search of a random want. // When the value ellapses, a random CID from the wantlist is chosen and the // client attempts to find more peers for it and sends them the single want. -// Default is set to 1 minute in [New]. +// [defaults.RebroadcastDelay] for the default. func RebroadcastDelay(newRebroadcastDelay delay.D) Option { return func(bs *Client) { bs.rebroadcastDelay = newRebroadcastDelay diff --git a/bitswap/internal/defaults/defaults.go b/bitswap/internal/defaults/defaults.go index f9494a0da..c7ac566f5 100644 --- a/bitswap/internal/defaults/defaults.go +++ b/bitswap/internal/defaults/defaults.go @@ -3,6 +3,8 @@ package defaults import ( "encoding/binary" "time" + + delay "github.com/ipfs/go-ipfs-delay" ) const ( @@ -34,3 +36,9 @@ const ( MaximumHashLength = 128 MaximumAllowedCid = binary.MaxVarintLen64*4 + MaximumHashLength ) + +var ( + // RebroadcastDelay is the default delay to trigger broadcast of + // random CIDs in the wantlist. + RebroadcastDelay = delay.Fixed(time.Minute) +)