Categorygithub.com/multiversx/mx-chain-p2p-go
modulepackage
1.0.18
Repository: https://github.com/multiversx/mx-chain-p2p-go.git
Documentation: pkg.go.dev

# README

mx-chain-go p2p components

The Messenger interface with its implementation are used to define the way to communicate between Multiversx nodes.

There are 2 ways to send data to the other peers:

  1. Broadcasting messages on a pubsub using topics;
  2. Direct sending messages to the connected peers.

The first type is used to send messages that has to reach every node (from corresponding shard, metachain, consensus group, etc.) and the second type is used to resolve requests coming from directly connected peers.

# Packages

No description provided by the author
go:generate protoc -I=.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author

# Functions

MessageOriginatorPid will output the message peer id in a pretty format If it can, it will display the last displayLastPidChars (12) characters from the pid.
MessageOriginatorSeq will output the sequence number as hex.
PeerIdToShortString trims the first displayLastPidChars characters of the provided peer ID after converting the peer ID to string using the Pretty functionality.

# Constants

ConnectionWatcherTypeDisabled - no connection watching should be made.
ConnectionWatcherTypeEmpty - not set, no connection watching should be made.
ConnectionWatcherTypePrint - new connection found will be printed in the log file.
FullArchiveMode defines the node operation as a full archive mode.
ListsSharder is the variant that uses lists.
LocalHostListenAddrWithIp4AndTcp defines the local host listening ip v.4 address and TCP.
NilListSharder is the variant that will not do connection trimming.
NormalOperation defines the normal mode operation: either seeder, observer or validator.
OneListSharder is the variant that is shard agnostic and uses one list.
WrongP2PMessageBlacklistDuration represents the time to keep a peer id in the blacklist if it sends a message that do not follow this protocol.

# Variables

ErrAlreadySeenMessage signals that the message has already been seen.
ErrChannelCanNotBeDeleted signals that a channel can not be deleted (might be the default channel).
ErrChannelCanNotBeReAdded signals that a channel can not be re added as it is the default channel.
ErrChannelDoesNotExist signals that a requested channel does not exist.
ErrEmptyBufferToSend signals that an empty buffer was provided for sending to other peers.
ErrEndPortIsSmallerThanStartPort signals that the ending port value is smaller than the starting port value.
ErrInvalidDurationProvided signals that an invalid time.Duration has been provided.
ErrInvalidEndingPortValue signals that an invalid ending port value has been provided.
ErrInvalidPortsRangeString signals that an invalid ports range string has been provided.
ErrInvalidPortValue signals that an invalid port value has been provided.
ErrInvalidQUICAddress signals that an invalid QUIC address was used.
ErrInvalidSeedersReconnectionInterval signals that an invalid seeders reconnection interval error occurred.
ErrInvalidStartingPortValue signals that an invalid starting port value has been provided.
ErrInvalidTCPAddress signals that an invalid TCP address was used.
ErrInvalidValue signals that an invalid value has been provided.
ErrInvalidWebTransportAddress signals that an invalid WebTransport address was used.
ErrInvalidWSAddress signals that an invalid WebSocket address was used.
ErrMessageProcessorAlreadyDefined signals that a message processor was already defined on the provided topic and identifier.
ErrMessageProcessorDoesNotExists signals that a message processor does not exist on the provided topic and identifier.
ErrMessageTooLarge signals that the message provided is too large.
ErrMessageTooNew signals that a message has a timestamp that is in the future relative to self.
ErrMessageTooOld signals that a message has a timestamp that is in the past relative to self.
ErrMessageUnmarshalError signals that an invalid message was received from a peer.
ErrNilCacher signals that a nil cacher has been provided.
ErrNilConnectionsWatcher signals that a nil connections watcher has been provided.
ErrNilContext signals that a nil context was provided.
ErrNilDirectSendMessageHandler signals that the message handler for new message has not been wired.
ErrNilFetchPeersOnTopicHandler signals that a nil handler was provided.
ErrNilHost signals that a nil host has been provided.
ErrNilMarshalizer signals that an operation has been attempted to or with a nil marshalizer implementation.
ErrNilMessage signals that a nil message has been received.
ErrNilMockNet signals that a nil mocknet was provided.
ErrNilP2pKeyGenerator signals that a nil p2p key generator has been provided.
ErrNilP2pPrivateKey signals that a nil p2p private key has been provided.
ErrNilP2PSigner signals that a nil p2p signer has been provided.
ErrNilP2pSingleSigner signals that a nil p2p single signer has been provided.
ErrNilPeerDenialEvaluator signals that a nil peer denial evaluator was provided.
ErrNilPeerShardResolver signals that the peer shard resolver provided is nil.
ErrNilPeersRatingHandler signals that a nil peers rating handler has been provided.
ErrNilPeerTopicNotifier signals that a nil peer topic notifier have been provided.
ErrNilPreferredPeersHolder signals that a nil preferred peers holder was provided.
ErrNilReconnecter signals that a nil reconnecter has been provided.
ErrNilSharder signals that the provided sharder is nil.
ErrNilSyncTimer signals that a nil sync timer was provided.
ErrNilTopic signals that a nil topic has been provided.
ErrNilValidator signals that a validator hasn't been set for the required topic.
ErrNoFreePortInRange signals that no free port was found from provided range.
ErrNoTransportsDefined signals that no transports were defined.
ErrPeerDiscoveryProcessAlreadyStarted signals that a peer discovery is already turned on.
ErrPeerNotDirectlyConnected signals that the peer is not directly connected to self.
ErrTooManyGoroutines is raised when the number of goroutines has exceeded a threshold.
ErrUnsupportedFields signals that unsupported fields are provided.
ErrUnsupportedMessageVersion signals that an unsupported message version was detected.
ErrUnwantedPeer signals that the provided peer has a longer kademlia distance in respect with the already connected peers and a connection to this peer will result in an immediate disconnection.
ErrWrongTypeAssertion signals that a wrong type assertion occurred.
ErrWrongTypeAssertions signals that a wrong type assertion occurred.

