Skip to content

Commit

Permalink
config: make Routing.AcceleratedDHTClient a Flag
Browse files Browse the repository at this point in the history
  • Loading branch information
hacdias committed Apr 3, 2024
1 parent 78a96e3 commit 8de995e
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 5 deletions.
2 changes: 1 addition & 1 deletion cmd/ipfs/kubo/daemon.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
case routingOptionNoneKwd:
ncfg.Routing = libp2p.NilRouterOption
case routingOptionCustomKwd:
if cfg.Routing.AcceleratedDHTClient {
if cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient) {
return fmt.Errorf("Routing.AcceleratedDHTClient option is set even tho Routing.Type is custom, using custom .AcceleratedDHTClient needs to be set on DHT routers individually")
}
ncfg.Routing = libp2p.ConstructDelegatedRouting(
Expand Down
6 changes: 5 additions & 1 deletion config/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ import (
"runtime"
)

var (
DefaultAcceleratedDHTClient = false
)

// Routing defines configuration options for libp2p routing.
type Routing struct {
// Type sets default daemon routing mode.
Expand All @@ -15,7 +19,7 @@ type Routing struct {
// When "custom" is set, user-provided Routing.Routers is used.
Type *OptionalString `json:",omitempty"`

AcceleratedDHTClient bool
AcceleratedDHTClient Flag `json:",omitempty"`

Routers Routers

Expand Down
2 changes: 1 addition & 1 deletion core/node/groups.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ func Online(bcfg *BuildCfg, cfg *config.Config, userResourceOverrides rcmgr.Part
cfg.Experimental.StrategicProviding,
cfg.Reprovider.Strategy.WithDefault(config.DefaultReproviderStrategy),
cfg.Reprovider.Interval.WithDefault(config.DefaultReproviderInterval),
cfg.Routing.AcceleratedDHTClient,
cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient),
),
)
}
Expand Down
2 changes: 1 addition & 1 deletion core/node/libp2p/routing.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func BaseRouting(cfg *config.Config) interface{} {
}
}

if dualDHT != nil && cfg.Routing.AcceleratedDHTClient {
if dualDHT != nil && cfg.Routing.AcceleratedDHTClient.WithDefault(config.DefaultAcceleratedDHTClient) {
cfg, err := in.Repo.Config()
if err != nil {
return out, err
Expand Down
2 changes: 1 addition & 1 deletion docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -1610,7 +1610,7 @@ them

Default: `false`

Type: `bool` (missing means `false`)
Type: `flag`

### `Routing.Routers`

Expand Down

0 comments on commit 8de995e

Please sign in to comment.