feat: introduce maybe_pending method to StateProviderFactory (#18260)

Co-authored-by: Matthias Seitz <matthias.seitz@outlook.de>
This commit is contained in:
Femi Bankole
2025-09-06 08:31:09 +01:00
committed by GitHub
parent 63a912e312
commit ef337d46a2
5 changed files with 62 additions and 33 deletions

View File

@@ -557,6 +557,10 @@ impl<C: Send + Sync + 'static, N: NodePrimitives> StateProviderFactory for NoopP
fn pending_state_by_hash(&self, _block_hash: B256) -> ProviderResult<Option<StateProviderBox>> {
Ok(Some(Box::new(self.clone())))
}
fn maybe_pending(&self) -> ProviderResult<Option<StateProviderBox>> {
Ok(Some(Box::new(self.clone())))
}
}
impl<C: Send + Sync, N: NodePrimitives> StageCheckpointReader for NoopProvider<C, N> {

View File

@@ -194,4 +194,9 @@ pub trait StateProviderFactory: BlockIdReader + Send + Sync {
///
/// If the block couldn't be found, returns `None`.
fn pending_state_by_hash(&self, block_hash: B256) -> ProviderResult<Option<StateProviderBox>>;
/// Returns a pending [`StateProvider`] if it exists.
///
/// This will return `None` if there's no pending state.
fn maybe_pending(&self) -> ProviderResult<Option<StateProviderBox>>;
}