-
Notifications
You must be signed in to change notification settings - Fork 89
chore(network): create docstrings for network manager #2250
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #2250 +/- ##
=======================================
Coverage 66.34% 66.34%
=======================================
Files 139 139
Lines 18379 18379
Branches 18379 18379
=======================================
Hits 12194 12194
Misses 4890 4890
Partials 1295 1295 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewed 1 of 1 files at r1.
Reviewable status: all files reviewed (commit messages unreviewed), 14 unresolved discussions (waiting on @eitanm-starkware)
crates/papyrus_network/src/network_manager/mod.rs
line 1 at r1 (raw file):
mod swarm_trait;
Add a mod documentation block (//!
), stating that this module contains a NetworkManager which runs the network
crates/papyrus_network/src/network_manager/mod.rs
line 58 at r1 (raw file):
impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> { /// Starts processing network events. This function runs indefinitely, handling connections,
This docstring is a bit long. Try to move as much information as possible to the module documentation or to the struct documentation and state here that this runs the NetworkManager
crates/papyrus_network/src/network_manager/mod.rs
line 59 at r1 (raw file):
impl<SwarmT: SwarmTrait> GenericNetworkManager<SwarmT> { /// Starts processing network events. This function runs indefinitely, handling connections, /// disconnections, messages, and other network-related events as they occur.
Put messages first, as it is the most important of the stuff you've mentioned here.
You should also probably mention discovery and peer choosing before connections and disconnections. Maybe you can use other words for that, I'll leave it up to you
crates/papyrus_network/src/network_manager/mod.rs
line 61 at r1 (raw file):
/// disconnections, messages, and other network-related events as they occur. /// /// The function processes events from the `swarm`, handles incoming and outgoing SQMR messages,
Remove the swarm part. It's an implementation detail
crates/papyrus_network/src/network_manager/mod.rs
line 62 at r1 (raw file):
/// /// The function processes events from the `swarm`, handles incoming and outgoing SQMR messages, /// and manages broadcasts and peer reports. It utilizes `tokio::select!` to concurrently
remove the part about tokio::select. It's also an implementation detail
crates/papyrus_network/src/network_manager/mod.rs
line 66 at r1 (raw file):
/// /// # Examples /// ```rust
I've already added code examples in #2243. I think you can remove them from all this file (those that I added a TODO to write you can copy what you did here and paste it there)`
crates/papyrus_network/src/network_manager/mod.rs
line 126 at r1 (raw file):
/// This function will panic if the protocol is already registered. /// /// The `SqmrServerReceiver` returned by this function can be used in an asynchronous loop
remove "in an asynchronous loop". IMO it's redundant
crates/papyrus_network/src/network_manager/mod.rs
line 127 at r1 (raw file):
/// /// The `SqmrServerReceiver` returned by this function can be used in an asynchronous loop /// to process incoming queries.
and send responses and reports to those queries
crates/papyrus_network/src/network_manager/mod.rs
line 129 at r1 (raw file):
/// to process incoming queries. /// /// # Parameters
Could you make sure this is the format for documenting the parameters and return type of a function in rust
crates/papyrus_network/src/network_manager/mod.rs
line 131 at r1 (raw file):
/// # Parameters /// - `protocol`: Identifier for the protocol. /// - `buffer_size`: The size of the internal message buffer.
The size of the buffer in the returned channel
crates/papyrus_network/src/network_manager/mod.rs
line 193 at r1 (raw file):
} /// Registers a client-side SQMR protocol with a buffer for outgoing messages.
messages -> queries
crates/papyrus_network/src/network_manager/mod.rs
line 197 at r1 (raw file):
/// /// The `SqmrClientSender` returned by this function is used to send queries and asynchronously /// handle responses.
and report them
crates/papyrus_network/src/network_manager/mod.rs
line 201 at r1 (raw file):
/// # Parameters /// - `protocol`: Identifier for the protocol. /// - `buffer_size`: The size of the internal message buffer.
Same as before
crates/papyrus_network/src/network_manager/mod.rs
line 272 at r1 (raw file):
/// The `BroadcastSubscriberChannels` structure contains senders and receivers for managing /// broadcast messages. ///
Add an important note that if the node is done for a short period all messages sent in that period will be missed, and that while most messages will reach all transitively-connected peers, it is not guaranteed and misses can occur
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reviewable status: all files reviewed (commit messages unreviewed), 14 unresolved discussions (waiting on @ShahakShama)
crates/papyrus_network/src/network_manager/mod.rs
line 1 at r1 (raw file):
Previously, ShahakShama wrote…
Add a mod documentation block (
//!
), stating that this module contains a NetworkManager which runs the network
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 58 at r1 (raw file):
Previously, ShahakShama wrote…
This docstring is a bit long. Try to move as much information as possible to the module documentation or to the struct documentation and state here that this runs the NetworkManager
finished. left examples for now. lets discuss moving examples. i think they should be next to the function impl
crates/papyrus_network/src/network_manager/mod.rs
line 59 at r1 (raw file):
Previously, ShahakShama wrote…
Put messages first, as it is the most important of the stuff you've mentioned here.
You should also probably mention discovery and peer choosing before connections and disconnections. Maybe you can use other words for that, I'll leave it up to you
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 61 at r1 (raw file):
Previously, ShahakShama wrote…
Remove the swarm part. It's an implementation detail
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 62 at r1 (raw file):
Previously, ShahakShama wrote…
remove the part about tokio::select. It's also an implementation detail
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 66 at r1 (raw file):
Previously, ShahakShama wrote…
I've already added code examples in #2243. I think you can remove them from all this file (those that I added a TODO to write you can copy what you did here and paste it there)`
i think we can have in both locations if needed. these examples focus on function usage. the doc focuses on an actual flow
crates/papyrus_network/src/network_manager/mod.rs
line 126 at r1 (raw file):
Previously, ShahakShama wrote…
remove "in an asynchronous loop". IMO it's redundant
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 127 at r1 (raw file):
Previously, ShahakShama wrote…
and send responses and reports to those queries
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 129 at r1 (raw file):
Previously, ShahakShama wrote…
Could you make sure this is the format for documenting the parameters and return type of a function in rust
there is no standard format from what I read
crates/papyrus_network/src/network_manager/mod.rs
line 131 at r1 (raw file):
Previously, ShahakShama wrote…
The size of the buffer in the returned channel
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 193 at r1 (raw file):
Previously, ShahakShama wrote…
messages -> queries
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 197 at r1 (raw file):
Previously, ShahakShama wrote…
and report them
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 201 at r1 (raw file):
Previously, ShahakShama wrote…
Same as before
Done.
crates/papyrus_network/src/network_manager/mod.rs
line 272 at r1 (raw file):
Previously, ShahakShama wrote…
Add an important note that if the node is done for a short period all messages sent in that period will be missed, and that while most messages will reach all transitively-connected peers, it is not guaranteed and misses can occur
Done.
This change is![Reviewable](https://camo.githubusercontent.com/1541c4039185914e83657d3683ec25920c672c6c5c7ab4240ee7bff601adec0b/68747470733a2f2f72657669657761626c652e696f2f7265766965775f627574746f6e2e737667)