fn bf_search_paths(
        &self,
        node: &TrustNode,
        roots: HashSet<&PublicKeyHashable>,
    ) -> Vec<Vec<Auth>> {
        // queue to collect all chains in the trust graph (each chain is a path in the trust graph)
        let mut chains_queue: VecDeque<Vec<Auth>> = VecDeque::new();

        let node_auths: Vec<Auth> = node.authorizations().cloned().collect();
        // put all auth in the queue as the first possible paths through the graph
        for auth in node_auths {
            chains_queue.push_back(vec![auth]);
        }

        // List of all chains that converge (terminate) to known roots
        let mut terminated_chains: Vec<Vec<Auth>> = Vec::new();

        while !chains_queue.is_empty() {
            let cur_chain = chains_queue
                .pop_front()
                .expect("`chains_queue` always has at least one element");

            let last = cur_chain
                .last()
                .expect("`cur_chain` always has at least one element");

            let auths: Vec<Auth> = self
                .nodes
                .get(&last.issued_by.clone().into())
                .expect(
                    "there cannot be paths without any nodes after adding verified certificates",
                )
                .authorizations()
                .cloned()
                .collect();

            for auth in auths {
                // if there is auth, that we not visited in the current chain, copy chain and append this auth
                if !cur_chain
                    .iter()
                    .any(|a| a.trust.issued_for == auth.issued_by)
                {
                    let mut new_chain = cur_chain.clone();
                    new_chain.push(auth);
                    chains_queue.push_back(new_chain);
                }
            }

            // to be considered a valid chain, the chain must:
            // - end with a self-signed trust
            // - that trust must converge to one of the root weights
            // - there should be more than 1 trust in the chain
            let self_signed = last.issued_by == last.trust.issued_for;
            let converges_to_root = roots.contains(last.issued_by.as_ref());

            if self_signed && converges_to_root && cur_chain.len() > 1 {
                terminated_chains.push(cur_chain);
            }
        }

        terminated_chains
    }
/// BF search for all converging paths (chains) in the graph
/// TODO could be optimized with closure, that will calculate the weight on the fly
/// TODO or store auths to build certificates
BF search for all converging paths (chains) in the graph
TODO could be optimized with closure, that will calculate the weight on the fly
TODO or store auths to build certificates
BF search for all converging paths ( chains ) in the graph TODO could be optimized with closure that will calculate the weight on the fly TODO or store auths to build certificates
fn bf_search_paths(
        &self,
        node: &TrustNode,
        roots: HashSet<&PublicKeyHashable>,
    ) -> Vec<Vec<Auth>> {
        // queue to collect all chains in the trust graph (each chain is a path in the trust graph)
        let mut chains_queue: VecDeque<Vec<Auth>> = VecDeque::new();
        let node_auths: Vec<Auth> = node.authorizations().cloned().collect();
        // put all auth in the queue as the first possible paths through the graph
        for auth in node_auths {
            chains_queue.push_back(vec![auth]);
        }
        // List of all chains that converge (terminate) to known roots
        let mut terminated_chains: Vec<Vec<Auth>> = Vec::new();
        while !chains_queue.is_empty() {
            let cur_chain = chains_queue
                .pop_front()
                .expect("`chains_queue` always has at least one element");
            let last = cur_chain
                .last()
                .expect("`cur_chain` always has at least one element");
            let auths: Vec<Auth> = self
                .nodes
                .get(&last.issued_by.clone().into())
                .expect(
                    "there cannot be paths without any nodes after adding verified certificates",
                )
                .authorizations()
                .cloned()
                .collect();
            for auth in auths {
                // if there is auth, that we not visited in the current chain, copy chain and append this auth
                if !cur_chain
                    .iter()
                    .any(|a| a.trust.issued_for == auth.issued_by)
                {
                    let mut new_chain = cur_chain.clone();
                    new_chain.push(auth);
                    chains_queue.push_back(new_chain);
                }
            }
            // to be considered a valid chain, the chain must:
            // - end with a self-signed trust
            // - that trust must converge to one of the root weights
            // - there should be more than 1 trust in the chain
            let self_signed = last.issued_by == last.trust.issued_for;
            let converges_to_root = roots.contains(last.issued_by.as_ref());
            if self_signed && converges_to_root && cur_chain.len() > 1 {
                terminated_chains.push(cur_chain);
            }
        }
        terminated_chains
    }
fn bf_search_paths ( & self , node : & TrustNode , roots : HashSet < & PublicKeyHashable > , ) -> Vec < Vec < Auth > > { // queue to collect all chains in the trust graph (each chain is a path in the trust graph) let mut chains_queue : VecDeque < Vec < Auth > > = VecDeque :: new ( ) ; let node_auths : Vec < Auth > = node . authorizations ( ) . cloned ( ) . collect ( ) ; // put all auth in the queue as the first possible paths through the graph for auth in node_auths { chains_queue . push_back ( vec ! [ auth ] ) ; } // List of all chains that converge (terminate) to known roots let mut terminated_chains : Vec < Vec < Auth > > = Vec :: new ( ) ; while ! chains_queue . is_empty ( ) { let cur_chain = chains_queue . pop_front ( ) . expect ( " " ) ; let last = cur_chain . last ( ) . expect ( " " ) ; let auths : Vec < Auth > = self . nodes . get ( & last . issued_by . clone ( ) . into ( ) ) . expect ( " " , ) . authorizations ( ) . cloned ( ) . collect ( ) ; for auth in auths { // if there is auth, that we not visited in the current chain, copy chain and append this auth if ! cur_chain . iter ( ) . any ( | a | a . trust . issued_for == auth . issued_by ) { let mut new_chain = cur_chain . clone ( ) ; new_chain . push ( auth ) ; chains_queue . push_back ( new_chain ) ; } } // to be considered a valid chain, the chain must: // - end with a self-signed trust // - that trust must converge to one of the root weights // - there should be more than 1 trust in the chain let self_signed = last . issued_by == last . trust . issued_for ; let converges_to_root = roots . contains ( last . issued_by . as_ref ( ) ) ; if self_signed && converges_to_root && cur_chain . len ( ) > 1 { terminated_chains . push ( cur_chain ) ; } } terminated_chains }
BF search for all converging paths (chains) in the graph
TODO could be optimized with closure, that will calculate the weight on the fly
TODO or store auths to build certificates
BF search for all converging paths ( chains ) in the graph TODO could be optimized with closure that will calculate the weight on the fly TODO or store auths to build certificates
&self
node
&TrustNode
roots
HashSet<&PublicKeyHashable>