Skip to main content

pathfinder_common/
consensus_info.rs

1use std::collections::BTreeMap;
2
3use serde::Deserialize;
4
5use crate::{BlockNumber, ContractAddress, ProposalCommitment};
6
7#[derive(Default, Debug, Clone)]
8pub struct ConsensusInfo {
9    /// Highest decided height and value.
10    pub highest_decision: Option<Decision>,
11    /// Application-specific peer scores, keyed by base58-encoded peer ID.
12    ///
13    /// A peer score will only appear in the map if it has changed from the
14    /// initial value.
15    pub application_peer_scores: BTreeMap<String, f64>,
16    /// Track the state of cached proposals and finalized blocks.
17    pub cached: BTreeMap<u64, CachedAtHeight>,
18}
19
20#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
21pub struct Decision {
22    pub height: BlockNumber,
23    pub round: u32,
24    pub value: ProposalCommitment,
25}
26
27#[derive(Default, Debug, Clone, PartialEq, Eq, Deserialize)]
28pub struct CachedAtHeight {
29    pub proposals: Vec<ProposalParts>,
30    pub blocks: Vec<FinalizedBlock>,
31}
32
33#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
34pub struct ProposalParts {
35    pub round: u32,
36    pub proposer: ContractAddress,
37    pub parts_len: usize,
38}
39
40#[derive(Default, Debug, Copy, Clone, PartialEq, Eq, Deserialize)]
41pub struct FinalizedBlock {
42    pub round: u32,
43    pub is_decided: bool,
44}