Skip to content

Commit

Permalink
Add flag bitswap-find-provider-timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
gammazero committed Nov 22, 2024
1 parent 90197c0 commit e7387f8
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 7 deletions.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require (
github.com/felixge/httpsnoop v1.0.4
github.com/ipfs-shipyard/nopfs v0.0.12
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231024163508-120e0c51ee3a
github.com/ipfs/boxo v0.24.4-0.20241122213905-f6d672a073dc
github.com/ipfs/boxo v0.24.4-0.20241122225644-7409ebea25a2
github.com/ipfs/go-block-format v0.2.0
github.com/ipfs/go-cid v0.4.1
github.com/ipfs/go-datastore v0.6.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,8 @@ github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231024163508-120e0c51ee3a h1:MKG
github.com/ipfs-shipyard/nopfs/ipfs v0.13.2-0.20231024163508-120e0c51ee3a/go.mod h1:6EekK/jo+TynwSE/ZOiOJd4eEvRXoavEC3vquKtv4yI=
github.com/ipfs/bbloom v0.0.4 h1:Gi+8EGJ2y5qiD5FbsbpX/TMNcJw8gSqr7eyjHa4Fhvs=
github.com/ipfs/bbloom v0.0.4/go.mod h1:cS9YprKXpoZ9lT0n/Mw/a6/aFV6DTjTLYHeA+gyqMG0=
github.com/ipfs/boxo v0.24.4-0.20241122213905-f6d672a073dc h1:nEIKTi3bW7HbO7VX0KAF82K1rm6mmHPD6BxppZCYTKE=
github.com/ipfs/boxo v0.24.4-0.20241122213905-f6d672a073dc/go.mod h1:DbXsp9GnF9cL4wDurnFnh2SSGjUcuiZmkhAcCA63J5A=
github.com/ipfs/boxo v0.24.4-0.20241122225644-7409ebea25a2 h1:P5/hA+/9ymER5xKlF4DVruntJaW2PGKMir1d6xfpHwA=
github.com/ipfs/boxo v0.24.4-0.20241122225644-7409ebea25a2/go.mod h1:DbXsp9GnF9cL4wDurnFnh2SSGjUcuiZmkhAcCA63J5A=
github.com/ipfs/go-bitfield v1.1.0 h1:fh7FIo8bSwaJEh6DdTWbCeZ1eqOaOkKFI74SCnsWbGA=
github.com/ipfs/go-bitfield v1.1.0/go.mod h1:paqf1wjq/D2BBmzfTVFlJQ9IlFOZpg422HL0HqsGWHU=
github.com/ipfs/go-bitswap v0.11.0 h1:j1WVvhDX1yhG32NTC9xfxnqycqYIlhzEzLXG/cU1HyQ=
Expand Down
15 changes: 11 additions & 4 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,17 +381,23 @@ Generate an identity seed and launch a gateway:
EnvVars: []string{"PEBBLE_WAL_MIN_SYNC_INTERVAL"},
Usage: "Sets the minimum duration between syncs of the WAL",
},
&cli.DurationFlag{
Name: "bitswap-find-provider-timeout",
Value: 10 * time.Second,
EnvVars: []string{"BITSWAP_FIND_PROVIDER_TIMEOUT"},
Usage: "Maximum time to spend on an attempt to find providers. 0 for bitswap default",
},
&cli.IntFlag{
Name: "bitswap-max-concurrent-finds",
Value: 0,
Value: 16,
EnvVars: []string{"BITSWAP_MAX_CONCURRENT_FINDS"},
Usage: "Maximum number of concurrent bitswap finds. Set 0 for bitswap default.",
Usage: "Maximum number of concurrent bitswap finds. 0 for bitswap default.",
},
&cli.IntFlag{
Name: "bitswap-max-providers-per-find",
EnvVars: []string{"BITSWAP_MAX_PROVIDERS_PER_FIND"},
Value: 0,
Usage: "Maximum number of providers to return for each bitswap find. Set 0 for bitswap default.",
Value: 10,
Usage: "Maximum number of providers to return for each bitswap find. 0 for bitswap default.",
},
}

Expand Down Expand Up @@ -554,6 +560,7 @@ share the same seed as long as the indexes are different.
WALMinSyncInterval: time.Second * time.Duration(cctx.Int("pebble-wal-min-sync-interval-sec")),

// Bitswap ProviderQueryManager config
bitswapFindProviderTimeout: cctx.Duration("bitswap-find-provider-timeout"),
bitswapMaxConcurrentFinds: cctx.Int("bitswap-max-concurrent-finds"),
bitswapMaxProvidersPerFind: cctx.Int("bitswap-max-providers-per-find"),

Check warning on line 565 in main.go

View check run for this annotation

Codecov / codecov/patch

main.go#L561-L565

Added lines #L561 - L565 were not covered by tests
}
Expand Down
1 change: 1 addition & 0 deletions setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ type Config struct {
WALMinSyncInterval time.Duration

// Bitswap ProviderQueryManager config
bitswapFindProviderTimeout time.Duration
bitswapMaxConcurrentFinds int
bitswapMaxProvidersPerFind int
}
Expand Down
1 change: 1 addition & 0 deletions setup_bitswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ func setupBitswapExchange(ctx context.Context, cfg Config, h host.Host, cr routi
bsclient.RebroadcastDelay(rebroadcastDelay),
bsclient.ProviderSearchDelay(providerSearchDelay),
bsclient.WithoutDuplicatedBlockStats(),
bsclient.WithFindProviderTimeout(cfg.bitswapFindProviderTimeout),
bsclient.WithMaxConcurrentFinds(cfg.bitswapMaxConcurrentFinds),
bsclient.WithMaxProvidersPerFind(cfg.bitswapMaxProvidersPerFind),
)
Expand Down

0 comments on commit e7387f8

Please sign in to comment.