fn close_enough(locator: &Vec<(u64, Hash)>, height: u64) -> Option<(u64, Hash)> {
	if locator.len() == 0 {
		return None;
	}
	// bounds, lower that last is last
	if locator.last().unwrap().0 >= height {
		return locator.last().map(|l| l.clone());
	}
	// higher than first is first if within an acceptable gap
	if locator[0].0 < height && height.saturating_sub(127) < locator[0].0 {
		return Some(locator[0]);
	}
	for hh in locator.windows(2) {
		if height <= hh[0].0 && height > hh[1].0 {
			if hh[0].0 - height < height - hh[1].0 {
				return Some(hh[0].clone());
			} else {
				return Some(hh[1].clone());
			}
		}
	}
	None
}
// Whether we have a value close enough to the provided height in the locator
Whether we have a value close enough to the provided height in the locator
Whether we have a value close enough to the provided height in the locator
fn close_enough(locator: &Vec<(u64, Hash)>, height: u64) -> Option<(u64, Hash)> {
	if locator.len() == 0 {
		return None;
	}
	// bounds, lower that last is last
	if locator.last().unwrap().0 >= height {
		return locator.last().map(|l| l.clone());
	}
	// higher than first is first if within an acceptable gap
	if locator[0].0 < height && height.saturating_sub(127) < locator[0].0 {
		return Some(locator[0]);
	}
	for hh in locator.windows(2) {
		if height <= hh[0].0 && height > hh[1].0 {
			if hh[0].0 - height < height - hh[1].0 {
				return Some(hh[0].clone());
			} else {
				return Some(hh[1].clone());
			}
		}
	}
	None
}
fn close_enough ( locator : & Vec < ( u64 , Hash ) > , height : u64 ) -> Option < ( u64 , Hash ) > { if locator . len ( ) == 0 { return None ; } // bounds, lower that last is last if locator . last ( ) . unwrap ( ) . 0 >= height { return locator . last ( ) . map ( | l | l . clone ( ) ) ; } // higher than first is first if within an acceptable gap if locator [ 0 ] . 0 < height && height . saturating_sub ( 127 ) < locator [ 0 ] . 0 { return Some ( locator [ 0 ] ) ; } for hh in locator . windows ( 2 ) { if height <= hh [ 0 ] . 0 && height > hh [ 1 ] . 0 { if hh [ 0 ] . 0 - height < height - hh [ 1 ] . 0 { return Some ( hh [ 0 ] . clone ( ) ) ; } else { return Some ( hh [ 1 ] . clone ( ) ) ; } } } None }
Whether we have a value close enough to the provided height in the locator
Whether we have a value close enough to the provided height in the locator
locator
&Vec<(u64, Hash)>
height
u64
locator
&Vec<(u64, Hash)>
height
u64