Struct fbas_analyzer::Fbas

source ·
pub struct Fbas { /* private fields */ }
Expand description

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§

source§

impl Fbas

source

pub fn assume_crash_faulty(&mut self, nodes: &NodeIdSet)

Assume in the following that nodes can exhibit crash failures with the “goal” of blocking individual nodes or the whole FBAS. For keeping node IDs unchanged, this method doesn’t delete the node entirely but only makes it unsatisfiable.

source

pub fn assume_split_faulty(&mut self, nodes: &NodeIdSet)

Assume in the following that nodes can exhibit Byzantine failures with the “goal” of provoking splits. This corresponds to the delete operation from Mazières’s original FBAS/SCP paper. For keeping node IDs unchanged, this method doesn’t delete the node entirely but only makes it unsatisfiable and redacts it from all quorum sets.

source§

impl Fbas

source

pub fn satisfiable_nodes(&self) -> NodeIdSet

source

pub fn unsatisfiable_nodes(&self) -> NodeIdSet

source

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

source

pub fn rank_nodes(&self) -> Vec<RankScore>

Rank all nodes in the FBAS using an algorithm vaguely resembling PageRank.

source

pub fn core_nodes(&self) -> NodeIdSet

Returns all nodes part of a quorum-containing strongly connected component.

source

pub fn one_node_quorums(&self) -> Vec<NodeId>

Returns all nodes v for which {v} is a quorum slice (and hence a quorum). These are often nodes that are somehow broken.

source

pub fn to_core(&self) -> Self

Removes all nodes that are not part of a quorum-containing strongly connected component (the FBAS “core”). Changes node IDs and causes splitting sets analyses to return only such splitting sets that can cause core nodes to diverge from each other!

source

pub fn to_standard_form(&self) -> Self

Removes all unsatisfiable nodes and reorders node IDs so that nodes are sorted by public key.

source

pub fn without_nodes_pretty(&self, nodes: &[String]) -> Self

Remove nodes (referred to by their public keys) from the FBAS and all quorum sets, basically assuming they have irrevocably crashed. Changes the node IDs of remaining nodes! For a similar method hat keeps node IDs unchanged see Fbas::assume_crash_faulty.

source

pub fn without_nodes(&self, nodes: &[NodeId]) -> Self

Remove nodes (referred to by their node IDs) from the FBAS and all quorum sets, basically assuming they have irrevocably crashed. Changes the node IDs of remaining nodes! For a similar method hat keeps node IDs unchanged see Fbas::assume_crash_faulty.

source§

impl Fbas

source

pub fn new() -> Self

FBAS of 0 nodes.

source

pub fn new_generic_unconfigured(n: usize) -> Self

FBAS of n nodes with empty quorum sets

source

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

source

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

Add a node with generic public_key

source

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

source

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

source

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

source

pub fn number_of_nodes(&self) -> usize

source

pub fn all_nodes(&self) -> NodeIdSet

source

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

source§

impl Fbas

source

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

source§

impl Fbas

source

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

source

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

source

pub fn from_json_stdin() -> Self

source

pub fn to_json_string(&self) -> String

source

pub fn to_json_string_pretty(&self) -> String

Trait Implementations§

source§

impl Clone for Fbas

source§

fn clone(&self) -> Fbas

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Fbas

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Fbas

source§

fn default() -> Fbas

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Fbas

source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Fbas

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Hash for Fbas

source§

fn hash<H: Hasher>(&self, state: &mut H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Fbas

source§

fn cmp(&self, other: &Self) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Fbas

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Fbas

source§

fn partial_cmp(&self, other: &Self) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Fbas

source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Eq for Fbas

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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

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

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

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