2022-10-24 04:43:25 -04:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2022-10-22 02:15:22 -04:00
|
|
|
use async_trait::async_trait;
|
|
|
|
|
|
2022-10-30 03:26:31 -04:00
|
|
|
use sp_consensus::{Error, CacheKeyId};
|
2022-10-24 04:43:25 -04:00
|
|
|
use sc_consensus::{BlockImportParams, BlockImport, Verifier};
|
2022-10-22 02:15:22 -04:00
|
|
|
|
2022-10-30 03:26:31 -04:00
|
|
|
use crate::{types::TendermintAuthor, tendermint::TendermintImport};
|
2022-10-22 02:15:22 -04:00
|
|
|
|
|
|
|
|
#[async_trait]
|
2022-10-30 03:26:31 -04:00
|
|
|
impl<T: TendermintAuthor> Verifier<T::Block> for TendermintImport<T>
|
2022-10-22 02:15:22 -04:00
|
|
|
where
|
2022-10-30 03:26:31 -04:00
|
|
|
Arc<T::Client>: BlockImport<T::Block, Transaction = T::BackendTransaction>,
|
|
|
|
|
<Arc<T::Client> as BlockImport<T::Block>>::Error: Into<Error>,
|
2022-10-22 02:15:22 -04:00
|
|
|
{
|
|
|
|
|
async fn verify(
|
|
|
|
|
&mut self,
|
2022-10-30 03:26:31 -04:00
|
|
|
mut block: BlockImportParams<T::Block, ()>,
|
|
|
|
|
) -> Result<(BlockImportParams<T::Block, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
|
2022-10-22 02:15:22 -04:00
|
|
|
self.check(&mut block).await.map_err(|e| format!("{}", e))?;
|
|
|
|
|
Ok((block, None))
|
|
|
|
|
}
|
|
|
|
|
}
|