Skip to content

Commit

Permalink
refacrot(p2p): add clarification comment for message_sender.send()
Browse files Browse the repository at this point in the history
Co-authored-by: ⭐️NINIKA⭐️ <[email protected]>
Signed-off-by: Shanin Roman <[email protected]>
  • Loading branch information
Erigara and DCNick3 authored Sep 5, 2024
1 parent aa88de0 commit 530aeff
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions p2p/src/peer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,11 @@ mod run {
idle_interval.reset();
ping_interval.reset();
}
// `message_sender.send()` is safe to be cancelled, it won't advance the queue or write anything if another branch completes first.
//
// We need to conditionally disable it in case there is no data is to be sent, otherwise `message_sender.send()` will complete immediately
//
// The only source of data to be sent is other branches of this loop, so we do not need any async waiting mechanism for waiting for readiness.
result = message_sender.send(), if message_sender.ready() => {
if let Err(error) = result {
iroha_logger::error!(%error, "Failed to send message to peer.");
Expand Down

0 comments on commit 530aeff

Please sign in to comment.