From a4b02a21b788c26df81e5725c82cd0023b716c6c Mon Sep 17 00:00:00 2001 From: 0g-peterzhb <158457852+0g-peterzhb@users.noreply.github.com> Date: Mon, 14 Oct 2024 14:19:05 +0800 Subject: [PATCH] add retry (#232) --- .../src/sync_manager/log_entry_fetcher.rs | 27 ++++++++++++------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs b/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs index 4395480..ace2491 100644 --- a/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs +++ b/node/log_entry_sync/src/sync_manager/log_entry_fetcher.rs @@ -662,17 +662,24 @@ async fn check_watch_process( "get block hash for block {} from RPC, assume there is no org", *progress - 1 ); - match provider.get_block(*progress - 1).await { - Ok(Some(v)) => { - break v.hash.expect("parent block hash expect exist"); + let hash = loop { + match provider.get_block(*progress - 1).await { + Ok(Some(v)) => { + break v.hash.expect("parent block hash expect exist"); + } + Ok(None) => { + panic!("parent block {} expect exist", *progress - 1); + } + Err(e) => { + if e.to_string().contains("server is too busy") { + warn!("server busy, wait for parent block {}", *progress - 1); + } else { + panic!("parent block {} expect exist, error {}", *progress - 1, e); + } + } } - Ok(None) => { - panic!("parent block {} expect exist", *progress - 1); - } - Err(e) => { - panic!("parent block {} expect exist, error {}", *progress - 1, e); - } - } + }; + break hash; } }; }