Expand description
Seed sync session creates a connection to the seed nodes specified in settings.
A new seed sync session is created every time we call P2p::start()
. The
seed sync session loops through all the configured seeds and creates a corresponding
Slot
. Slot
’s are started, but sit in a suspended state until they are activated
by a call to notify (see: p2p.seed()
).
When a Slot
has been activated by a call to notify()
, it will try to connect
to the given seed address using a Connector
. This will either connect successfully
or fail with a warning. With gather the results of each Slot
in an AtomicBool
so that we can handle the error elsewhere in the code base.
If a seed node connects successfully, it runs a version exchange protocol, stores the channel in the p2p list of channels, and disconnects, removing the channel from the channel list.
The channel is registered using the Session::register_channel()
trait
method. This invokes the Protocol Registry method attach()
. Usually this
returns a list of protocols that we loop through and start. In this case,
attach()
uses the bitflag selector to identify seed sessions and exclude
them.
The version exchange occurs inside register_channel()
. We create a handshake
task that runs the version exchange with the perform_handshake_protocols()
function. This runs the version exchange protocol, stores the channel in the
p2p list of channels, and subscribes to a stop signal.
Structs§
- Defines seed connections session
- Slot 🔒