mirror of
https://github.com/fluencelabs/go-libp2p-kad-dht
synced 2025-04-24 22:32:13 +00:00
cleanup: documentation and code cleanup for search/getvalue quorum defaulting to zero
This commit is contained in:
parent
075afe8528
commit
147dc1244d
@ -465,7 +465,7 @@ func TestSearchValue(t *testing.T) {
|
||||
|
||||
ctxT, cancel = context.WithTimeout(ctx, time.Second*2)
|
||||
defer cancel()
|
||||
valCh, err := dhtA.SearchValue(ctxT, "/v/hello", Quorum(-1))
|
||||
valCh, err := dhtA.SearchValue(ctxT, "/v/hello", Quorum(0))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ func (dht *IpfsDHT) SearchValue(ctx context.Context, key string, opts ...routing
|
||||
|
||||
responsesNeeded := 0
|
||||
if !cfg.Offline {
|
||||
responsesNeeded = getQuorum(&cfg, 0)
|
||||
responsesNeeded = getQuorum(&cfg, defaultQuorum)
|
||||
}
|
||||
|
||||
stopCh := make(chan struct{})
|
||||
|
@ -7,9 +7,10 @@ type quorumOptionKey struct{}
|
||||
const defaultQuorum = 0
|
||||
|
||||
// Quorum is a DHT option that tells the DHT how many peers it needs to get
|
||||
// values from before returning the best one.
|
||||
// values from before returning the best one. Zero means the DHT query
|
||||
// should complete instead of returning early.
|
||||
//
|
||||
// Default: 16
|
||||
// Default: 0
|
||||
func Quorum(n int) routing.Option {
|
||||
return func(opts *routing.Options) error {
|
||||
if opts.Other == nil {
|
||||
|
Loading…
x
Reference in New Issue
Block a user