Documentation
¶
Overview ¶
Package libp2p provides discovery mechanisms using Kademlia DHT.
Index ¶
- Constants
- func NewDHTAnnouncer(ctx context.Context, opts DHTAnnounceOptions, join transport.JoinServer) (io.Closer, error)
- func NewJoinRoundTripper(opts RoundTripOptions) transport.JoinRoundTripper
- func NewRoundTripper[REQ, RESP any](opts RoundTripOptions, method string) transport.RoundTripper[REQ, RESP]
- type DHTAnnounceOptions
- type RoundTripOptions
- type Stream
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.
Click to show internal directories.
Click to hide internal directories.