Skip to content
This repository has been archived by the owner on Oct 31, 2024. It is now read-only.

Commit

Permalink
chore: adding logs on channel failure
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <[email protected]>
  • Loading branch information
Freyskeyd committed Apr 19, 2024
1 parent 42bde65 commit 4490cb6
Showing 1 changed file with 37 additions and 11 deletions.
48 changes: 37 additions & 11 deletions crates/topos-tce/src/app_context/network.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
use futures::TryFutureExt;
use prost::Message;
use std::collections::hash_map;
use tokio::sync::mpsc::error::TrySendError;
use topos_tce_storage::errors::{InternalStorageError, StorageError};

use tokio::spawn;
Expand Down Expand Up @@ -50,22 +52,32 @@ impl AppContext {
certificate_id
);

if self
match self
.tce_cli
.get_double_echo_channel()
.send(DoubleEchoCommand::Broadcast {
need_gossip: false,
cert,
pending_id,
})
.map_err(TrySendError::from)
.await
.is_err()
{
error!(
"Unable to send DoubleEchoCommand::Broadcast command \
to double echo for {}",
certificate_id
);
Err(TrySendError::Full(_)) => {
error!(
"Unable to send DoubleEchoCommand::Broadcast command \
to double echo for {}, channel is full",
certificate_id
);
}
Err(TrySendError::Closed(_)) => {
error!(
"Unable to send DoubleEchoCommand::Broadcast command \
to double echo for {}, channel is closed",
certificate_id
);
}
Ok(_) => {}
}
}

Expand Down Expand Up @@ -136,15 +148,22 @@ impl AppContext {
validator_id = validator_id
);

if let Err(e) = channel
match channel
.send(DoubleEchoCommand::Echo {
signature: signature.into(),
certificate_id,
validator_id,
})
.map_err(TrySendError::from)
.await
{
error!("Unable to pass received Echo message: {:?}", e);
Err(TrySendError::Full(_)) => {
error!("Unable to process Echo message due to DoubleEchoChannel being full");
}
Err(TrySendError::Closed(_)) => {
error!("Unable to process Echo message due to DoubleEchoChannel being closed");
}
Ok(_) => {}
}
} else {
error!("Unable to process Echo message due to invalid data");
Expand Down Expand Up @@ -181,15 +200,22 @@ impl AppContext {
certificate_id = certificate_id,
validator_id = validator_id
);
if let Err(e) = channel
match channel
.send(DoubleEchoCommand::Ready {
signature: signature.into(),
certificate_id,
validator_id,
})
.map_err(TrySendError::from)
.await
{
error!("Unable to pass received Ready message: {:?}", e);
Err(TrySendError::Full(_)) => {
error!("Unable to process Ready message due to DoubleEchoChannel being full");
}
Err(TrySendError::Closed(_)) => {
error!("Unable to process Ready message due to DoubleEchoChannel being closed");
}
Ok(_) => {}
}
} else {
error!("Unable to process Ready message due to invalid data");
Expand Down

0 comments on commit 4490cb6

Please sign in to comment.