package
0.0.1
Repository: https://github.com/libonomy/libonomy-p2p.git
Documentation: pkg.go.dev

# Packages

Package config defines configuration used in the p2p package.
Package connectionpool functions as a connection cache that takes care of connecting and reusing connected sockets.
Package discovery implements uses bitcoin-based addrbook to store network addresses and collects them by crawling the network using a simple protocol.
Package gossip implements simple protocol to send new validated messages to all peers and ignore old or not valid messages.
Package metrics defines metric reporting for the p2p component.
Package net manages the accepting network connections/messages and routing the data upward for the protocols to consume.
Package node defines simple data structures to represent p2p node identities.
Package p2pcrypto defines the cryptographic primitives used to communicate and identify in the p2p network, it uses go stdlib's NaCL box implementation.
Package server is used to wrap the p2p services to define multiple req-res messages under one protocol.
Package service defines basic interfaces to for protocols to consume p2p functionality.
Package version includes methods to compare versions between nodes.

# Functions

CreatePayload is a helper function to format a payload for sending.
ExtractData is a helper function to extract the payload data from a message payload.
New creates a new P2P service a.k.a `Switch` it loads existing node information from the disk or creates a new one.
NewPeers creates a Peers instance that is registered to `s`'s events and updates with them.
NewPeersImpl creates a Peers using specified parameters and returns it.
NewUDPMux creates a new udp protocol server.
StringIdentifiers turns Switch into string representation node for use as bootnodes.

# Constants

todo: add to the config.
NoResultsInterval is the timeout we wait between requesting more peers repeatedly.
UPNPRetries is the number of times to retry obtaining a port due to a UPnP failure.

# Variables

ErrBadFormat1 could'nt deserialize the payload.
ErrBadFormat2 could'nt deserialize the protocol message payload.
ErrFailDecrypt session cant decrypt.
ErrNoProtocol we don't have the protocol message.
ErrNoSession we don't have this session.
ErrOutOfSync is returned when message timestamp was out of sync.

# Structs

IntegrationTestSuite is a suite which bootstraps a network according to the given params and lets you run actions on this network.
Payload holds either a byte array or a wrapped req-res message.
Peers is used by protocols to manage available peers.
ProtocolMessage is a pair of metadata and a a payload.
ProtocolMessageMetadata is a general p2p message wrapper.
Switch is the heart of the p2p package.
UDPMux is a server for receiving and sending udp messages.

# Interfaces

NodeTestInstance is an instance of a p2p node for testing.
PeerSubscriptionProvider is the interface that provides us with peer events channels.

# Type aliases

Lookuper is a service used to lookup for nodes we know already.
Peer is represented by a p2p identity public key.
Service is a wrapper for service.Service to expose the Service interface to `p2p` package clients.