Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/add min hops config #656

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/router/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ type Config struct {
RouteGroupDialer setupclient.RouteGroupDialer
SetupNodes []cipher.PubKey
RulesGCInterval time.Duration
MinHops uint16
MaxHops uint16
}

// SetDefaults sets default values for certain empty values.
Expand All @@ -76,6 +78,10 @@ func (c *Config) SetDefaults() {
if c.RulesGCInterval <= 0 {
c.RulesGCInterval = DefaultRulesGCInterval
}

if c.MaxHops == 0 {
c.MaxHops = maxHops
}
}

// DialOptions describes dial options.
Expand Down Expand Up @@ -827,7 +833,7 @@ fetchRoutesAgain:
ctx := context.Background()

paths, err := r.conf.RouteFinder.FindRoutes(ctx, []routing.PathEdges{forward, backward},
&rfclient.RouteOptions{MinHops: minHops, MaxHops: maxHops})
&rfclient.RouteOptions{MinHops: r.conf.MinHops, MaxHops: r.conf.MaxHops})

if err == rfclient.ErrTransportNotFound {
return nil, nil, err
Expand Down
1 change: 1 addition & 0 deletions pkg/visor/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ func initRouter(v *Visor) bool {
RouteGroupDialer: setupclient.NewSetupNodeDialer(),
SetupNodes: conf.SetupNodes,
RulesGCInterval: 0, // TODO
MinHops: v.conf.Routing.MinHops,
}

r, err := router.New(v.net, &rConf)
Expand Down
1 change: 1 addition & 0 deletions pkg/visor/visorconfig/v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ type V1Routing struct {
SetupNodes []cipher.PubKey `json:"setup_nodes,omitempty"`
RouteFinder string `json:"route_finder"`
RouteFinderTimeout Duration `json:"route_finder_timeout,omitempty"`
MinHops uint16 `json:"min_hops"`
}

// V1UptimeTracker configures uptime tracker.
Expand Down