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
Notifications
are prioritized over actions from external API and internal actions byProtocolController
(like slot allocation). Notifications
ignores all commands fromProtocolController
after sending “incoming” request until receiving the answer to this “incoming” request.- After sending a “connect” message,
ProtocolController
switches the state of the peer fromOutbound
toInbound
if it receives an “incoming” request fromNotifications
for 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§
- Opaque identifier for an incoming connection. Allocated by the network.
- Configuration for a set of nodes for a specific protocol.
- Worker side of
ProtocolHandle
responsible for all the logic. - Shared handle to
ProtocolController
. Distributed around the code outside of the protocol implementation. Notifications
protocol 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 that is sent by
ProtocolController
toNotifications
.
Constants§
- Log target for this file.