pub(crate) fn find_symmetric_nodes_in_node_set(
    nodes: &NodeIdSet,
    fbas: &Fbas,
) -> SymmetricNodesMap {
    let mut referencing_qsets = vec![BTreeSet::new(); fbas.number_of_nodes()];

    for vc_qset in nodes
        .iter()
        .map(|node_id| fbas.nodes[node_id].quorum_set.to_standard_form(node_id))
        .unique()
        .flat_map(|qset| qset.validator_containing_quorum_sets())
        .unique()
    {
        for node_id in vc_qset.contained_nodes().iter() {
            referencing_qsets[node_id].insert(vc_qset.clone());
        }
    }
    let symmetry_qsets = referencing_qsets
        .iter()
        .filter(|qsets| qsets.len() == 1)
        .flatten()
        .filter(|qset| {
            qset.contained_nodes()
                .iter()
                .all(|node_id| referencing_qsets[node_id].len() == 1)
        });
    let mut result = HashMap::new();
    for qset in symmetry_qsets {
        let mut symmetric_nodes = qset.contained_nodes();
        // ensure that we don't count nodes that don't exist
        symmetric_nodes.intersect_with(nodes);
        for node_id in symmetric_nodes.iter() {
            result.insert(node_id, symmetric_nodes.clone());
        }
    }
    SymmetricNodesMap(result)
}
/// Find groups of nodes that can be freely exchanged with one another. We currently don't find all
/// such groups of nodes but only such nodes that are always included in the same
/// validator-containing quorum set. For illustration, in a Stellar-type FBAS the nodes belonging
/// to the same organization are typically symmetric to each other.
Find groups of nodes that can be freely exchanged with one another. We currently don't find all
such groups of nodes but only such nodes that are always included in the same
validator-containing quorum set. For illustration, in a Stellar-type FBAS the nodes belonging
to the same organization are typically symmetric to each other.
Find groups of nodes that can be freely exchanged with one another . We currently don ' t find all such groups of nodes but only such nodes that are always included in the same validator - containing quorum set . For illustration in a Stellar - type FBAS the nodes belonging to the same organization are typically symmetric to each other .
pub(crate) fn find_symmetric_nodes_in_node_set(
    nodes: &NodeIdSet,
    fbas: &Fbas,
) -> SymmetricNodesMap {
    let mut referencing_qsets = vec![BTreeSet::new(); fbas.number_of_nodes()];
    for vc_qset in nodes
        .iter()
        .map(|node_id| fbas.nodes[node_id].quorum_set.to_standard_form(node_id))
        .unique()
        .flat_map(|qset| qset.validator_containing_quorum_sets())
        .unique()
    {
        for node_id in vc_qset.contained_nodes().iter() {
            referencing_qsets[node_id].insert(vc_qset.clone());
        }
    }
    let symmetry_qsets = referencing_qsets
        .iter()
        .filter(|qsets| qsets.len() == 1)
        .flatten()
        .filter(|qset| {
            qset.contained_nodes()
                .iter()
                .all(|node_id| referencing_qsets[node_id].len() == 1)
        });
    let mut result = HashMap::new();
    for qset in symmetry_qsets {
        let mut symmetric_nodes = qset.contained_nodes();
        // ensure that we don't count nodes that don't exist
        symmetric_nodes.intersect_with(nodes);
        for node_id in symmetric_nodes.iter() {
            result.insert(node_id, symmetric_nodes.clone());
        }
    }
    SymmetricNodesMap(result)
}
pub ( crate ) fn find_symmetric_nodes_in_node_set ( nodes : & NodeIdSet , fbas : & Fbas , ) -> SymmetricNodesMap { let mut referencing_qsets = vec ! [ BTreeSet new ( ) fbas number_of_nodes ( ) ] ; for vc_qset in nodes . iter ( ) . map ( | node_id | fbas . nodes [ node_id ] . quorum_set . to_standard_form ( node_id ) ) . unique ( ) . flat_map ( | qset | qset . validator_containing_quorum_sets ( ) ) . unique ( ) { for node_id in vc_qset . contained_nodes ( ) . iter ( ) { referencing_qsets [ node_id ] . insert ( vc_qset . clone ( ) ) ; } } let symmetry_qsets = referencing_qsets . iter ( ) . filter ( | qsets | qsets . len ( ) == 1 ) . flatten ( ) . filter ( | qset | { qset . contained_nodes ( ) . iter ( ) . all ( | node_id | referencing_qsets [ node_id ] . len ( ) == 1 ) } ) ; let mut result = HashMap :: new ( ) ; for qset in symmetry_qsets { let mut symmetric_nodes = qset . contained_nodes ( ) ; // ensure that we don't count nodes that don't exist symmetric_nodes . intersect_with ( nodes ) ; for node_id in symmetric_nodes . iter ( ) { result . insert ( node_id , symmetric_nodes . clone ( ) ) ; } } SymmetricNodesMap ( result ) }
Find groups of nodes that can be freely exchanged with one another.
Find groups of nodes that can be freely exchanged with one another .
nodes
&NodeIdSet
fbas
&Fbas
nodes
&NodeIdSet
fbas
&Fbas