mirror of
https://github.com/0glabs/0g-storage-node.git
synced 2024-11-20 15:05:19 +00:00
check error messages (#176)
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
Some checks failed
abi-consistent-check / build-and-compare (push) Has been cancelled
code-coverage / unittest-cov (push) Has been cancelled
rust / check (push) Has been cancelled
rust / test (push) Has been cancelled
rust / lints (push) Has been cancelled
functional-test / test (push) Has been cancelled
This commit is contained in:
parent
508e787bd0
commit
e3c199d361
@ -14,7 +14,7 @@ use thiserror::Error;
|
|||||||
pub(crate) type PinBoxFut<'a, T> =
|
pub(crate) type PinBoxFut<'a, T> =
|
||||||
Pin<Box<dyn Future<Output = Result<T, ProviderError>> + Send + 'a>>;
|
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
|
/// A log query provides streaming access to historical logs via a paginated
|
||||||
/// request. For streaming access to future logs, use [`Middleware::watch`] or
|
/// request. For streaming access to future logs, use [`Middleware::watch`] or
|
||||||
@ -127,7 +127,7 @@ where
|
|||||||
// this is okay because we will only enter this state when the filter is
|
// this is okay because we will only enter this state when the filter is
|
||||||
// paginatable i.e. from block is set
|
// paginatable i.e. from block is set
|
||||||
let from_block = self.filter.get_from_block().unwrap();
|
let from_block = self.filter.get_from_block().unwrap();
|
||||||
let to_block = min(from_block + self.page_size, last_block);
|
let to_block = min(from_block + self.page_size - 1, last_block);
|
||||||
self.from_block = Some(to_block + 1);
|
self.from_block = Some(to_block + 1);
|
||||||
|
|
||||||
let filter = self
|
let filter = self
|
||||||
@ -159,14 +159,15 @@ where
|
|||||||
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
|
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
if err.to_string().contains(TOO_MANY_LOGS_ERROR_MSG) {
|
for msg in TOO_MANY_LOGS_ERROR_MSG.iter() {
|
||||||
|
if err.to_string().contains(msg) {
|
||||||
self.from_block = *from_block;
|
self.from_block = *from_block;
|
||||||
self.page_size /= 2;
|
self.page_size /= 2;
|
||||||
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
|
rewake_with_new_state!(ctx, self, LogQueryState::Consume);
|
||||||
} else {
|
|
||||||
Poll::Ready(Some(Err(LogQueryError::LoadLogsError(err))))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Poll::Ready(Some(Err(LogQueryError::LoadLogsError(err))))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LogQueryState::Consume => {
|
LogQueryState::Consume => {
|
||||||
@ -181,9 +182,9 @@ where
|
|||||||
let from_block = self.from_block.unwrap();
|
let from_block = self.from_block.unwrap();
|
||||||
let to_block = if let Some(l) = self.last_block {
|
let to_block = if let Some(l) = self.last_block {
|
||||||
// if last_block is not none, only getLogs from to_block to last_block
|
// if last_block is not none, only getLogs from to_block to last_block
|
||||||
min(from_block + self.page_size, l)
|
min(from_block + self.page_size - 1, l)
|
||||||
} else {
|
} else {
|
||||||
from_block + self.page_size
|
from_block + self.page_size - 1
|
||||||
};
|
};
|
||||||
|
|
||||||
// no more pages to load, and everything is consumed
|
// no more pages to load, and everything is consumed
|
||||||
|
Loading…
Reference in New Issue
Block a user