dhtopts

package
v4.2.5+incompatible Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2018 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultProtocols = []protocol.ID{ProtocolDHT, ProtocolDHTOld}
View Source
var Defaults = func(o *Options) error {
	o.Validator = record.NamespacedValidator{
		"pk": record.PublicKeyValidator{},
	}
	o.Datastore = dssync.MutexWrap(ds.NewMapDatastore())
	o.Protocols = DefaultProtocols
	return nil
}

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

View Source
var ProtocolDHT protocol.ID = "/ipfs/kad/1.0.0"
View Source
var ProtocolDHTOld protocol.ID = "/ipfs/dht"

Functions

This section is empty.

Types

type Option

type Option func(*Options) error

Option DHT option type.

func Client

func Client(only bool) Option

Client configures whether or not the DHT operates in client-only mode.

Defaults to false.

func Datastore

func Datastore(ds ds.Batching) Option

Datastore configures the DHT to use the specified datastore.

Defaults to an in-memory (temporary) map.

func NamespacedValidator

func NamespacedValidator(ns string, v record.Validator) Option

NamespacedValidator adds a validator namespaced under `ns`. This option fails if the DHT is not using a `record.NamespacedValidator` as it's validator (it uses one by default but this can be overridden with the `Validator` option).

Example: Given a validator registered as `NamespacedValidator("ipns", myValidator)`, all records with keys starting with `/ipns/` will be validated with `myValidator`.

func Protocols

func Protocols(protocols ...protocol.ID) Option

Protocols sets the protocols for the DHT

Defaults to dht.DefaultProtocols

func Validator

func Validator(v record.Validator) Option

Validator configures the DHT to use the specified validator.

Defaults to a namespaced validator that can only validate public keys.

type Options

type Options struct {
	Datastore ds.Batching
	Validator record.Validator
	Client    bool
	Protocols []protocol.ID
}

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

func (*Options) Apply

func (o *Options) Apply(opts ...Option) error

Apply applies the given options to this Option

Jump to

Keyboard shortcuts

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