add protocol based node selection for hop
This commit is contained in:
parent
936954ecf2
commit
c04c28e1fd
16
hop/hop.go
16
hop/hop.go
@ -168,16 +168,24 @@ func (p *chainHop) Select(ctx context.Context, opts ...hop.SelectOption) *chain.
|
|||||||
if len(filters) == 0 {
|
if len(filters) == 0 {
|
||||||
filters = nodes
|
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 {
|
if node == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
if node.Options().Protocol == "" {
|
||||||
|
nodes = append(nodes, node)
|
||||||
|
continue
|
||||||
|
}
|
||||||
if node.Options().Protocol == protocol {
|
if node.Options().Protocol == protocol {
|
||||||
filters = append(filters, node)
|
nodes = append(nodes, node)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
filters = nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
// filter by path
|
// filter by path
|
||||||
|
Loading…
Reference in New Issue
Block a user