pub(crate) fn find_decided(&self, state: &'a State<C>) -> Option<(u64, &'a C::Hash)> {
        let max_height = *self.0.keys().next_back()?;
        let total_weight: Weight = self.0.values().map(Tally::weight).sum();
        // In the loop, this will be the tally of all votes from higher than the current height.
        let mut prev_tally = self[max_height].clone();
        // Start from `max_height - 1` and find the greatest height where a decision can be made.
        for height in (0..max_height).rev() {
            // The tally at `height` is the sum of the parents of `height + 1` and the units that
            // point directly to blocks at `height`.
            let mut h_tally = prev_tally.parents(state);
            if let Some(tally) = self.0.get(&height) {
                h_tally.extend(tally);
            }
            // If any block received more than 50%, a decision can be made: Either that block is
            // the fork choice, or we can pick its highest scoring child from `prev_tally`.
            if h_tally.max_w() > total_weight / 2 {
                #[allow(clippy::integer_arithmetic)] // height < max_height, so height < u64::MAX
                return Some(
                    match prev_tally.filter_descendants(height, h_tally.max_bhash(), state) {
                        Some(filtered) => (height + 1, filtered.max_bhash()),
                        None => (height, h_tally.max_bhash()),
                    },
                );
            }
            prev_tally = h_tally;
        }
        // Even at level 0 no block received a majority. Pick the one with the highest weight.
        Some((0, prev_tally.max_bhash()))
    }
/// Returns the height and hash of a block that is an ancestor of the fork choice, and _not_ an
/// ancestor of all entries in `self`. Returns `None` if `self` is empty.
Returns the height and hash of a block that is an ancestor of the fork choice, and _not_ an
ancestor of all entries in `self`. Returns `None` if `self` is empty.
Returns the height and hash of a block that is an ancestor of the fork choice and _not_ an ancestor of all entries in ` self ` . Returns ` None ` if ` self ` is empty .
pub(crate) fn find_decided(&self, state: &'a State<C>) -> Option<(u64, &'a C::Hash)> {
        let max_height = *self.0.keys().next_back()?;
        let total_weight: Weight = self.0.values().map(Tally::weight).sum();
        // In the loop, this will be the tally of all votes from higher than the current height.
        let mut prev_tally = self[max_height].clone();
        // Start from `max_height - 1` and find the greatest height where a decision can be made.
        for height in (0..max_height).rev() {
            // The tally at `height` is the sum of the parents of `height + 1` and the units that
            // point directly to blocks at `height`.
            let mut h_tally = prev_tally.parents(state);
            if let Some(tally) = self.0.get(&height) {
                h_tally.extend(tally);
            }
            // If any block received more than 50%, a decision can be made: Either that block is
            // the fork choice, or we can pick its highest scoring child from `prev_tally`.
            if h_tally.max_w() > total_weight / 2 {
                #[allow(clippy::integer_arithmetic)] // height < max_height, so height < u64::MAX
                return Some(
                    match prev_tally.filter_descendants(height, h_tally.max_bhash(), state) {
                        Some(filtered) => (height + 1, filtered.max_bhash()),
                        None => (height, h_tally.max_bhash()),
                    },
                );
            }
            prev_tally = h_tally;
        }
        // Even at level 0 no block received a majority. Pick the one with the highest weight.
        Some((0, prev_tally.max_bhash()))
    }
pub ( crate ) fn find_decided ( & self , state : & ' a State < C > ) -> Option < ( u64 , & ' a C :: Hash ) > { let max_height = * self . 0 . keys ( ) . next_back ( ) ? ; let total_weight : Weight = self . 0 . values ( ) . map ( Tally :: weight ) . sum ( ) ; // In the loop, this will be the tally of all votes from higher than the current height. let mut prev_tally = self [ max_height ] . clone ( ) ; // Start from `max_height - 1` and find the greatest height where a decision can be made. for height in ( 0 .. max_height ) . rev ( ) { // The tally at `height` is the sum of the parents of `height + 1` and the units that // point directly to blocks at `height`. let mut h_tally = prev_tally . parents ( state ) ; if let Some ( tally ) = self . 0 . get ( & height ) { h_tally . extend ( tally ) ; } // If any block received more than 50%, a decision can be made: Either that block is // the fork choice, or we can pick its highest scoring child from `prev_tally`. if h_tally . max_w ( ) > total_weight / 2 { # [ allow ( clippy integer_arithmetic ) ] // height < max_height, so height < u64::MAX return Some ( match prev_tally . filter_descendants ( height , h_tally . max_bhash ( ) , state ) { Some ( filtered ) => ( height + 1 , filtered . max_bhash ( ) ) , None => ( height , h_tally . max_bhash ( ) ) , } , ) ; } prev_tally = h_tally ; } // Even at level 0 no block received a majority. Pick the one with the highest weight. Some ( ( 0 , prev_tally . max_bhash ( ) ) ) }
Returns the height and hash of a block that is an ancestor of the fork choice, and _not_ an
ancestor of all entries in `self`.
Returns the height and hash of a block that is an ancestor of the fork choice and _not_ an ancestor of all entries in ` self ` .
&self
state
&'a State<C>
&self
state
&'a State<C>