Skip to content

Commit

Permalink
interfaces: generalize retryable erros
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Oct 24, 2022
1 parent b0e86ff commit b522f7d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion crates/interfaces/src/consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use tokio::sync::watch::Receiver;
/// Consensus is a protocol that chooses canonical chain.
/// We are checking validity of block header here.
#[async_trait]
pub trait Consensus {
pub trait Consensus: Send + Sync {
/// Get a receiver for the fork choice state
fn fork_choice_state(&self) -> Receiver<ForkchoiceState>;

Expand Down
7 changes: 4 additions & 3 deletions crates/interfaces/src/p2p/headers/downloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,16 @@ pub enum DownloadError {
}

impl DownloadError {
/// Returns bool indicating whether this error is retryable or fatal
/// Returns bool indicating whether this error is retryable or fatal, in the cases
/// where the peer responds with no headers, or times out.
pub fn is_retryable(&self) -> bool {
matches!(self, DownloadError::NoHeaderResponse { .. })
matches!(self, DownloadError::NoHeaderResponse { .. } | DownloadError::Timeout { .. })
}
}

/// The header downloading strategy
#[async_trait]
pub trait Downloader: Sync + Send + Debug {
pub trait Downloader: Sync + Send {
/// The Consensus used to verify block validity when
/// downloading
type Consensus: Consensus;
Expand Down

0 comments on commit b522f7d

Please sign in to comment.