Эх сурвалжийг харах

more verbose documentation edit on p2p.rs. summarizes interface utlities

rachel-rose 5 жил өмнө
parent
commit
78816ccb61
1 өөрчлөгдсөн 7 нэмэгдсэн , 2 устгасан
  1. 7 2
      src/net/p2p.rs

+ 7 - 2
src/net/p2p.rs

@@ -18,7 +18,12 @@ pub type ConnectedChannels<T> = Mutex<HashMap<SocketAddr, Arc<T>>>;
 /// Atomic pointer to p2p interface.
 /// Atomic pointer to p2p interface.
 pub type P2pPtr = Arc<P2p>;
 pub type P2pPtr = Arc<P2p>;
 
 
-/// Top level peer-to-peer networking interface.
+/// Top level peer-to-peer networking interface. Provides all core functionality
+/// to interact with the peer-to-peer network. Used to create a network, to
+/// start and run it, to broadcast messages across all channels, and to manage
+/// the channel store. The channel store is a hashmap of channel address that we
+/// can use to add and remove channels or check whether a channel is already is
+/// in the store.
 pub struct P2p {
 pub struct P2p {
     pending: PendingChannels,
     pending: PendingChannels,
     channels: ConnectedChannels<Channel>,
     channels: ConnectedChannels<Channel>,
@@ -137,7 +142,7 @@ impl P2p {
         self.channel_subscriber.clone().subscribe().await
         self.channel_subscriber.clone().subscribe().await
     }
     }
 
 
-    /// Stop a subscription.
+    /// Subscribe to a stop signal.
     pub async fn subscribe_stop(&self) -> Subscription<NetError> {
     pub async fn subscribe_stop(&self) -> Subscription<NetError> {
         self.stop_subscriber.clone().subscribe().await
         self.stop_subscriber.clone().subscribe().await
     }
     }