Skip to content

Commit

Permalink
fix(claimer): previous too high error
Browse files Browse the repository at this point in the history
This condition will happen when the checker reads blocks faster than
they are produced, so it shouldn't be considered an error. Instead, the
code just skips the update.
  • Loading branch information
gligneul authored and marcelstanley committed Nov 22, 2023
1 parent 6c6b22b commit 843a75d
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions offchain/authority-claimer/src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,6 @@ pub enum DuplicateCheckerError {
latest
))]
DepthTooHigh { depth: u64, latest: u64 },

#[snafu(display(
"Previous block `{}` higher than latest block `{}`",
previous,
latest
))]
PreviousTooHigh { previous: u64, latest: u64 },
}

impl DefaultDuplicateChecker {
Expand Down Expand Up @@ -140,13 +133,14 @@ impl DefaultDuplicateChecker {
ensure!(depth <= latest, DepthTooHighSnafu { depth, latest });
let latest = latest - depth;

ensure!(
self.next_block_to_read <= latest,
PreviousTooHighSnafu {
previous: self.next_block_to_read,
if latest < self.next_block_to_read {
trace!(
"nothing to read; next block is {}, but current block is {}",
self.next_block_to_read,
latest
}
);
);
return Ok(());
}

let dapp_address = H160(self.dapp_address.inner().to_owned());
let topic = ValueOrArray::Value(Some(dapp_address.into()));
Expand Down

0 comments on commit 843a75d

Please sign in to comment.