domain_client_consensus_relay_chain/import_queue.rs
1// Copyright 2019-2021 Parity Technologies (UK) Ltd.
2// This file is part of Cumulus.
3
4// Cumulus is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Cumulus is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Cumulus. If not, see <http://www.gnu.org/licenses/>.
16
17use sc_consensus::import_queue::Verifier as VerifierT;
18use sc_consensus::BlockImportParams;
19use sp_runtime::traits::{Block as BlockT, Header as HeaderT};
20use std::marker::PhantomData;
21
22/// A verifier that just checks the inherents.
23pub struct Verifier<Block> {
24 _marker: PhantomData<Block>,
25}
26
27impl<Block> Default for Verifier<Block> {
28 /// Create a new instance.
29 #[inline]
30 fn default() -> Self {
31 Self {
32 _marker: PhantomData,
33 }
34 }
35}
36
37#[async_trait::async_trait]
38impl<Block> VerifierT<Block> for Verifier<Block>
39where
40 Block: BlockT,
41{
42 async fn verify(
43 &self,
44 mut block_params: BlockImportParams<Block>,
45 ) -> Result<BlockImportParams<Block>, String> {
46 block_params.post_hash = Some(block_params.header.hash());
47
48 Ok(block_params)
49 }
50}