add protocol option for node

This commit is contained in:
ginuerzh
2022-11-30 10:47:27 +08:00
parent 0f0679a3ec
commit 8effb0b8b9
2 changed files with 16 additions and 2 deletions

View File

@ -3,8 +3,9 @@ package chain
import "context"
type SelectOptions struct {
Addr string
Host string
Addr string
Host string
Protocol string
}
type SelectOption func(*SelectOptions)
@ -21,6 +22,12 @@ func HostSelectOption(host string) SelectOption {
}
}
func ProtocolSelectOption(protocol string) SelectOption {
return func(o *SelectOptions) {
o.Protocol = protocol
}
}
type Hop interface {
Nodes() []*Node
Select(ctx context.Context, opts ...SelectOption) *Node