Skip to content

Commit

Permalink
fix error match and eol (#20)
Browse files Browse the repository at this point in the history
* fix error match and eol
  • Loading branch information
0g-peterzhb authored Aug 28, 2024
1 parent 221e82a commit a3fa996
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
15 changes: 8 additions & 7 deletions node/log_entry_sync/src/sync_manager/log_query.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use thiserror::Error;
pub(crate) type PinBoxFut<'a, T> =
Pin<Box<dyn Future<Output = Result<T, ProviderError>> + Send + 'a>>;

const TOO_MANY_LOGS_ERROR_MSG: &str = "query returned more than";
const TOO_MANY_LOGS_ERROR_MSG: [&str; 2] = ["query returned more than", "too large with more than"];

/// A log query provides streaming access to historical logs via a paginated
/// request. For streaming access to future logs, use [`Middleware::watch`] or
Expand Down Expand Up @@ -159,13 +159,14 @@ where
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
}
Err(err) => {
if err.to_string().contains(TOO_MANY_LOGS_ERROR_MSG) {
self.from_block = *from_block;
self.page_size /= 2;
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
} else {
Poll::Ready(Some(Err(LogQueryError::LoadLogsError(err))))
for msg in TOO_MANY_LOGS_ERROR_MSG.iter() {
if err.to_string().contains(msg) {
self.from_block = *from_block;
self.page_size /= 2;
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
}
}
Poll::Ready(Some(Err(LogQueryError::LoadLogsError(err))))
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions node/src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@ pub fn configure(logfile: &str, executor: TaskExecutor) {
let handle = builder.reload_handle();
builder.init();

let logfile = logfile.to_string();
let logfile = logfile.trim_end().to_string();

// load config synchronously
let mut config = std::fs::read_to_string(&logfile).unwrap_or_default();
let mut config = std::fs::read_to_string(&logfile)
.unwrap_or_default()
.trim_end()
.to_string();
let _ = handle.reload(&config);

// periodically check for config changes
Expand Down

0 comments on commit a3fa996

Please sign in to comment.