resolver

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrNoPeersToAsk = errors.Error("no peers to ask")
)

Variables

This section is empty.

Functions

func NewPeerCache added in v0.11.1

func NewPeerCache(gcTime time.Duration) *peerCache

func WithBoostrapPeers

func WithBoostrapPeers(ps []*peer.Peer) func(*resolver)

WithBoostrapPeers overrides the default bootstrap peers for the resolver.

Types

type LookupFilter

type LookupFilter func(*peer.Peer) bool

LookupOptions

type LookupOption

type LookupOption func(*LookupOptions)

LookupOptions

func LookupByCertificateSigner

func LookupByCertificateSigner(certSigner crypto.PublicKey) LookupOption

LookupByCertificateSigner matches certificate signers

func LookupByContentHash

func LookupByContentHash(hash object.Hash) LookupOption

LookupByContentHash matches content hashes

func LookupByContentType

func LookupByContentType(contentType string) LookupOption

LookupByContentType matches content hashes

func LookupByOwner

func LookupByOwner(keys ...crypto.PublicKey) LookupOption

LookupByOwner matches the peer key

func LookupOnlyLocal

func LookupOnlyLocal() LookupOption

LookupOnlyLocal forces the discoverer to only look at its cache

type LookupOptions

type LookupOptions struct {
	Local bool
	// Lookups are strings we are looking for, will be used to create a
	// bloom filter when forwarding the lookup request to providers
	Lookups []string
	// filters are the lookups equivalents for matching local peers
	Filters []LookupFilter
}

LookupOptions

func ParseLookupOptions

func ParseLookupOptions(opts ...LookupOption) *LookupOptions

func (LookupOptions) Match

func (l LookupOptions) Match(p *peer.Peer) bool

type Option

type Option func(*resolver)

Option for customizing a new resolver

type Resolver

type Resolver interface {
	Lookup(
		ctx context.Context,
		opts ...LookupOption,
	) (<-chan *peer.Peer, error)
	Bootstrap(
		ctx context.Context,
		bootstrapPeers ...*peer.Peer,
	) error
}

func New

func New(
	ctx context.Context,
	netw network.Network,
	opts ...Option,
) Resolver

New returns a new resolver

Jump to

Keyboard shortcuts

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