jam_std_common/
finality.rs1use codec::{Decode, Encode, MaxEncodedLen};
2use core::fmt;
3use jam_types::{HeaderHash, Slot, StateRootHash};
4
5#[derive(
8 Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Encode, Decode, MaxEncodedLen,
9)]
10pub struct GrandpaTarget {
11 pub hash: HeaderHash,
13 pub state_root: StateRootHash,
15}
16
17impl GrandpaTarget {
18 pub fn new(hash: HeaderHash, state_root: StateRootHash) -> Self {
19 GrandpaTarget { hash, state_root }
20 }
21}
22
23impl fmt::Display for GrandpaTarget {
24 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
25 write!(f, "{} (state root {})", self.hash, self.state_root)
26 }
27}
28
29pub type GrandpaSetId = u32;
35
36pub type GrandpaRoundNumber = u64;
38
39#[derive(Debug, Clone, PartialEq, Eq, Encode, Decode, MaxEncodedLen)]
40pub enum GrandpaMessage {
41 #[codec(index = 0)]
42 Prevote(GrandpaTarget, Slot),
43 #[codec(index = 1)]
44 Precommit(GrandpaTarget, Slot),
45 #[codec(index = 2)]
46 PrimaryPropose(GrandpaTarget, Slot),
47}