mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-02-19 03:04:27 -05:00
chore: allow invalid storage metadata (#22150)
This commit is contained in:
@@ -16,11 +16,15 @@ pub trait MetadataProvider: Send {
|
||||
/// Get a metadata value by key
|
||||
fn get_metadata(&self, key: &str) -> ProviderResult<Option<Vec<u8>>>;
|
||||
|
||||
/// Get storage settings for this node
|
||||
/// Get storage settings for this node.
|
||||
///
|
||||
/// If the stored metadata can't be deserialized (e.g. the format changed),
|
||||
/// this returns `None` instead of an error so commands like `db clear` can
|
||||
/// still operate without requiring a compatible metadata schema.
|
||||
fn storage_settings(&self) -> ProviderResult<Option<StorageSettings>> {
|
||||
self.get_metadata(keys::STORAGE_SETTINGS)?
|
||||
.map(|bytes| serde_json::from_slice(&bytes).map_err(ProviderError::other))
|
||||
.transpose()
|
||||
Ok(self
|
||||
.get_metadata(keys::STORAGE_SETTINGS)?
|
||||
.and_then(|bytes| serde_json::from_slice(&bytes).ok()))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user