ipld-eth-server/vendor/github.com/libp2p/go-libp2p-kad-dht/routing_options.go
Elizabeth Engelman 36533f7c3f Update vendor directory and make necessary code changes
Fixes for new geth version
2019-09-25 16:32:27 -05:00

30 lines
664 B
Go

package dht
import "github.com/libp2p/go-libp2p-core/routing"
type quorumOptionKey struct{}
const defaultQuorum = 16
// Quorum is a DHT option that tells the DHT how many peers it needs to get
// values from before returning the best one.
//
// Default: 16
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[quorumOptionKey{}] = n
return nil
}
}
func getQuorum(opts *routing.Options, ndefault int) int {
responsesNeeded, ok := opts.Other[quorumOptionKey{}].(int)
if !ok {
responsesNeeded = ndefault
}
return responsesNeeded
}