diff --git a/pallets/slow-clap/Cargo.toml b/pallets/slow-clap/Cargo.toml index 289b869..a872e83 100644 --- a/pallets/slow-clap/Cargo.toml +++ b/pallets/slow-clap/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "ghost-slow-clap" -version = "0.3.38" +version = "0.3.39" description = "Applause protocol for the EVM bridge" license.workspace = true authors.workspace = true diff --git a/pallets/slow-clap/src/lib.rs b/pallets/slow-clap/src/lib.rs index d47ee2d..1e2eefd 100644 --- a/pallets/slow-clap/src/lib.rs +++ b/pallets/slow-clap/src/lib.rs @@ -763,23 +763,20 @@ impl Pallet { Ok(match maybe_block_range { Some((from_block, to_block)) => match maybe_new_evm_block { - Some(_) => { - match estimated_block.checked_sub(from_block) { - Some(current_distance) - if current_distance - < max_block_distance => - { - (from_block, estimated_block) - } - _ => ( - from_block, - from_block - .saturating_add(max_block_distance) - .min(estimated_block), - ), - } + Some(_) if from_block.le(&to_block) => { + let adjusted_to_block = estimated_block + .checked_sub(from_block) + .map(|current_distance| current_distance + .le(&max_block_distance) + .then(|| estimated_block) + ) + .flatten() + .unwrap_or(from_block + .saturating_add(max_block_distance) + .min(estimated_block)); + (from_block, adjusted_to_block) } - None => (to_block, to_block), + _ => (to_block, to_block), }, None => (estimated_block, estimated_block), })