avoiding back in time travel

Signed-off-by: Uncle Stinky <uncle.stinky@ghostchain.io>
This commit is contained in:
Uncle Stinky 2025-07-31 15:30:28 +03:00
parent b969081cbf
commit 1c4c517728
Signed by: st1nky
GPG Key ID: 016064BD97603B40
2 changed files with 14 additions and 17 deletions

View File

@ -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

View File

@ -763,23 +763,20 @@ impl<T: Config> Pallet<T> {
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
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),
),
.min(estimated_block));
(from_block, adjusted_to_block)
}
}
None => (to_block, to_block),
_ => (to_block, to_block),
},
None => (estimated_block, estimated_block),
})