config

package
v0.43.0 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPrefix protocol.ID = amino.ProtocolPrefix

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.MsgSenderBuilder = net.NewMessageSenderImpl

	o.RoutingTable.LatencyTolerance = 10 * time.Second
	o.RoutingTable.RefreshQueryTimeout = 10 * time.Second
	o.RoutingTable.RefreshInterval = 10 * time.Minute
	o.RoutingTable.AutoRefresh = true
	o.RoutingTable.PeerFilter = EmptyRTFilter
	o.RoutingTable.PersistInterval = time.Hour

	o.MaxRecordAge = amino.DefaultMaxRecordAge
	o.ValueGCInterval = amino.DefaultValueGCInterval

	o.BucketSize = amino.DefaultBucketSize
	o.Concurrency = amino.DefaultConcurrency
	o.Resiliency = amino.DefaultResiliency
	o.LookupCheckConcurrency = 256

	o.OptimisticProvideJobsPoolSize = 60

	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(_ any, ai peer.AddrInfo) bool

func EmptyRTFilter

func EmptyRTFilter(_ any, p peer.ID) bool

func GetQuorum

func GetQuorum(opts *routing.Options) int

GetQuorum defaults to 0 if no option is found

Types

type BootstrapOrderOpt added in v0.43.0

type BootstrapOrderOpt int

BootstrapOrderOpt selects which peers the DHT dials first when its routing table is empty.

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
	ValueGCInterval     time.Duration
	EnableProviders     bool
	EnableValues        bool
	ProviderManagerOpts []records.Option
	// ValueDatastore and ProviderDatastore optionally give the value store and
	// the provider store their own physical datastore. When nil, each falls back
	// to Datastore. Record keys are namespaced by a per-record-type prefix, so a
	// shared Datastore stays collision-free.
	ValueDatastore         ds.Batching
	ProviderDatastore      ds.Batching
	QueryPeerFilter        QueryFilterFunc
	LookupCheckConcurrency int
	MsgSenderBuilder       func(h host.Host, protos []protocol.ID) pb.MessageSenderWithDisconnect

	RoutingTable struct {
		RefreshQueryTimeout time.Duration
		RefreshInterval     time.Duration
		AutoRefresh         bool
		LatencyTolerance    time.Duration
		CheckInterval       time.Duration
		PeerFilter          RouteTableFilterFunc
		DiversityFilter     peerdiversity.PeerIPGroupFilter
		// PersistInterval is how often the routing table is saved to the
		// Datastore; zero disables saving and seeding from saved peers.
		PersistInterval time.Duration
	}

	BootstrapPeers func() []peer.AddrInfo
	BootstrapOrder BootstrapOrderOpt
	AddressFilter  func([]ma.Multiaddr) []ma.Multiaddr
	OnRequestHook  func(ctx context.Context, s network.Stream, req *pb.Message)

	// test specific Config options
	DisableFixLowPeers          bool
	TestAddressUpdateProcessing bool

	EnableOptimisticProvide       bool
	OptimisticProvideJobsPoolSize int
}

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) ProviderDS added in v0.42.0

func (c *Config) ProviderDS() ds.Batching

ProviderDS returns the datastore backing the provider store: the ProviderDatastore override when set, else the shared Datastore.

func (*Config) Validate

func (c *Config) Validate() error

func (*Config) ValueDS added in v0.42.0

func (c *Config) ValueDS() ds.Batching

ValueDS returns the datastore backing the value store: the ValueDatastore override when set, else the shared Datastore.

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 any, 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 any, 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
⌂ 换网址