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

Commit

Permalink
chore: refactor after review
Browse files Browse the repository at this point in the history
Signed-off-by: Simon Paitrault <simon.paitrault@gmail.com>
  • Loading branch information
Freyskeyd committed Mar 12, 2024
1 parent e459b6a commit ae3e1b5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 5 deletions.
3 changes: 3 additions & 0 deletions crates/topos-tce-api/src/runtime/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ pub enum RuntimeError {

#[error("Unexpected store error: {0}")]
Store(#[from] StorageError),

#[error("Communication error: {0}")]
CommunicationError(String),
}
4 changes: 4 additions & 0 deletions crates/topos-tce-storage/src/validator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,8 @@ impl ValidatorStore {
}

/// Returns the number of certificates in the pending pool (by iterating)
///
/// Performance can be an issue on this one as we iter over all the pending certificates.
pub fn iter_count_pending_certificates(&self) -> Result<u64, StorageError> {
Ok(self
.pending_tables
Expand All @@ -158,6 +160,8 @@ impl ValidatorStore {
}

/// Returns the number of certificates in the precedence pool (by iterating)
///
/// Performance can be an issue on this one as we iter over all the precedence certificates.
pub fn iter_count_precedence_pool_certificates(&self) -> Result<u64, StorageError> {
Ok(self
.pending_tables
Expand Down
19 changes: 16 additions & 3 deletions crates/topos-tce/src/app_context/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,17 +30,30 @@ impl AppContext {
certificate.id, certificate.source_subnet_id
);

_ = self
if let Err(_) = self
.tce_cli
.get_double_echo_channel()
.send(DoubleEchoCommand::Broadcast {
need_gossip: true,
cert: *certificate,
pending_id,
})
.await;
.await
{
error!(
"Unable to send DoubleEchoCommand::Broadcast command to double \
echo for {}",
certificate.id
);

sender.send(Ok(PendingResult::InPending(pending_id)))
sender.send(Err(RuntimeError::CommunicationError(
"Unable to send DoubleEchoCommand::Broadcast command to double \
echo"
.to_string(),
)))
} else {
sender.send(Ok(PendingResult::InPending(pending_id)))
}
}
Ok(None) => {
debug!(
Expand Down
11 changes: 9 additions & 2 deletions crates/topos-tce/src/app_context/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,22 @@ impl AppContext {
cert.id
);

_ = self
if let Err(_) = self
.tce_cli
.get_double_echo_channel()
.send(DoubleEchoCommand::Broadcast {
need_gossip: false,
cert,
pending_id,
})
.await;
.await
{
error!(
"Unable to send DoubleEchoCommand::Broadcast command to \
double echo for {}",
certificate.id
);
}
}
Ok(None) => {
debug!(
Expand Down

0 comments on commit ae3e1b5

Please sign in to comment.