sc_consensus_beefy/communication/notification.rs
1// This file is part of Substrate.
2
3// Copyright (C) Parity Technologies (UK) Ltd.
4// SPDX-License-Identifier: GPL-3.0-or-later WITH Classpath-exception-2.0
5
6// This program is free software: you can redistribute it and/or modify
7// it under the terms of the GNU General Public License as published by
8// the Free Software Foundation, either version 3 of the License, or
9// (at your option) any later version.
10
11// This program is distributed in the hope that it will be useful,
12// but WITHOUT ANY WARRANTY; without even the implied warranty of
13// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14// GNU General Public License for more details.
15
16// You should have received a copy of the GNU General Public License
17// along with this program. If not, see <https://www.gnu.org/licenses/>.
18
19use sc_utils::notification::{NotificationSender, NotificationStream, TracingKeyStr};
20use sp_runtime::traits::Block as BlockT;
21
22use crate::justification::BeefyVersionedFinalityProof;
23
24/// The sending half of the notifications channel(s) used to send
25/// notifications about best BEEFY block from the gadget side.
26pub type BeefyBestBlockSender<Block> = NotificationSender<<Block as BlockT>::Hash>;
27
28/// The receiving half of a notifications channel used to receive
29/// notifications about best BEEFY blocks determined on the gadget side.
30pub type BeefyBestBlockStream<Block> =
31 NotificationStream<<Block as BlockT>::Hash, BeefyBestBlockTracingKey>;
32
33/// The sending half of the notifications channel(s) used to send notifications
34/// about versioned finality proof generated at the end of a BEEFY round.
35pub type BeefyVersionedFinalityProofSender<Block, AuthorityId> =
36 NotificationSender<BeefyVersionedFinalityProof<Block, AuthorityId>>;
37
38/// The receiving half of a notifications channel used to receive notifications
39/// about versioned finality proof generated at the end of a BEEFY round.
40pub type BeefyVersionedFinalityProofStream<Block, AuthorityId> = NotificationStream<
41 BeefyVersionedFinalityProof<Block, AuthorityId>,
42 BeefyVersionedFinalityProofTracingKey,
43>;
44
45/// Provides tracing key for BEEFY best block stream.
46#[derive(Clone)]
47pub struct BeefyBestBlockTracingKey;
48impl TracingKeyStr for BeefyBestBlockTracingKey {
49 const TRACING_KEY: &'static str = "mpsc_beefy_best_block_notification_stream";
50}
51
52/// Provides tracing key for BEEFY versioned finality proof stream.
53#[derive(Clone)]
54pub struct BeefyVersionedFinalityProofTracingKey;
55impl TracingKeyStr for BeefyVersionedFinalityProofTracingKey {
56 const TRACING_KEY: &'static str = "mpsc_beefy_versioned_finality_proof_notification_stream";
57}