Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

Commit

Permalink
sc-finality-grandpa: use the #[from] attriute to remove boilerplate c…
Browse files Browse the repository at this point in the history
…ode (#11003)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
  • Loading branch information
koushiro authored Mar 10, 2022
1 parent b36030a commit 1321c6f
Showing 1 changed file with 2 additions and 14 deletions.
16 changes: 2 additions & 14 deletions client/finality-grandpa/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ impl Config {
pub enum Error {
/// An error within grandpa.
#[error("grandpa error: {0}")]
Grandpa(GrandpaError),
Grandpa(#[from] GrandpaError),

/// A network error.
#[error("network error: {0}")]
Expand All @@ -291,7 +291,7 @@ pub enum Error {

/// Could not complete a round on disk.
#[error("could not complete a round on disk: {0}")]
Client(ClientError),
Client(#[from] ClientError),

/// Could not sign outgoing message
#[error("could not sign outgoing message: {0}")]
Expand All @@ -310,18 +310,6 @@ pub enum Error {
RuntimeApi(sp_api::ApiError),
}

impl From<GrandpaError> for Error {
fn from(e: GrandpaError) -> Self {
Error::Grandpa(e)
}
}

impl From<ClientError> for Error {
fn from(e: ClientError) -> Self {
Error::Client(e)
}
}

/// Something which can determine if a block is known.
pub(crate) trait BlockStatus<Block: BlockT> {
/// Return `Ok(Some(number))` or `Ok(None)` depending on whether the block
Expand Down

0 comments on commit 1321c6f

Please sign in to comment.