pub fn wait_for_all_nodes_to_catchup(&mut self) -> bool {
        let num_attempts = 60;
        let last_committed_round_str = "consensus{op=committed_blocks_count}";
        let mut done = vec![false; self.validator_nodes.len()];

        let mut last_committed_round = 0;
        // First, try to retrieve the max value across all the committed rounds
        debug!("Calculating max committed round across the validators.");
        for node in self.validator_nodes.values() {
            match node.get_metric(last_committed_round_str) {
                Some(val) => {
                    debug!("\tNode {} last committed round = {}", node.peer_id, val);
                    last_committed_round = last_committed_round.max(val);
                }
                None => {
                    debug!(
                        "\tNode {} last committed round unknown, assuming 0.",
                        node.peer_id
                    );
                }
            }
        }

        // Now wait for all the nodes to catch up to the max.
        for i in 0..num_attempts {
            debug!(
                "Wait for catchup, target_commit_round = {}, attempt: {} of {}",
                last_committed_round,
                i + 1,
                num_attempts
            );
            for (node, done) in self.validator_nodes.values_mut().zip(done.iter_mut()) {
                if *done {
                    continue;
                }

                match node.get_metric(last_committed_round_str) {
                    Some(val) => {
                        if val >= last_committed_round {
                            debug!(
                                "\tNode {} is caught up with last committed round {}",
                                node.peer_id, val
                            );
                            *done = true;
                        } else {
                            debug!(
                                "\tNode {} is not caught up yet with last committed round {}",
                                node.peer_id, val
                            );
                        }
                    }
                    None => {
                        debug!(
                            "\tNode {} last committed round unknown, assuming 0.",
                            node.peer_id
                        );
                    }
                }
            }

            // Check if all the nodes have been successfully caught up
            if done.iter().all(|status| *status) {
                return true;
            }

            ::std::thread::sleep(::std::time::Duration::from_millis(1000));
        }

        false
    }
/// This function first checks the last committed round of all the nodes, picks the max
/// value and then waits for all the nodes to catch up to that round.
/// Once done, we can guarantee that all the txns committed before the invocation of this
/// function are now available at all the nodes.
This function first checks the last committed round of all the nodes, picks the max
value and then waits for all the nodes to catch up to that round.
Once done, we can guarantee that all the txns committed before the invocation of this
function are now available at all the nodes.
This function first checks the last committed round of all the nodes picks the max value and then waits for all the nodes to catch up to that round . Once done we can guarantee that all the txns committed before the invocation of this function are now available at all the nodes .
pub fn wait_for_all_nodes_to_catchup(&mut self) -> bool {
        let num_attempts = 60;
        let last_committed_round_str = "consensus{op=committed_blocks_count}";
        let mut done = vec![false; self.validator_nodes.len()];
        let mut last_committed_round = 0;
        // First, try to retrieve the max value across all the committed rounds
        debug!("Calculating max committed round across the validators.");
        for node in self.validator_nodes.values() {
            match node.get_metric(last_committed_round_str) {
                Some(val) => {
                    debug!("\tNode {} last committed round = {}", node.peer_id, val);
                    last_committed_round = last_committed_round.max(val);
                }
                None => {
                    debug!(
                        "\tNode {} last committed round unknown, assuming 0.",
                        node.peer_id
                    );
                }
            }
        }
        // Now wait for all the nodes to catch up to the max.
        for i in 0..num_attempts {
            debug!(
                "Wait for catchup, target_commit_round = {}, attempt: {} of {}",
                last_committed_round,
                i + 1,
                num_attempts
            );
            for (node, done) in self.validator_nodes.values_mut().zip(done.iter_mut()) {
                if *done {
                    continue;
                }
                match node.get_metric(last_committed_round_str) {
                    Some(val) => {
                        if val >= last_committed_round {
                            debug!(
                                "\tNode {} is caught up with last committed round {}",
                                node.peer_id, val
                            );
                            *done = true;
                        } else {
                            debug!(
                                "\tNode {} is not caught up yet with last committed round {}",
                                node.peer_id, val
                            );
                        }
                    }
                    None => {
                        debug!(
                            "\tNode {} last committed round unknown, assuming 0.",
                            node.peer_id
                        );
                    }
                }
            }
            // Check if all the nodes have been successfully caught up
            if done.iter().all(|status| *status) {
                return true;
            }
            ::std::thread::sleep(::std::time::Duration::from_millis(1000));
        }
        false
    }
pub fn wait_for_all_nodes_to_catchup ( & mut self ) -> bool { let num_attempts = 60 ; let last_committed_round_str = " " ; let mut done = vec ! [ false self validator_nodes len ( ) ] ; let mut last_committed_round = 0 ; // First, try to retrieve the max value across all the committed rounds debug ! ( " " ) ; for node in self . validator_nodes . values ( ) { match node . get_metric ( last_committed_round_str ) { Some ( val ) => { debug ! ( " \t " node peer_id val ) ; last_committed_round = last_committed_round . max ( val ) ; } None => { debug ! ( " \t " node peer_id ) ; } } } // Now wait for all the nodes to catch up to the max. for i in 0 .. num_attempts { debug ! ( " " last_committed_round i 1 num_attempts ) ; for ( node , done ) in self . validator_nodes . values_mut ( ) . zip ( done . iter_mut ( ) ) { if * done { continue ; } match node . get_metric ( last_committed_round_str ) { Some ( val ) => { if val >= last_committed_round { debug ! ( " \t " node peer_id val ) ; * done = true ; } else { debug ! ( " \t " node peer_id val ) ; } } None => { debug ! ( " \t " node peer_id ) ; } } } // Check if all the nodes have been successfully caught up if done . iter ( ) . all ( | status | * status ) { return true ; } :: std :: thread :: sleep ( :: std :: time :: Duration :: from_millis ( 1000 ) ) ; } false }
This function first checks the last committed round of all the nodes, picks the max
value and then waits for all the nodes to catch up to that round.
This function first checks the last committed round of all the nodes picks the max value and then waits for all the nodes to catch up to that round .
&mut self
&mut self