ceremonyclient/go-libp2p-kad-dht/internal/config/quorum.go

17 lines
349 B
Go
Raw Normal View History

2024-10-12 18:48:25 +00:00
package config
import "github.com/libp2p/go-libp2p/core/routing"
type QuorumOptionKey struct{}
const defaultQuorum = 0
// GetQuorum defaults to 0 if no option is found
func GetQuorum(opts *routing.Options) int {
responsesNeeded, ok := opts.Other[QuorumOptionKey{}].(int)
if !ok {
responsesNeeded = defaultQuorum
}
return responsesNeeded
}