mirror of
https://github.com/serai-dex/serai.git
synced 2025-12-11 13:39:25 +00:00
Clean generics in Tendermint with a monolith with associated types
This commit is contained in:
@@ -2,41 +2,21 @@ use std::sync::Arc;
|
||||
|
||||
use async_trait::async_trait;
|
||||
|
||||
use sp_inherents::CreateInherentDataProviders;
|
||||
use sp_runtime::traits::Block;
|
||||
use sp_api::TransactionFor;
|
||||
|
||||
use sp_consensus::{Error, CacheKeyId, Environment};
|
||||
use sp_consensus::{Error, CacheKeyId};
|
||||
use sc_consensus::{BlockImportParams, BlockImport, Verifier};
|
||||
|
||||
use sc_client_api::Backend;
|
||||
|
||||
use sp_tendermint::TendermintApi;
|
||||
|
||||
use crate::{
|
||||
tendermint::{TendermintClient, TendermintImport},
|
||||
Announce,
|
||||
};
|
||||
use crate::{types::TendermintAuthor, tendermint::TendermintImport};
|
||||
|
||||
#[async_trait]
|
||||
impl<
|
||||
B: Block,
|
||||
Be: Backend<B> + 'static,
|
||||
C: TendermintClient<B, Be>,
|
||||
CIDP: CreateInherentDataProviders<B, ()> + 'static,
|
||||
E: Send + Sync + Environment<B> + 'static,
|
||||
A: Announce<B>,
|
||||
> Verifier<B> for TendermintImport<B, Be, C, CIDP, E, A>
|
||||
impl<T: TendermintAuthor> Verifier<T::Block> for TendermintImport<T>
|
||||
where
|
||||
TransactionFor<C, B>: Send + Sync + 'static,
|
||||
Arc<C>: BlockImport<B, Transaction = TransactionFor<C, B>>,
|
||||
<Arc<C> as BlockImport<B>>::Error: Into<Error>,
|
||||
C::Api: TendermintApi<B>,
|
||||
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<B, ()>,
|
||||
) -> Result<(BlockImportParams<B, ()>, Option<Vec<(CacheKeyId, Vec<u8>)>>), String> {
|
||||
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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user