|
|
@@ -8,9 +8,26 @@ use crate::Result;
|
|
|
|
|
|
use super::{p2p::P2pPtr, protocol::ProtocolVersion, ChannelPtr};
|
|
|
|
|
|
-/// Seed connections session. Manages the creation of seed sessions. Used on
|
|
|
-/// first time connecting to the network. The seed node stores a list of other
|
|
|
-/// nodes in the network.
|
|
|
+/// Seed session creates a connection to the seed nodes specified in settings.
|
|
|
+/// A new seed session is created every time we call p2p::start(). The seed
|
|
|
+/// session loops through all the configured seeds and tries to connect to
|
|
|
+/// them using a Connector. The seed session either connects successfully,
|
|
|
+/// fails with an error or times out.
|
|
|
+///
|
|
|
+/// 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 Session trait method, register_channel().
|
|
|
+/// 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 function
|
|
|
+/// perform_handshake_protocols(). This runs the version exchange protocol,
|
|
|
+/// stores the channel in the p2p list of channels, and subscribes to a stop
|
|
|
+/// signal.
|
|
|
pub mod seed_session;
|
|
|
|
|
|
pub mod manual_session;
|
|
|
@@ -18,7 +35,7 @@ pub mod manual_session;
|
|
|
/// Inbound connections session. Manages the creation of inbound sessions. Used
|
|
|
/// to create an inbound session and start and stop the session.
|
|
|
///
|
|
|
-/// Class consists of 3 pointers: a weak pointer to the peer-to-peer class, an
|
|
|
+/// Class consists of 3 pointers: a weak pointer to the p2p parent class, an
|
|
|
/// acceptor pointer, and a stoppable task pointer. Using a weak pointer to P2P
|
|
|
/// allows us to avoid circular dependencies.
|
|
|
pub mod inbound_session;
|
|
|
@@ -26,7 +43,7 @@ pub mod inbound_session;
|
|
|
/// Outbound connections session. Manages the creation of outbound sessions.
|
|
|
/// Used to create an outbound session and stop and start the session.
|
|
|
///
|
|
|
-/// Class consists of a weak pointer to the peer-to-peer interface and a vector
|
|
|
+/// Class consists of a weak pointer to the p2p interface and a vector
|
|
|
/// of outbound connection slots. Using a weak pointer to p2p allows us to avoid
|
|
|
/// circular dependencies. The vector of slots is wrapped in a mutex lock. This
|
|
|
/// is switched on everytime we instantiate a connection slot and insures that
|