make Protocols variadic, for usability

This commit is contained in:
Erin Swenson-Healey 2018-06-01 15:54:17 -07:00
parent d94deae41d
commit 3b148d2b88
2 changed files with 2 additions and 3 deletions

View File

@ -13,7 +13,6 @@ import (
opts "github.com/libp2p/go-libp2p-kad-dht/opts"
pb "github.com/libp2p/go-libp2p-kad-dht/pb"
"github.com/libp2p/go-libp2p-protocol"
cid "github.com/ipfs/go-cid"
u "github.com/ipfs/go-ipfs-util"
@ -1082,7 +1081,7 @@ func TestGetSetPluggedProtocol(t *testing.T) {
defer cancel()
os := []opts.Option{
opts.Protocols([]protocol.ID{"/esh/dht"}),
opts.Protocols("/esh/dht"),
opts.Client(false),
opts.NamespacedValidator("v", blankValidator{}),
}

View File

@ -96,7 +96,7 @@ func NamespacedValidator(ns string, v record.Validator) Option {
// Protocols sets the protocols for the DHT
//
// Defaults to dht.DefaultProtocols
func Protocols(protocols []protocol.ID) Option {
func Protocols(protocols ...protocol.ID) Option {
return func(o *Options) error {
o.Protocols = protocols
return nil