Fix the dead loop problem (#228)
Some checks are pending
abi-consistent-check / build-and-compare (push) Waiting to run
code-coverage / unittest-cov (push) Waiting to run
rust / check (push) Waiting to run
rust / test (push) Waiting to run
rust / lints (push) Waiting to run
functional-test / test (push) Waiting to run

* Fix the dead loop problem

* keep parent block of log_latest_block_number block

* avoid overflow
This commit is contained in:
Joel Liu 2024-10-10 22:02:20 +08:00 committed by GitHub
parent 79d960d4ea
commit 649f6e5e9f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -178,7 +178,10 @@ impl LogEntryFetcher {
if let Some(finalized_block_number) = finalized_block_number { if let Some(finalized_block_number) = finalized_block_number {
let safe_block_number = std::cmp::min( let safe_block_number = std::cmp::min(
std::cmp::min(log_latest_block_number, finalized_block_number), std::cmp::min(
log_latest_block_number.saturating_sub(1),
finalized_block_number,
),
processed_block_number, processed_block_number,
); );
let mut pending_keys = vec![]; let mut pending_keys = vec![];
@ -657,7 +660,7 @@ async fn check_watch_process(
); );
match provider.get_block(*progress - 1).await { match provider.get_block(*progress - 1).await {
Ok(Some(v)) => { Ok(Some(v)) => {
v.hash.expect("parent block hash expect exist"); break v.hash.expect("parent block hash expect exist");
} }
Ok(None) => { Ok(None) => {
panic!("parent block {} expect exist", *progress - 1); panic!("parent block {} expect exist", *progress - 1);