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;
|
|
|
|
|
|
|
|
|
|
use sp_inherents::CreateInherentDataProviders;
|
|
|
|
|
use sp_runtime::traits::Block;
|
2022-10-24 04:43:25 -04:00
|
|
|
use sp_api::TransactionFor;
|
2022-10-22 02:15:22 -04:00
|
|
|
|
2022-10-24 04:43:25 -04:00
|
|
|
use sp_consensus::{Error, CacheKeyId, Environment};
|
|
|
|
|
use sc_consensus::{BlockImportParams, BlockImport, Verifier};
|
2022-10-22 02:15:22 -04:00
|
|
|
|
2022-10-24 04:43:25 -04:00
|
|
|
use sc_client_api::Backend;
|
2022-10-22 02:15:22 -04:00
|
|
|
|
2022-10-27 08:44:53 -04:00
|
|
|
use sp_tendermint::TendermintApi;
|
2022-10-27 06:29:56 -04:00
|
|
|
|
2022-10-24 04:43:25 -04:00
|
|
|
use crate::{
|
|
|
|
|
tendermint::{TendermintClient, TendermintImport},
|
|
|
|
|
Announce,
|
|
|
|
|
};
|
2022-10-22 02:15:22 -04:00
|
|
|
|
|
|
|
|
#[async_trait]
|
|
|
|
|
impl<
|
|
|
|
|
B: Block,
|
|
|
|
|
Be: Backend<B> + 'static,
|
2022-10-24 04:43:25 -04:00
|
|
|
C: TendermintClient<B, Be>,
|
2022-10-22 02:15:22 -04:00
|
|
|
CIDP: CreateInherentDataProviders<B, ()> + 'static,
|
|
|
|
|
E: Send + Sync + Environment<B> + 'static,
|
2022-10-22 07:36:13 -04:00
|
|
|
A: Announce<B>,
|
2022-10-24 04:43:25 -04:00
|
|
|
> Verifier<B> for TendermintImport<B, Be, C, CIDP, E, A>
|
2022-10-22 02:15:22 -04:00
|
|
|
where
|
|
|
|
|
TransactionFor<C, B>: Send + Sync + 'static,
|
2022-10-24 04:43:25 -04:00
|
|
|
Arc<C>: BlockImport<B, Transaction = TransactionFor<C, B>>,
|
|
|
|
|
<Arc<C> as BlockImport<B>>::Error: Into<Error>,
|
2022-10-27 08:44:53 -04:00
|
|
|
C::Api: TendermintApi<B>,
|
2022-10-22 02:15:22 -04:00
|
|
|
{
|
|
|
|
|
async fn verify(
|
|
|
|
|
&mut self,
|
|
|
|
|
mut block: BlockImportParams<B, ()>,
|
|
|
|
|
) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
|
|
|
|
|
self.check(&mut block).await.map_err(|e| format!("{}", e))?;
|
|
|
|
|
Ok((block, None))
|
|
|
|
|
}
|
|
|
|
|
}
|