libp2p

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

Package libp2p provides discovery mechanisms using Kademlia DHT.

Index

Constants

View Source
const JoinProtocol = protocol.ID("/webmesh/join/0.0.1")

JoinProtocol is the protocol used for joining a mesh.

Variables

This section is empty.

Functions

func NewDHTAnnouncer

func NewDHTAnnouncer(ctx context.Context, opts DHTAnnounceOptions, join transport.JoinServer) (io.Closer, error)

NewDHTAnnouncer creates a new announcer on the kadmilia DHT and executes received join requests against the given join Server.

func NewJoinRoundTripper

func NewJoinRoundTripper(opts RoundTripOptions) transport.JoinRoundTripper

NewJoinRoundTripper returns a round tripper that uses the libp2p kademlia DHT to join a cluster.

func NewRoundTripper

func NewRoundTripper[REQ, RESP any](opts RoundTripOptions, method string) transport.RoundTripper[REQ, RESP]

NewRoundTripper returns a round tripper that uses the libp2p kademlia DHT.

Types

type DHTAnnounceOptions

type DHTAnnounceOptions struct {
	// PSK is the pre-shared key to use as a rendezvous point for the DHT.
	PSK string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// Options are options for configuring the libp2p host.
	Options []libp2p.Option
	// DiscoveryTTL is the TTL to use for the discovery service.
	// This is only applicable when announcing the host.
	DiscoveryTTL time.Duration
}

DHTAnnounceOptions are options for announcing the host or discovering peers on the libp2p kademlia DHT.

type RoundTripOptions

type RoundTripOptions struct {
	// PSK is the pre-shared key to use as a rendezvous point for the DHT.
	PSK string
	// BootstrapPeers is a list of bootstrap peers to use for the DHT.
	// If empty or nil, the default bootstrap peers will be used.
	BootstrapPeers []multiaddr.Multiaddr
	// Options are options for configuring the libp2p host.
	Options []libp2p.Option
	// ConnectTimeout is the per-address timeout for connecting to a peer.
	ConnectTimeout time.Duration
}

RoundTripOptions are options for performing a round trip against a libp2p host.

type Stream

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

Stream is a wrapper around a libp2p stream.

func (*Stream) Close

func (s *Stream) Close() error

func (*Stream) Read

func (s *Stream) Read(p []byte) (int, error)

func (*Stream) Write

func (s *Stream) Write(p []byte) (int, error)

Jump to

Keyboard shortcuts

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