ceremonyclient/go-libp2p-kad-dht/routing_options.go
2024-10-12 11:48:25 -07:00

22 lines
581 B
Go

package dht
import (
internalConfig "github.com/libp2p/go-libp2p-kad-dht/internal/config"
"github.com/libp2p/go-libp2p/core/routing"
)
// Quorum is a DHT option that tells the DHT how many peers it needs to get
// values from before returning the best one. Zero means the DHT query
// should complete instead of returning early.
//
// Default: 0
func Quorum(n int) routing.Option {
return func(opts *routing.Options) error {
if opts.Other == nil {
opts.Other = make(map[interface{}]interface{}, 1)
}
opts.Other[internalConfig.QuorumOptionKey{}] = n
return nil
}
}