config

package
v0.12.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 29, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrefix protocol.ID = "/ipfs"

DefaultPrefix is the application specific prefix attached to all DHT protocols by default.

Variables

View Source
var Defaults = func(o *Config) error {
	o.Validator = record.NamespacedValidator{}
	o.Datastore = dssync.MutexWrap(ds.NewMapDatastore())
	o.ProtocolPrefix = DefaultPrefix
	o.EnableProviders = true
	o.EnableValues = true
	o.QueryPeerFilter = EmptyQueryFilter

	o.RoutingTable.LatencyTolerance = time.Minute
	o.RoutingTable.RefreshQueryTimeout = 1 * time.Minute
	o.RoutingTable.RefreshInterval = 10 * time.Minute
	o.RoutingTable.AutoRefresh = true
	o.RoutingTable.PeerFilter = EmptyRTFilter
	o.MaxRecordAge = time.Hour * 36

	o.BucketSize = defaultBucketSize
	o.Concurrency = 10
	o.Resiliency = 3

	return nil
}

Defaults are the default DHT options. This option will be automatically prepended to any options you pass to the DHT constructor.

Functions

func EmptyQueryFilter

func EmptyQueryFilter(_ interface{}, ai peer.AddrInfo) bool

func EmptyRTFilter

func EmptyRTFilter(_ interface{}, p peer.ID) bool

func GetQuorum

func GetQuorum(opts *routing.Options) int

GetQuorum defaults to 0 if no option is found

Types

type Config

type Config struct {
	Datastore          ds.Batching
	Validator          record.Validator
	ValidatorChanged   bool // if true implies that the validator has been changed and that Defaults should not be used
	Mode               ModeOpt
	ProtocolPrefix     protocol.ID
	V1ProtocolOverride protocol.ID
	BucketSize         int
	Concurrency        int
	Resiliency         int
	MaxRecordAge       time.Duration
	EnableProviders    bool
	EnableValues       bool
	ProvidersOptions   []providers.Option
	QueryPeerFilter    QueryFilterFunc

	RoutingTable struct {
		RefreshQueryTimeout time.Duration
		RefreshInterval     time.Duration
		AutoRefresh         bool
		LatencyTolerance    time.Duration
		CheckInterval       time.Duration
		PeerFilter          RouteTableFilterFunc
		DiversityFilter     peerdiversity.PeerIPGroupFilter
	}

	BootstrapPeers func() []peer.AddrInfo

	// test specific Config options
	DisableFixLowPeers          bool
	TestAddressUpdateProcessing bool
}

Config is a structure containing all the options that can be used when constructing a DHT.

func (*Config) Apply

func (c *Config) Apply(opts ...Option) error

Apply applies the given options to this Option

func (*Config) ApplyFallbacks

func (c *Config) ApplyFallbacks(h host.Host) error

ApplyFallbacks sets default values that could not be applied during config creation since they are dependent on other configuration parameters (e.g. optA is by default 2x optB) and/or on the Host

func (*Config) Validate

func (c *Config) Validate() error

type ModeOpt

type ModeOpt int

ModeOpt describes what mode the dht should operate in

type Option

type Option func(*Config) error

Option DHT option type.

type QueryFilterFunc

type QueryFilterFunc func(dht interface{}, ai peer.AddrInfo) bool

QueryFilterFunc is a filter applied when considering peers to dial when querying

type QuorumOptionKey

type QuorumOptionKey struct{}

type RouteTableFilterFunc

type RouteTableFilterFunc func(dht interface{}, p peer.ID) bool

RouteTableFilterFunc is a filter applied when considering connections to keep in the local route table.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL