3.8 Document termination of unbounded loop

This commit is contained in:
Luke Parker 2023-07-10 14:34:32 -04:00
parent d75115ce13
commit fa1b569b78
No known key found for this signature in database

View file

@ -115,6 +115,9 @@ impl Scanner {
/// If an offset isn't usable, it will be incremented until it is. If this offset is already /// If an offset isn't usable, it will be incremented until it is. If this offset is already
/// present, None is returned. Else, Some(offset) will be, with the used offset. /// present, None is returned. Else, Some(offset) will be, with the used offset.
pub fn register_offset(&mut self, mut offset: Scalar) -> Option<Scalar> { pub fn register_offset(&mut self, mut offset: Scalar) -> Option<Scalar> {
// This loop will terminate as soon as an even point is found, with any point having a ~50%
// chance of being even
// That means this should terminate within a very small amount of iterations
loop { loop {
match address(Network::Bitcoin, self.key + (ProjectivePoint::GENERATOR * offset)) { match address(Network::Bitcoin, self.key + (ProjectivePoint::GENERATOR * offset)) {
Some(address) => { Some(address) => {