fn process_check_db(&mut self) {
        // Todo, add calls to ask peers for missing data
        let mut node = self.node_service.clone();
        self.executor.spawn(async move {
            let meta = node.get_metadata().await.expect("Could not retrieve chain meta");

            let mut height = meta.height_of_longest_chain.expect("Could not retrieve chain height");
            let mut missing_blocks = Vec::new();
            let mut missing_headers = Vec::new();
            print!("Searching for height: ");
            // We need to check every header, but not every block.
            let horizon_height = meta.horizon_block(height);
            while height > 0 {
                print!("{}", height);
                io::stdout().flush().unwrap();
                // we can only check till the pruning horizon, 0 is archive node so it needs to check every block.
                if height > horizon_height {
                    match node.get_blocks(vec![height]).await {
                        Err(_err) => {
                            missing_blocks.push(height);
                        },
                        Ok(mut data) => match data.pop() {
                            // We need to check the data it self, as FetchMatchingBlocks will suppress any error, only
                            // logging it.
                            Some(_historical_block) => {},
                            None => missing_blocks.push(height),
                        },
                    };
                }
                height -= 1;
                let next_header = node.get_headers(vec![height]).await;
                if next_header.is_err() {
                    // this header is missing, so we stop here and need to ask for this header
                    missing_headers.push(height);
                };
                print!("\x1B[{}D\x1B[K", (height + 1).to_string().chars().count());
            }
            println!("Complete");
            for missing_block in missing_blocks {
                println!("Missing block at height: {}", missing_block);
            }
            for missing_header_height in missing_headers {
                println!("Missing header at height: {}", missing_header_height)
            }
        });
    }
/// Function to process the check-db command
Function to process the check-db command
Function to process the check - db command
fn process_check_db(&mut self) {
        // Todo, add calls to ask peers for missing data
        let mut node = self.node_service.clone();
        self.executor.spawn(async move {
            let meta = node.get_metadata().await.expect("Could not retrieve chain meta");
            let mut height = meta.height_of_longest_chain.expect("Could not retrieve chain height");
            let mut missing_blocks = Vec::new();
            let mut missing_headers = Vec::new();
            print!("Searching for height: ");
            // We need to check every header, but not every block.
            let horizon_height = meta.horizon_block(height);
            while height > 0 {
                print!("{}", height);
                io::stdout().flush().unwrap();
                // we can only check till the pruning horizon, 0 is archive node so it needs to check every block.
                if height > horizon_height {
                    match node.get_blocks(vec![height]).await {
                        Err(_err) => {
                            missing_blocks.push(height);
                        },
                        Ok(mut data) => match data.pop() {
                            // We need to check the data it self, as FetchMatchingBlocks will suppress any error, only
                            // logging it.
                            Some(_historical_block) => {},
                            None => missing_blocks.push(height),
                        },
                    };
                }
                height -= 1;
                let next_header = node.get_headers(vec![height]).await;
                if next_header.is_err() {
                    // this header is missing, so we stop here and need to ask for this header
                    missing_headers.push(height);
                };
                print!("\x1B[{}D\x1B[K", (height + 1).to_string().chars().count());
            }
            println!("Complete");
            for missing_block in missing_blocks {
                println!("Missing block at height: {}", missing_block);
            }
            for missing_header_height in missing_headers {
                println!("Missing header at height: {}", missing_header_height)
            }
        });
    }
fn process_check_db ( & mut self ) { // Todo, add calls to ask peers for missing data let mut node = self . node_service . clone ( ) ; self . executor . spawn ( async move { let meta = node . get_metadata ( ) . await . expect ( " " ) ; let mut height = meta . height_of_longest_chain . expect ( " " ) ; let mut missing_blocks = Vec :: new ( ) ; let mut missing_headers = Vec :: new ( ) ; print ! ( " " ) ; // We need to check every header, but not every block. let horizon_height = meta . horizon_block ( height ) ; while height > 0 { print ! ( " " height ) ; io :: stdout ( ) . flush ( ) . unwrap ( ) ; // we can only check till the pruning horizon, 0 is archive node so it needs to check every block. if height > horizon_height { match node . get_blocks ( vec ! [ height ] ) . await { Err ( _err ) => { missing_blocks . push ( height ) ; } , Ok ( mut data ) => match data . pop ( ) { // We need to check the data it self, as FetchMatchingBlocks will suppress any error, only // logging it. Some ( _historical_block ) => { } , None => missing_blocks . push ( height ) , } , } ; } height -= 1 ; let next_header = node . get_headers ( vec ! [ height ] ) . await ; if next_header . is_err ( ) { // this header is missing, so we stop here and need to ask for this header missing_headers . push ( height ) ; } ; print ! ( " \x1B \x1B " ( height 1 ) to_string ( ) chars ( ) count ( ) ) ; } println ! ( " " ) ; for missing_block in missing_blocks { println ! ( " " missing_block ) ; } for missing_header_height in missing_headers { println ! ( " " missing_header_height ) } } ) ; }
Function to process the check-db command
Function to process the check - db command
&mut self
&mut self