host

package
v0.0.0-...-cdc5ecf Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2025 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps a libp2p host with common functionality

func NewClient

func NewClient(keyPath string) (*Client, error)

NewClient creates a new libp2p host with the given configuration

func (*Client) Close

func (h *Client) Close() error

Close closes the host

func (*Client) Connect

func (h *Client) Connect(ctx context.Context, addr string) (peer.ID, error)

Connect connects to a peer at the given multiaddr

func (*Client) ConnectMultiple

func (h *Client) ConnectMultiple(ctx context.Context, addrs []string) (peer.ID, string, error)

ConnectMultiple tries to connect to a peer using multiple addresses Returns the peer ID and the successful address

func (*Client) Host

func (h *Client) Host() host.Host

Host returns the underlying libp2p host

func (*Client) ID

func (h *Client) ID() peer.ID

ID returns the peer ID of this host

type Node

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

func NewNode

func NewNode(cfg NodeConfig) (*Node, error)

func (*Node) Close

func (n *Node) Close() error

func (*Node) ConnectRelay

func (n *Node) ConnectRelay(ctx context.Context, relayAddr string) error

func (*Node) Host

func (n *Node) Host() host.Host

func (*Node) StartRelay

func (n *Node) StartRelay() error

type NodeConfig

type NodeConfig struct {
	ListenAddr   string
	PrivateKey   crypto.PrivKey
	RelayMode    bool
	ConnectRelay string
	Key          string
}

type Notifee

type Notifee struct {
	Logger *slog.Logger
}

func NewNotifee

func NewNotifee(logger *slog.Logger) *Notifee

func (*Notifee) Connected

func (n *Notifee) Connected(net network.Network, conn network.Conn)

func (*Notifee) Disconnected

func (n *Notifee) Disconnected(net network.Network, conn network.Conn)

func (*Notifee) Listen

func (n *Notifee) Listen(net network.Network, ma multiaddr.Multiaddr)

func (*Notifee) ListenClose

func (n *Notifee) ListenClose(net network.Network, ma multiaddr.Multiaddr)

Jump to

Keyboard shortcuts

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