This document lists the packages and source files, excluding test units, that
implement the p2p layer, and summarizes the main types they implement.
Types play the role of classes in Go.The reference version for this documentation is the branch
v0.34.x.State of August 2022.
ConnSet interface, a “lookup table for connections and their ips”.Internal type connSet implements the ConnSet interface.Used by the transport to store connected peers.
Defines several error types.ErrRejected enumerates a number of reason for which a peer was rejected.
Mainly produced by the transport,
but also by the switch.ErrSwitchDuplicatePeerID is produced by the PeerSet used by the switch.ErrSwitchConnectToSelf is handled by the switch,
but currently is not produced outside tests.ErrSwitchAuthenticationFailure is handled by the PEX reactor,
but currently is not produced outside tests.ErrTransportClosed is produced by the transport
and handled by the switch.ErrNetAddressNoID, ErrNetAddressInvalid, and ErrNetAddressLookup
are parsing a string to create an instance of NetAddress.
It can be returned in the setup of the switch
and of the PEX reactor,
as well when the transport validates a NodeInfo, as part of
the connection handshake.ErrCurrentlyDialingOrExistingAddress is produced by the switch,
and handled by the switch and the PEX reactor.
Type NetAddress contains the ID and the network address (IP and port) of a node.The API of the address book receives and returns NetAddress instances.This source file was adapted from btcd,
a Go implementation of Bitcoin.
Interface NodeInfo stores the basic information about a node exchanged with a
peer during the handshake.It is implemented by DefaultNodeInfo type.The switch stores the local NodeInfo.The NodeInfo of connected peers is produced by the
transport during the handshake, and stored in Peer instances.
Interface Peer represents a connected peer.It is implemented by the internal peer type.The transport API methods return Peer instances,
wrapping established secure connection with peers.The switch API methods receive Peer instances.
The switch stores connected peers in a PeerSet.The Reactor methods, invoked by the switch, receive Peer instances.
Interface IPeerSet offers methods to access a table of Peer instances.Type PeerSet implements a thread-safe table of Peer instances,
used by the switch.The switch provides limited access to this table by returing a IPeerSet
instance, used by the PEX reactor.
Documented in switch.The Switch implements the peer manager role for inbound peers.Reactors have access to the Switch and may invoke its methods.
This includes the PEX reactor.
Documented in transport.The Transport interface is implemented by MultiplexTransport.The switch contains a Transport and uses it to establish
connections with peers.
Implements the MConnection type and the Channel abstraction.A MConnection multiplexes a generic network connection (net.Conn) into
multiple independent Channels, used by different Reactors.A Peer stores the MConnection instance used to interact with a
peer, which multiplex a SecretConnection.
Implements the SecretConnection type, which is an encrypted authenticated
connection built atop a raw network (TCP) connection.A Peer stores the SecretConnection established by the transport,
which is the underlying connection multiplexed by MConnection.As briefly documented in the transport,
a SecretConnection implements the Station-To-Station (STS) protocol.The SecretConnection type implements the net.Conn interface,
which is a generic network connection.
A number of errors produced and handled by the address book.ErrAddrBookNilAddr is produced by the address book, but handled (logged) by
the PEX reactor.ErrUnsolicitedList is produced and handled by the PEX protocol.