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.
This commit is contained in:
Luke Parker
2022-10-30 06:30:44 -04:00
parent f37adf4feb
commit 066bc40a88
3 changed files with 16 additions and 25 deletions

View File

@@ -3,7 +3,7 @@ use std::{sync::Arc, collections::HashMap};
use async_trait::async_trait; use async_trait::async_trait;
use sp_consensus::{Error, CacheKeyId}; 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}; use crate::{types::TendermintValidator, tendermint::TendermintImport};
@@ -45,3 +45,18 @@ where
// machine with the new height // machine with the new height
} }
} }
#[async_trait]
impl<T: TendermintValidator> Verifier<T::Block> for TendermintImport<T>
where
Arc<T::Client>: BlockImport<T::Block, Transaction = T::BackendTransaction>,
<Arc<T::Client> as BlockImport<T::Block>>::Error: Into<Error>,
{
async fn verify(
&mut self,
mut block: BlockImportParams<T::Block, ()>,
) -> Result<(BlockImportParams<T::Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
self.check(&mut block).await.map_err(|e| format!("{}", e))?;
Ok((block, None))
}
}

View File

@@ -22,7 +22,6 @@ mod validators;
mod tendermint; mod tendermint;
pub use tendermint::TendermintAuthority; pub use tendermint::TendermintAuthority;
mod block_import; mod block_import;
mod verifier;
mod import_queue; mod import_queue;
use import_queue::TendermintImportQueue; use import_queue::TendermintImportQueue;

View File

@@ -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<T: TendermintValidator> Verifier<T::Block> for TendermintImport<T>
where
Arc<T::Client>: BlockImport<T::Block, Transaction = T::BackendTransaction>,
<Arc<T::Client> as BlockImport<T::Block>>::Error: Into<Error>,
{
async fn verify(
&mut self,
mut block: BlockImportParams<T::Block, ()>,
) -> Result<(BlockImportParams<T::Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
self.check(&mut block).await.map_err(|e| format!("{}", e))?;
Ok((block, None))
}
}