Skip to content

Commit

Permalink
add protocol based node selection for hop
Browse files Browse the repository at this point in the history
  • Loading branch information
ginuerzh committed Jan 8, 2024
1 parent 936954e commit c04c28e
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions hop/hop.go
Original file line number Diff line number Diff line change
Expand Up @@ -168,16 +168,24 @@ func (p *chainHop) Select(ctx context.Context, opts ...hop.SelectOption) *chain.
if len(filters) == 0 {
filters = nodes
}
} else if protocol := options.Protocol; protocol != "" {
filters = nil
for _, node := range ns {
}

if protocol := options.Protocol; protocol != "" {
p.options.logger.Debugf("filter by protocol: %s", protocol)
var nodes []*chain.Node
for _, node := range filters {
if node == nil {
continue
}
if node.Options().Protocol == "" {
nodes = append(nodes, node)
continue
}
if node.Options().Protocol == protocol {
filters = append(filters, node)
nodes = append(nodes, node)
}
}
filters = nodes
}

// filter by path
Expand Down

0 comments on commit c04c28e

Please sign in to comment.