[][src]Struct fbas_analyzer::Fbas

pub struct Fbas { /* fields omitted */ }

Representation of an FBAS.

Example

use fbas_analyzer::{Fbas, QuorumSet};

let fbas = Fbas::from_json_str(
    r#"[
    {
        "publicKey": "n0",
        "quorumSet": { "threshold": 1, "validators": ["n1"] }
    },
    {
        "publicKey": "n1",
        "quorumSet": { "threshold": 2, "validators": ["n1", "n2"] }
    },
    {
        "publicKey": "n2",
        "quorumSet": { "threshold": 2, "validators": ["n1", "n2"] }
    }
]"#,
);
assert_eq!(3, fbas.number_of_nodes());
assert_eq!(Some(0), fbas.get_node_id("n0"));
assert_eq!(
    QuorumSet {
        validators: vec![1],
        inner_quorum_sets: vec![],
        threshold: 1
    },
    fbas.get_quorum_set(0).unwrap()
);

let quorum_set = QuorumSet {
    validators: vec![1, 2],
    inner_quorum_sets: vec![],
    threshold: 2,
};
let mut fbas = fbas;
fbas.swap_quorum_set(0, quorum_set.clone());
assert_eq!(Some(quorum_set), fbas.get_quorum_set(0));

Implementations

impl Fbas[src]

pub fn satisfiable_nodes(&self) -> NodeIdSet[src]

pub fn unsatisfiable_nodes(&self) -> NodeIdSet[src]

pub fn strongly_connected_components(&self) -> Vec<NodeIdSet>[src]

pub fn rank_nodes(&self) -> Vec<f64>[src]

pub fn relevant_nodes(&self) -> NodeIdSet[src]

Returns all nodes part of a quorum-containing strongly connected component (the only nodes relevant for analysis).

pub fn to_standard_form(&self) -> Self[src]

Reduces the FBAS to nodes relevant to analysis (nodes part of a quorum-containing strongly connected component) and reorders node IDs so that nodes are sorted by public key.

impl Fbas[src]

pub fn new() -> Self[src]

FBAS of 0 nodes.

pub fn new_generic_unconfigured(n: usize) -> Self[src]

FBAS of n nodes with empty quorum sets

pub fn add_node(&mut self, node: Node) -> NodeId[src]

pub fn add_generic_node(&mut self, quorum_set: QuorumSet) -> NodeId[src]

Add a node with generic public_key

pub fn get_node_id(&self, public_key: &str) -> Option<NodeId>[src]

pub fn get_quorum_set(&self, node_id: NodeId) -> Option<QuorumSet>[src]

pub fn swap_quorum_set(
    &mut self,
    node_id: NodeId,
    quorum_set: QuorumSet
) -> QuorumSet
[src]

pub fn number_of_nodes(&self) -> usize[src]

pub fn all_nodes(&self) -> NodeIdSet[src]

pub fn is_quorum(&self, node_set: &NodeIdSet) -> bool[src]

impl Fbas[src]

pub fn shrunken(&self, ids_to_keep: NodeIdSet) -> (Self, ShrinkManager)[src]

impl Fbas[src]

pub fn from_json_str(json: &str) -> Self[src]

pub fn from_json_file(path: &Path) -> Self[src]

pub fn from_json_stdin() -> Self[src]

pub fn to_json_string(&self) -> String[src]

pub fn to_json_string_pretty(&self) -> String[src]

Trait Implementations

impl Clone for Fbas[src]

impl Debug for Fbas[src]

impl Default for Fbas[src]

impl<'de> Deserialize<'de> for Fbas[src]

impl Display for Fbas[src]

impl Eq for Fbas[src]

impl Hash for Fbas[src]

impl Ord for Fbas[src]

impl PartialEq<Fbas> for Fbas[src]

impl PartialOrd<Fbas> for Fbas[src]

impl Serialize for Fbas[src]

Auto Trait Implementations

impl RefUnwindSafe for Fbas

impl Send for Fbas

impl Sync for Fbas

impl Unpin for Fbas

impl UnwindSafe for Fbas

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> DeserializeOwned for T where
    T: for<'de> Deserialize<'de>, 
[src]

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,