# Structs

ConnectedPeersInfo represents the DTO structure used to output the metrics for connected peers.
PeerCounts represents the DTO structure used to output the count metrics for connected peers.

# Interfaces

ConnectionMonitorWrapper uses a connection monitor but checks if the peer is blacklisted or not TODO this should be removed after merging of the PeerShardResolver and BlacklistHandler.
ConnectionsWatcher represent an entity able to watch new connections.
Debugger represent a p2p debugger able to print p2p statistics (messages received/sent per topic).
DirectSender defines a component that can send direct messages to connected peers.
Marshalizer defines the 2 basic operations: serialize (marshal) and deserialize (unmarshal).
MessageP2P defines what a p2p message can do (should return).
MessageProcessor is the interface used to describe what a receive message processor should do All implementations that will be called from Messenger implementation will need to satisfy this interface If the function returns a non nil value, the received message will not be propagated to its connected peers.
Messenger is the main struct used for communication with other peers.
NetworkShardingCollector defines the updating methods used by the network sharding component The interface assures that the collected data will be used by the p2p network sharding components.
PeerDenialEvaluator defines the behavior of a component that is able to decide if a peer ID is black listed or not TODO merge this interface with the PeerShardResolver => P2PProtocolHandler ? TODO move antiflooding inside network messenger.
PeerDiscoverer defines the behaviour of a peer discovery mechanism.
PeerDiscoveryFactory defines the factory for peer discoverer implementation.
PeerShardResolver is able to resolve the link between the provided PeerID and the shardID.
PeersRatingHandler represent an entity able to handle peers ratings.
PeerTopicNotifier represent an entity able to handle new notifications on a new peer on a topic.
PreferredPeersHolderHandler defines the behavior of a component able to handle preferred peers operations.
Reconnecter defines the behaviour of a network reconnection mechanism.
Sharder defines the eviction computing process of unwanted peers.
SignerVerifier is used in higher level protocol authentication of 2 peers after the basic p2p connection has been made.
SyncTimer represent an entity able to tell the current time.

# Type aliases

NodeOperation defines the p2p node operation.