node

package
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2026 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// LowWater is the minimum number of connections to maintain (D_lo)
	LowWater = 4
	// HighWater is the maximum number of connections (D_hi)
	HighWater = 8
	// GracePeriod is how long to wait before pruning connections
	GracePeriod = 0
)

Connection limits matching GossipSub mesh parameters

Variables

This section is empty.

Functions

This section is empty.

Types

type Node

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

func NewNode

func NewNode(ctx context.Context) (*Node, error)

func (*Node) Addrs

func (n *Node) Addrs() []multiaddr.Multiaddr

func (*Node) Context

func (n *Node) Context() context.Context

func (*Node) Host

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

func (*Node) ID

func (n *Node) ID() peer.ID

func (*Node) ListPeers

func (n *Node) ListPeers() string

ListPeers logs peer list (for debug) and returns formatted string

func (*Node) PeerManager

func (n *Node) PeerManager() *PeerManager

func (*Node) PubSub

func (n *Node) PubSub() *pubsub.PubSub

PubSub returns the GossipSub instance

func (*Node) SetProtocol

func (n *Node) SetProtocol(p Protocol)

type PeerCallback

type PeerCallback func(peerID string, connected bool)

PeerCallback is called when a peer connects or disconnects

type PeerManager

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

func NewPeerManager

func NewPeerManager(maxPeers int) *PeerManager

func (*PeerManager) Add

func (pm *PeerManager) Add(p peer.ID) bool

func (*PeerManager) Count

func (pm *PeerManager) Count() int

func (*PeerManager) Has

func (pm *PeerManager) Has(p peer.ID) bool

func (*PeerManager) IsFull

func (pm *PeerManager) IsFull() bool

func (*PeerManager) List

func (pm *PeerManager) List() []peer.ID

func (*PeerManager) ParsePeer added in v1.1.0

func (pm *PeerManager) ParsePeer(peerID string) (peer.ID, error)

func (*PeerManager) Remove

func (pm *PeerManager) Remove(p peer.ID)

func (*PeerManager) SetCallback

func (pm *PeerManager) SetCallback(cb PeerCallback)

type Protocol

type Protocol interface {
	HandleStream(network.Stream)
}

Jump to

Keyboard shortcuts

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