cluster

package
v0.1.1-0...-12c552a Latest Latest
Warning

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

Go to latest
Published: May 14, 2026 License: MIT Imports: 29 Imported by: 0

Documentation

Overview

Package cluster provides types and methods for working with a libp2p cluster.

Index

Constants

This section is empty.

Variables

View Source
var ErrNoPeersAvailable = errors.New("no peers discovered in DHT")

Functions

func NewDHT

func NewDHT(ctx context.Context, h host.Host, cfg *config.Cluster) (*dht.IpfsDHT, error)

func PushPullInterval

func PushPullInterval(n int, interval time.Duration) time.Duration

PushPullInterval returns the push/pull interval for the given network size. We scale the push/pull interval based on the network size for clusters > 32 nodes to prevent saturating the network with state sync requests, same as memberlist.

Types

type Cluster

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

Cluster represents a distributed peer-to-peer network, managed via libp2p.

func New

func New(cfg *config.Config, files *state.Files, resolver dmnet.InterfaceResolver) (*Cluster, error)

New initializes and returns a new Cluster instance with the provided configuration and store.

func (*Cluster) Join

func (c *Cluster) Join(ctx context.Context) error

Join connects to bootstrap peers and starts the push-pull loop.

func (*Cluster) Leave

func (c *Cluster) Leave(_ context.Context) error

Leave gracefully shuts down the cluster by closing the host.

func (*Cluster) PushPullLoop

func (c *Cluster) PushPullLoop(ctx context.Context) error

PushPullLoop periodically selects one random connected peer and exchanges state.

type ConnectionGater

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

func NewConnectionGater

func NewConnectionGater(interfaces []string, resolver dmnet.InterfaceResolver) *ConnectionGater

func (*ConnectionGater) InterceptAccept

func (c *ConnectionGater) InterceptAccept(multiaddrs network.ConnMultiaddrs) bool

func (*ConnectionGater) InterceptAddrDial

func (c *ConnectionGater) InterceptAddrDial(id peer.ID, multiaddr multiaddr.Multiaddr) bool

func (*ConnectionGater) InterceptPeerDial

func (c *ConnectionGater) InterceptPeerDial(peer.ID) bool

func (*ConnectionGater) InterceptSecured

func (c *ConnectionGater) InterceptSecured(_ network.Direction, _ peer.ID, _ network.ConnMultiaddrs) bool

func (*ConnectionGater) InterceptUpgraded

func (c *ConnectionGater) InterceptUpgraded(_ network.Conn) (bool, control.DisconnectReason)

Jump to

Keyboard shortcuts

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