sc_consensus_beefy_rpc/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 codec::Encode;
20use serde::{Deserialize, Serialize};
21
22use sp_consensus_beefy::AuthorityIdBound;
23use sp_runtime::traits::Block as BlockT;
24
25/// An encoded finality proof proving that the given header has been finalized.
26/// The given bytes should be the SCALE-encoded representation of a
27/// `sp_consensus_beefy::VersionedFinalityProof`.
28#[derive(Clone, Serialize, Deserialize)]
29pub struct EncodedVersionedFinalityProof(sp_core::Bytes);
30
31impl EncodedVersionedFinalityProof {
32 pub fn new<Block, AuthorityId>(
33 finality_proof: sc_consensus_beefy::justification::BeefyVersionedFinalityProof<
34 Block,
35 AuthorityId,
36 >,
37 ) -> Self
38 where
39 Block: BlockT,
40 AuthorityId: AuthorityIdBound,
41 {
42 EncodedVersionedFinalityProof(finality_proof.encode().into())
43 }
44}