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
43
44
45
46
47
48
49
50
51
//! A library and tool for analyzing the quorum structure of federated byzantine agreement systems
//! (FBASs) like [Stellar](https://www.stellar.org/). Related research paper
//! [here](https://arxiv.org/abs/2002.08101).
//!
//! We recommend using the [`Analysis`](struct.Analysis.html) struct for doing analyses.
//!
//! # Example analysis
//! ```
//! use fbas_analyzer::{Fbas, Analysis, bitset, bitsetvec};
//!
//! let fbas = Fbas::from_json_file(std::path::Path::new("test_data/correct_trivial.json"));
//! let mut analysis = Analysis::new(&fbas);
//!
//! assert!(analysis.has_quorum_intersection());
//!
//! // "Unwrapping" analysis results gives us their internal representation, with node IDs
//! // corresponding to node indices in the input JSON.
//! assert_eq!(bitsetvec![{0,1},{0,2},{1,2}], analysis.minimal_blocking_sets().unwrap());
//!
//! // You can directly transform results into vectors of public keys or organization names...
//! let mss_pretty = analysis.minimal_splitting_sets().into_pretty_vec_vec(&fbas, None);
//! assert_eq!(vec!["GCGB2S2KGYARPVIA37HYZXVRM2YZUEXA6S33ZU5BUDC6THSB62LZSTYH"], mss_pretty[0]);
//!
//! // ...or serialize them using serde.
//! assert_eq!("[0,1,2]", serde_json::to_string(&analysis.top_tier()).unwrap());
//!
//! // You can also post-process results. Let's say we believe that node 0 has crashed...
//! let remaining_mbs = analysis.minimal_blocking_sets().without_nodes(&[0]).minimal_sets();
//! assert_eq!(bitsetvec![{1},{2}], remaining_mbs.unwrap()); // Yikes!
//! ```
//!
//! # More examples...
//!
//! ...can be found in the `src/bin` and `examples` folders...

#![doc(html_root_url = "https://docs.rs/fbas_analyzer/0.7.4")]

mod analysis;
mod core_types;
mod io;

pub use analysis::*;
pub use core_types::{Fbas, Groupings, NodeId, NodeIdSet, QuorumSet};
pub use io::{to_grouping_names, to_public_keys, AnalysisResult, FilteredNodes, PrettyQuorumSet};

use core_types::*;

use log::{debug, info, warn};

#[cfg(feature = "qsc-simulation")]
pub mod simulation;