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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
use std::{fmt::Debug, hash::Hash, num::NonZeroUsize};

use parity_scale_codec::{Decode, Encode};

mod data_interpreter;
mod data_provider;
mod data_store;
mod proposal;
mod status_provider;

pub use data_interpreter::OrderedDataInterpreter;
pub use data_provider::{ChainTracker, DataProvider};
pub use data_store::{DataStore};
pub use proposal::UnvalidatedPhronProposal;

// Maximum number of blocks above the last finalized allowed in an PhronBFT proposal.
pub const MAX_DATA_BRANCH_LEN: usize = 7;

/// The data ordered by the Phron consensus.
#[derive(Clone, Debug, Encode, Decode, Hash, PartialEq, Eq)]
pub struct PhronData {
    pub head_proposal: UnvalidatedPhronProposal,
}

/// A trait allowing to check the data contained in an PhronBFT network message, for the purpose of
/// data availability checks.
pub trait PhronNetworkMessage: Clone + Debug {
    fn included_data(&self) -> Vec<PhronData>;
}

#[derive(Clone, Debug)]
pub struct ChainInfoCacheConfig {
    pub block_cache_capacity: NonZeroUsize,
}

impl Default for ChainInfoCacheConfig {
    fn default() -> ChainInfoCacheConfig {
        ChainInfoCacheConfig {
            block_cache_capacity: NonZeroUsize::new(2000).unwrap(),
        }
    }
}