From 066bc40a884cf4e2f16a9bee969caa83c887648a Mon Sep 17 00:00:00 2001 From: Luke Parker Date: Sun, 30 Oct 2022 06:30:44 -0400 Subject: [PATCH] Merge Verifier into block_import.rs These two files were largely the same, just hooking into sync structs with almost identical imports. As this project shapes up, removing dead weight is appreciated. --- .../tendermint/client/src/block_import.rs | 17 +++++++++++++- substrate/tendermint/client/src/lib.rs | 1 - substrate/tendermint/client/src/verifier.rs | 23 ------------------- 3 files changed, 16 insertions(+), 25 deletions(-) delete mode 100644 substrate/tendermint/client/src/verifier.rs diff --git a/substrate/tendermint/client/src/block_import.rs b/substrate/tendermint/client/src/block_import.rs index 21d5782c..379cb1e5 100644 --- a/substrate/tendermint/client/src/block_import.rs +++ b/substrate/tendermint/client/src/block_import.rs @@ -3,7 +3,7 @@ use std::{sync::Arc, collections::HashMap}; use async_trait::async_trait; use sp_consensus::{Error, CacheKeyId}; -use sc_consensus::{BlockCheckParams, BlockImportParams, ImportResult, BlockImport}; +use sc_consensus::{BlockCheckParams, BlockImportParams, ImportResult, BlockImport, Verifier}; use crate::{types::TendermintValidator, tendermint::TendermintImport}; @@ -45,3 +45,18 @@ where // machine with the new height } } + +#[async_trait] +impl Verifier for TendermintImport +where + Arc: BlockImport, + as BlockImport>::Error: Into, +{ + async fn verify( + &mut self, + mut block: BlockImportParams, + ) -> Result<(BlockImportParams, Option)>>), String> { + self.check(&mut block).await.map_err(|e| format!("{}", e))?; + Ok((block, None)) + } +} diff --git a/substrate/tendermint/client/src/lib.rs b/substrate/tendermint/client/src/lib.rs index 7f2cdd70..36e3e349 100644 --- a/substrate/tendermint/client/src/lib.rs +++ b/substrate/tendermint/client/src/lib.rs @@ -22,7 +22,6 @@ mod validators; mod tendermint; pub use tendermint::TendermintAuthority; mod block_import; -mod verifier; mod import_queue; use import_queue::TendermintImportQueue; diff --git a/substrate/tendermint/client/src/verifier.rs b/substrate/tendermint/client/src/verifier.rs deleted file mode 100644 index 9b7c2a92..00000000 --- a/substrate/tendermint/client/src/verifier.rs +++ /dev/null @@ -1,23 +0,0 @@ -use std::sync::Arc; - -use async_trait::async_trait; - -use sp_consensus::{Error, CacheKeyId}; -use sc_consensus::{BlockImportParams, BlockImport, Verifier}; - -use crate::{types::TendermintValidator, tendermint::TendermintImport}; - -#[async_trait] -impl Verifier for TendermintImport -where - Arc: BlockImport, - as BlockImport>::Error: Into, -{ - async fn verify( - &mut self, - mut block: BlockImportParams, - ) -> Result<(BlockImportParams, Option)>>), String> { - self.check(&mut block).await.map_err(|e| format!("{}", e))?; - Ok((block, None)) - } -}