Expand description
Protocol Controller. Generic implementation of peer management for protocols.
Responsible for accepting/rejecting incoming connections and initiating outgoing connections,
respecting the inbound and outbound peer slot counts. Communicates with PeerStore to get and
update peer reputation values and sends commands to Notifications.
Due to asynchronous nature of communication between ProtocolController and Notifications,
ProtocolController has an imperfect view of the states of the peers. To reduce this
desynchronization, the following measures are taken:
- Network peer events from 
Notificationsare prioritized over actions from external API and internal actions byProtocolController(like slot allocation). Notificationsignores all commands fromProtocolControllerafter sending “incoming” request until receiving the answer to this “incoming” request.- After sending a “connect” message, 
ProtocolControllerswitches the state of the peer fromOutboundtoInboundif it receives an “incoming” request fromNotificationsfor this peer. 
These measures do not eliminate confusing commands from ProtocolController completely,
so Notifications must correctly handle seemingly inconsistent commands, like a “connect”
command for the peer it thinks is already connected, and a “drop” command for a peer that
was previously dropped.
Even though this does not guarantee that ProtocolController and Notifications have the same
view of the peers’ states at any given moment, the eventual consistency is maintained.
Structs§
- Incoming
Index  - Opaque identifier for an incoming connection. Allocated by the network.
 - Proto
SetConfig  - Configuration for a set of nodes for a specific protocol.
 - Protocol
Controller  - Worker side of 
ProtocolHandleresponsible for all the logic. - Protocol
Handle  - Shared handle to 
ProtocolController. Distributed around the code outside of the protocol implementation. - SetId
 Notificationsprotocol index. For historical reasons it’s calledSetId, because it used to refer to a set of peers in a peerset for this protocol.
Enums§
- Message
 - Message that is sent by 
ProtocolControllertoNotifications. 
Constants§
- LOG_
TARGET  - Log target for this file.