p2p

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Apr 13, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ConfigReader added in v0.7.0

type ConfigReader interface {
	// GetKeyDir returns the legacy directory for persisting node keys.
	GetKeyDir() string

	// GetMaxPeers returns the maximum number of connected peers.
	GetMaxPeers() int

	// GetListenAddrs returns the multiaddrs to listen on.
	GetListenAddrs() []string

	// GetEnableRelay reports whether this node acts as a relay for NAT traversal.
	GetEnableRelay() bool

	// GetBootstrapPeers returns the initial peers for DHT bootstrapping.
	GetBootstrapPeers() []string

	// GetEnableMDNS reports whether multicast DNS discovery is enabled.
	GetEnableMDNS() bool
}

ConfigReader is a narrow interface for the configuration fields that Node needs. Consumers define the interface (Go convention) so the p2p package does not depend on the config package.

type Node

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

Node wraps a libp2p host with DHT-based peer discovery.

func NewNode

func NewNode(cfg ConfigReader, logger *zap.SugaredLogger, secrets *security.SecretsStore) (*Node, error)

NewNode creates a libp2p node with Noise encryption and TCP/QUIC transports. The node key is persisted in SecretsStore (encrypted) when available, falling back to cfg.KeyDir for backward compatibility.

func (*Node) ConnectedPeers

func (n *Node) ConnectedPeers() []peer.ID

ConnectedPeers returns the peer IDs of all currently connected peers.

func (*Node) Host

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

Host returns the underlying libp2p host for protocol registration.

func (*Node) Multiaddrs

func (n *Node) Multiaddrs() []ma.Multiaddr

Multiaddrs returns the listen addresses of the underlying host.

func (*Node) PeerID

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

PeerID returns the node's libp2p peer ID.

func (*Node) PubSub added in v0.6.0

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

PubSub returns the shared GossipSub instance, creating it on first access.

func (*Node) SetStreamHandler

func (n *Node) SetStreamHandler(protocolID string, handler network.StreamHandler)

SetStreamHandler registers a protocol stream handler on the host.

func (*Node) Start

func (n *Node) Start(wg *sync.WaitGroup) error

Start bootstraps the Kademlia DHT and optionally starts mDNS discovery. The WaitGroup is incremented so callers can wait for graceful shutdown.

func (*Node) Stop

func (n *Node) Stop() error

Stop shuts down the DHT, mDNS service, and libp2p host.

Directories

Path Synopsis
Package agentpool manages a pool of discovered P2P agents with health checking, weighted selection, and capability-based filtering.
Package agentpool manages a pool of discovered P2P agents with health checking, weighted selection, and capability-based filtering.
Package discovery implements gossip-based agent card propagation and peer discovery.
Package discovery implements gossip-based agent card propagation and peer discovery.
Package firewall implements the Knowledge Firewall for P2P queries.
Package firewall implements the Knowledge Firewall for P2P queries.
Package handshake implements ZK-enhanced peer authentication and session management.
Package handshake implements ZK-enhanced peer authentication and session management.
Package identity provides decentralized identity (DID) derivation from wallet public keys.
Package identity provides decentralized identity (DID) derivation from wallet public keys.
Package ontologybridge connects the P2P protocol handler to the ontology service.
Package ontologybridge connects the P2P protocol handler to the ontology service.
Package paygate implements a payment gate that checks tool pricing and verifies EIP-3009 payment authorizations between the firewall and tool executor in the P2P protocol.
Package paygate implements a payment gate that checks tool pricing and verifies EIP-3009 payment authorizations between the firewall and tool executor in the P2P protocol.
Package protocol implements the A2A-over-P2P message exchange protocol.
Package protocol implements the A2A-over-P2P message exchange protocol.
Package reputation tracks peer trust scores based on exchange outcomes.
Package reputation tracks peer trust scores based on exchange outcomes.
Package settlement handles asynchronous on-chain settlement of P2P tool invocation payments.
Package settlement handles asynchronous on-chain settlement of P2P tool invocation payments.
Package team defines the types and coordination primitives for P2P agent teams.
Package team defines the types and coordination primitives for P2P agent teams.
zkp
Package zkp provides zero-knowledge proof generation and verification using the gnark library with support for PlonK and Groth16 proving schemes.
Package zkp provides zero-knowledge proof generation and verification using the gnark library with support for PlonK and Groth16 proving schemes.
circuits
Package circuits provides gnark circuit definitions for zero-knowledge proofs used in agent identity, attestation, and capability verification.
Package circuits provides gnark circuit definitions for zero-knowledge proofs used in agent identity, attestation, and capability verification.

Jump to

Keyboard shortcuts

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