fn locate_headers(
        &self,
        locators: &[BlockHash],
        stop_hash: BlockHash,
        max_headers: usize,
    ) -> Vec<BlockHeader> {
        if locators.is_empty() {
            if let Some((_, header)) = self.get_block(&stop_hash) {
                return vec![*header];
            }
            return vec![];
        }

        // Start from the highest locator hash that is on our active chain.
        // We don't respond with anything if none of the locators were found.
        let start = if let Some(hash) = locators.iter().find(|h| self.contains(h)) {
            let (height, _) = self.get_block(hash).unwrap();
            height
        } else {
            0 as Height
        };

        let start = start + 1;
        let stop = self
            .get_block(&stop_hash)
            .map(|(h, _)| h)
            .unwrap_or_else(|| self.height());
        let stop = Height::min(start + max_headers as Height, stop + 1);

        if start > stop {
            return vec![];
        }

        self.range(start..stop).map(|h| h.header).collect()
    }
/// Return headers after the first known hash in the locators list, and until the stop hash
/// is reached.
///
/// This function will never return more than `max_headers`.
///
/// * When no locators are provided, the stop hash is treated as a request for that header
///   alone.
/// * When locators *are* provided, but none of them are known, it is equivalent to having
///   the genesis hash as locator.
///
Return headers after the first known hash in the locators list, and until the stop hash
is reached.

This function will never return more than `max_headers`.

When no locators are provided, the stop hash is treated as a request for that header
alone.
When locators *are* provided, but none of them are known, it is equivalent to having
the genesis hash as locator.
Return headers after the first known hash in the locators list and until the stop hash is reached . This function will never return more than ` max_headers ` . When no locators are provided the stop hash is treated as a request for that header alone . When locators * are * provided but none of them are known it is equivalent to having the genesis hash as locator .
fn locate_headers(
        &self,
        locators: &[BlockHash],
        stop_hash: BlockHash,
        max_headers: usize,
    ) -> Vec<BlockHeader> {
        if locators.is_empty() {
            if let Some((_, header)) = self.get_block(&stop_hash) {
                return vec![*header];
            }
            return vec![];
        }
        // Start from the highest locator hash that is on our active chain.
        // We don't respond with anything if none of the locators were found.
        let start = if let Some(hash) = locators.iter().find(|h| self.contains(h)) {
            let (height, _) = self.get_block(hash).unwrap();
            height
        } else {
            0 as Height
        };
        let start = start + 1;
        let stop = self
            .get_block(&stop_hash)
            .map(|(h, _)| h)
            .unwrap_or_else(|| self.height());
        let stop = Height::min(start + max_headers as Height, stop + 1);
        if start > stop {
            return vec![];
        }
        self.range(start..stop).map(|h| h.header).collect()
    }
fn locate_headers ( & self , locators : & [ BlockHash ] , stop_hash : BlockHash , max_headers : usize , ) -> Vec < BlockHeader > { if locators . is_empty ( ) { if let Some ( ( _ , header ) ) = self . get_block ( & stop_hash ) { return vec ! [ header ] ; } return vec ! [ ] ; } // Start from the highest locator hash that is on our active chain. // We don't respond with anything if none of the locators were found. let start = if let Some ( hash ) = locators . iter ( ) . find ( | h | self . contains ( h ) ) { let ( height , _ ) = self . get_block ( hash ) . unwrap ( ) ; height } else { 0 as Height } ; let start = start + 1 ; let stop = self . get_block ( & stop_hash ) . map ( | ( h , _ ) | h ) . unwrap_or_else ( | | self . height ( ) ) ; let stop = Height :: min ( start + max_headers as Height , stop + 1 ) ; if start > stop { return vec ! [ ] ; } self . range ( start .. stop ) . map ( | h | h . header ) . collect ( ) }
Return headers after the first known hash in the locators list, and until the stop hash
is reached.
Return headers after the first known hash in the locators list and until the stop hash is reached .
&self
locators
&[BlockHash]
stop_hash
BlockHash
max_headers
usize