sc-finality-grandpa: use the #[from] attriute to remove boilerplate code (#11003)

Signed-off-by: koushiro <koushiro.cqx@gmail.com>
This commit is contained in:
Qinxuan Chen
2022-03-10 17:02:58 +08:00
committed by GitHub
parent f8e0e41e15
commit 18aef02e87
+2 -14
View File
@@ -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}")]
@@ -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}")]
@@ -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