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
impl Fbas
sourcepub fn assume_crash_faulty(&mut self, nodes: &NodeIdSet)
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.
sourcepub fn assume_split_faulty(&mut self, nodes: &NodeIdSet)
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
impl Fbas
pub fn satisfiable_nodes(&self) -> NodeIdSet
pub fn unsatisfiable_nodes(&self) -> NodeIdSet
pub fn strongly_connected_components(&self) -> Vec<NodeIdSet>
sourcepub fn rank_nodes(&self) -> Vec<RankScore>
pub fn rank_nodes(&self) -> Vec<RankScore>
Rank all nodes in the FBAS using an algorithm vaguely resembling PageRank.
sourcepub fn core_nodes(&self) -> NodeIdSet
pub fn core_nodes(&self) -> NodeIdSet
Returns all nodes part of a quorum-containing strongly connected component.
sourcepub fn one_node_quorums(&self) -> Vec<NodeId>
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.
sourcepub fn to_core(&self) -> Self
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!
sourcepub fn to_standard_form(&self) -> Self
pub fn to_standard_form(&self) -> Self
Removes all unsatisfiable nodes and reorders node IDs so that nodes are sorted by public key.
sourcepub fn without_nodes_pretty(&self, nodes: &[String]) -> Self
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
.
sourcepub fn without_nodes(&self, nodes: &[NodeId]) -> Self
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
impl Fbas
sourcepub fn new_generic_unconfigured(n: usize) -> Self
pub fn new_generic_unconfigured(n: usize) -> Self
FBAS of n
nodes with empty quorum sets
pub fn add_node(&mut self, node: Node) -> NodeId
sourcepub fn add_generic_node(&mut self, quorum_set: QuorumSet) -> NodeId
pub fn add_generic_node(&mut self, quorum_set: QuorumSet) -> NodeId
Add a node with generic public_key
pub fn get_node_id(&self, public_key: &str) -> Option<NodeId>
pub fn get_quorum_set(&self, node_id: NodeId) -> Option<QuorumSet>
pub fn swap_quorum_set( &mut self, node_id: NodeId, quorum_set: QuorumSet ) -> QuorumSet
pub fn number_of_nodes(&self) -> usize
pub fn all_nodes(&self) -> NodeIdSet
pub fn is_quorum(&self, node_set: &NodeIdSet) -> bool
source§impl Fbas
impl Fbas
pub fn from_json_str(json: &str) -> Self
pub fn from_json_file(path: &Path) -> Self
pub fn from_json_stdin() -> Self
pub fn to_json_string(&self) -> String
pub fn to_json_string_pretty(&self) -> String
Trait Implementations§
source§impl<'de> Deserialize<'de> for Fbas
impl<'de> Deserialize<'de> for Fbas
source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
source§impl Ord for Fbas
impl Ord for Fbas
source§impl PartialEq for Fbas
impl PartialEq for Fbas
source§impl PartialOrd for Fbas
impl PartialOrd for Fbas
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moreimpl 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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.