Skip to content

Commit

Permalink
Move block verification impl
Browse files Browse the repository at this point in the history
  • Loading branch information
nazar-pc committed Sep 30, 2024
1 parent d09e9ff commit 9d533ab
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions crates/sc-consensus-subspace/src/verifier.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,22 +447,6 @@ where

Ok(())
}
}

#[async_trait::async_trait]
impl<PosTable, Block, Client, SelectChain> Verifier<Block>
for SubspaceVerifier<PosTable, Block, Client, SelectChain>
where
PosTable: Table,
Block: BlockT,
BlockNumber: From<NumberFor<Block>>,
Client: HeaderBackend<Block> + ProvideRuntimeApi<Block> + Send + Sync + AuxStore,
Client::Api: BlockBuilderApi<Block> + SubspaceApi<Block, PublicKey>,
SelectChain: sp_consensus::SelectChain<Block>,
{
fn verification_concurrency(&self) -> NonZeroUsize {
available_parallelism().unwrap_or(NonZeroUsize::new(1).expect("Not zero; qed"))
}

async fn verify(
&self,
Expand Down Expand Up @@ -619,3 +603,26 @@ where
Ok(block)
}
}

#[async_trait::async_trait]
impl<PosTable, Block, Client, SelectChain> Verifier<Block>
for SubspaceVerifier<PosTable, Block, Client, SelectChain>
where
PosTable: Table,
Block: BlockT,
BlockNumber: From<NumberFor<Block>>,
Client: HeaderBackend<Block> + ProvideRuntimeApi<Block> + Send + Sync + AuxStore,
Client::Api: BlockBuilderApi<Block> + SubspaceApi<Block, PublicKey>,
SelectChain: sp_consensus::SelectChain<Block>,
{
fn verification_concurrency(&self) -> NonZeroUsize {
available_parallelism().unwrap_or(NonZeroUsize::new(1).expect("Not zero; qed"))
}

async fn verify(
&self,
block: BlockImportParams<Block>,
) -> Result<BlockImportParams<Block>, String> {
self.verify(block).await
}
}

0 comments on commit 9d533ab

Please sign in to comment.