network

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: BSD-3-Clause Imports: 7 Imported by: 0

Documentation

Overview

Package network handles P2P communication between nodes

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidConfig = fmt.Errorf("invalid network configuration")

ErrInvalidConfig indicates the network configuration is invalid

Functions

This section is empty.

Types

type Config

type Config struct {
	// Port is the port to listen on (0 for random)
	Port int

	// Peer is the multiaddr of a peer to connect to (optional)
	Peer string
}

Config represents network configuration

type Node

type Node interface {
	// Host returns the libp2p host
	Host() host.Host

	// Connect connects to a peer
	Connect(ctx context.Context, addr multiaddr.Multiaddr) error

	// Peers returns the list of connected peers
	Peers() []peer.ID

	// Close closes the node
	Close() error
}

Node represents a P2P network node

func NewNode

func NewNode(ctx context.Context, cfg Config) (Node, error)

NewNode creates a new P2P network node

Jump to

Keyboard shortcuts

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