1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
use parity_scale_codec::{Decode, Encode};
use sp_runtime::Justification;

use crate::{
    abft::SignatureSet,
    phron_primitives::{AuthoritySignature, PHRON_ENGINE_ID},
    crypto::Signature,
};

mod compatibility;

pub use compatibility::{backwards_compatible_decode, versioned_encode, Error as DecodeError};

const LOG_TARGET: &str = "phron-justification";

/// A proof of block finality, currently in the form of a sufficiently long list of signatures or a
/// sudo signature of a block for emergency finalization.
#[derive(Clone, Encode, Decode, Debug, PartialEq, Eq)]
pub enum PhronJustification {
    CommitteeMultisignature(SignatureSet<Signature>),
    EmergencySignature(AuthoritySignature),
}

impl From<PhronJustification> for Justification {
    fn from(val: PhronJustification) -> Self {
        (PHRON_ENGINE_ID, versioned_encode(val))
    }
}