mirror of
https://github.com/Qortal/pirate-librustzcash.git
synced 2025-07-31 12:31:22 +00:00
Tidy up DiversifierIndex::increment()
This commit is contained in:
10
src/lib.rs
10
src/lib.rs
@@ -286,19 +286,15 @@ impl DiversifierIndex {
|
||||
}
|
||||
|
||||
pub fn increment(&mut self) -> Result<(), ()> {
|
||||
let mut k = 0;
|
||||
loop {
|
||||
for k in 0..11 {
|
||||
self.0[k] = self.0[k].wrapping_add(1);
|
||||
if self.0[k] != 0 {
|
||||
// No overflow
|
||||
return Ok(());
|
||||
}
|
||||
// Overflow
|
||||
k += 1;
|
||||
if k == 11 {
|
||||
return Err(());
|
||||
}
|
||||
}
|
||||
// Overflow
|
||||
Err(())
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user