Documentation
¶
Index ¶
- func FromBootstrapPeerAddrInfos(bootstrapPeerAddrInfos []BootstrapPeerAddrInfo) ([]peer.AddrInfo, error)
- type BootstrapPeerAddrInfo
- type Bootstrapper
- type DNSBootstrapper
- type HTTPBootstrapper
- type LookupResult
- type Router
- func (r *Router) Advertise(ctx context.Context, keys []string) error
- func (r *Router) Host() host.Host
- func (r *Router) ListPeers() ([]routing.Peer, error)
- func (r *Router) LocalAddresses() ([]netip.Addr, error)
- func (r *Router) Lookup(ctx context.Context, key string, count int) (*routing.Iterator, error)
- func (r *Router) Measure(ctx context.Context, key string) ([]LookupResult, error)
- func (r *Router) Ready(ctx context.Context) (bool, error)
- func (r *Router) Run(ctx context.Context) error
- func (r *Router) Withdraw(ctx context.Context, keys []string) error
- type RouterConfig
- type RouterOption
- type StaticBootstrapper
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FromBootstrapPeerAddrInfos ¶
func FromBootstrapPeerAddrInfos(bootstrapPeerAddrInfos []BootstrapPeerAddrInfo) ([]peer.AddrInfo, error)
Types ¶
type BootstrapPeerAddrInfo ¶
BootstrapPeerAddrInfo mirrors libp2p's peer.AddrInfo JSON shape but allows the ID to be omitted or empty. libp2p's peer.AddrInfo.UnmarshalJSON rejects an empty ID, so we unmarshal into this struct and convert via fromBootstrapPeerAddrInfos.
type Bootstrapper ¶
type Bootstrapper interface {
// Get returns a list of peers that should be used as bootstrap nodes.
// If the peer ID is empty it will be resolved.
// If the address is missing a port the P2P router port will be used.
Get(ctx context.Context) ([]peer.AddrInfo, error)
}
Bootstrapper resolves peers to bootstrap with for the P2P router.
type DNSBootstrapper ¶
type DNSBootstrapper struct {
// contains filtered or unexported fields
}
func NewDNSBootstrapper ¶
func NewDNSBootstrapper(host string) *DNSBootstrapper
type HTTPBootstrapper ¶
type HTTPBootstrapper struct {
// contains filtered or unexported fields
}
HTTPBootstrapper resolves bootstrap peers over HTTP.
func NewHTTPBootstrapper ¶
func NewHTTPBootstrapper(bootstrapURL url.URL, pool *x509.CertPool, cert *tls.Certificate) (*HTTPBootstrapper, error)
NewHTTPBootstrapper creates an HTTP bootstrapper.
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(ctx context.Context, addr string, bs Bootstrapper, peerMetadata routing.PeerMetadata, opts ...RouterOption) (*Router, error)
type RouterConfig ¶
type RouterOption ¶
type RouterOption = option.Option[RouterConfig]
func WithAdvertiseTTL ¶
func WithAdvertiseTTL(ttl time.Duration) RouterOption
func WithDataDir ¶
func WithDataDir(dataDir string) RouterOption
func WithLibP2POptions ¶
func WithLibP2POptions(opts ...libp2p.Option) RouterOption
func WithMaxReprovideDelay ¶
func WithMaxReprovideDelay(delay time.Duration) RouterOption
type StaticBootstrapper ¶
type StaticBootstrapper struct {
// contains filtered or unexported fields
}
func NewStaticBootstrapper ¶
func NewStaticBootstrapper(peers []peer.AddrInfo) *StaticBootstrapper
func NewStaticBootstrapperFromStrings ¶
func NewStaticBootstrapperFromStrings(peerStrs []string) (*StaticBootstrapper, error)
func (*StaticBootstrapper) Add ¶
func (b *StaticBootstrapper) Add(peer peer.AddrInfo)
Click to show internal directories.
Click to hide internal directories.