referrerpolicy=no-referrer-when-downgrade

finality_relay/
base.rs

1// Copyright 2019-2023 Parity Technologies (UK) Ltd.
2// This file is part of Parity Bridges Common.
3
4// Parity Bridges Common 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// Parity Bridges Common 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 Parity Bridges Common.  If not, see <http://www.gnu.org/licenses/>.
16
17use async_trait::async_trait;
18use bp_header_chain::FinalityProof;
19use futures::Stream;
20use relay_utils::relay_loop::Client as RelayClient;
21use std::fmt::Debug;
22
23/// Base finality pipeline.
24pub trait FinalityPipeline: 'static + Clone + Debug + Send + Sync {
25	/// Name of the finality proofs source.
26	const SOURCE_NAME: &'static str;
27	/// Name of the finality proofs target.
28	const TARGET_NAME: &'static str;
29
30	/// Synced headers are identified by this hash.
31	type Hash: Eq + Clone + Copy + Send + Sync + Debug;
32	/// Synced headers are identified by this number.
33	type Number: relay_utils::BlockNumberBase;
34	/// Finality proof type.
35	type FinalityProof: FinalityProof<Self::Hash, Self::Number>;
36}
37
38/// Source client used in finality related loops.
39#[async_trait]
40pub trait SourceClientBase<P: FinalityPipeline>: RelayClient {
41	/// Stream of new finality proofs. The stream is allowed to miss proofs for some
42	/// headers, even if those headers are mandatory.
43	type FinalityProofsStream: Stream<Item = P::FinalityProof> + Send + Unpin;
44
45	/// Subscribe to new finality proofs.
46	async fn finality_proofs(&self) -> Result<Self::FinalityProofsStream, Self::Error>;
47}