autorelay

package
v0.23.5 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2022 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultRelays = []string{
	"/ip4/147.75.80.110/tcp/4001/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
	"/ip4/147.75.80.110/udp/4001/quic/p2p/QmbFgm5zan8P6eWWmeyfncR5feYEMPbht5b1FW1C37aQ7y",
	"/ip4/147.75.195.153/tcp/4001/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
	"/ip4/147.75.195.153/udp/4001/quic/p2p/QmW9m57aiBDHAkKj9nmFSEn7ZqrcF1fZS4bipsTCHburei",
	"/ip4/147.75.70.221/tcp/4001/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
	"/ip4/147.75.70.221/udp/4001/quic/p2p/Qme8g49gm3q4Acp7xWBKg3nAa9fxZ1YmyDJdyGgoG6LsXh",
}

DefaultRelays are the known PL-operated v1 relays; will be decommissioned in 2022.

Functions

func Filter

func Filter(addrs []ma.Multiaddr) []ma.Multiaddr

Filter filters out all relay addresses.

Types

type AutoRelay

type AutoRelay struct {
	// contains filtered or unexported fields
}

func NewAutoRelay

func NewAutoRelay(bhost *basic.BasicHost, opts ...Option) (*AutoRelay, error)

func (*AutoRelay) Close

func (r *AutoRelay) Close() error

type AutoRelayHost

type AutoRelayHost struct {
	host.Host
	// contains filtered or unexported fields
}

func NewAutoRelayHost

func NewAutoRelayHost(h host.Host, ar *AutoRelay) *AutoRelayHost

func (*AutoRelayHost) Close

func (h *AutoRelayHost) Close() error

type Option

type Option func(*config) error

func WithBackoff

func WithBackoff(d time.Duration) Option

WithBackoff sets the time we wait after failing to obtain a reservation with a candidate.

func WithBootDelay

func WithBootDelay(d time.Duration) Option

WithBootDelay set the boot delay for finding relays. We won't attempt any reservation if we've have less than a minimum number of candidates. This prevents us to connect to the "first best" relay, and allows us to carefully select the relay. However, in case we haven't found enough relays after the boot delay, we use what we have.

func WithCircuitV1Support

func WithCircuitV1Support() Option

WithCircuitV1Support enables support for circuit v1 relays.

func WithClock

func WithClock(cl clock.Clock) Option

func WithDefaultStaticRelays

func WithDefaultStaticRelays() Option

func WithMaxCandidateAge

func WithMaxCandidateAge(d time.Duration) Option

WithMaxCandidateAge sets the maximum age of a candidate. When we are connected to the desired number of relays, we don't ask the peer source for new candidates. This can lead to AutoRelay's candidate list becoming outdated, and means we won't be able to quickly establish a new relay connection if our existing connection breaks, if all the candidates have become stale.

func WithMaxCandidates

func WithMaxCandidates(n int) Option

WithMaxCandidates sets the number of relay candidates that we buffer.

func WithMinCandidates

func WithMinCandidates(n int) Option

WithMinCandidates sets the minimum number of relay candidates we collect before to get a reservation with any of them (unless we've been running for longer than the boot delay). This is to make sure that we don't just randomly connect to the first candidate that we discover.

func WithNumRelays

func WithNumRelays(n int) Option

WithNumRelays sets the number of relays we strive to obtain reservations with.

func WithPeerSource

func WithPeerSource(f func(ctx context.Context, numPeers int) <-chan peer.AddrInfo, minInterval time.Duration) Option

WithPeerSource defines a callback for AutoRelay to query for more relay candidates. AutoRelay will call this function when it needs new candidates is connected to the desired number of relays, and it has enough candidates (in case we get disconnected from one of the relays). Implementations must send *at most* numPeers, and close the channel when they don't intend to provide any more peers. AutoRelay will not call the callback again until the channel is closed. Implementations should send new peers, but may send peers they sent before. AutoRelay implements a per-peer backoff (see WithBackoff). minInterval is the minimum interval this callback is called with, even if AutoRelay needs new candidates. The context.Context passed MAY be canceled when AutoRelay feels satisfied, it will be canceled when the node is shutting down. If the channel is canceled you MUST close the output channel at some point.

func WithStaticRelays

func WithStaticRelays(static []peer.AddrInfo) Option

Jump to

Keyboard shortcuts

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