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
No known key found for this signature in database
GPG key ID: F9F1386DB1E119B6
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 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<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;
pub use tendermint::TendermintAuthority;
mod block_import;
mod verifier;
mod import_queue;
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))
}
}