mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-04-30 03:01:58 -04:00
just impl custom deserialize
This commit is contained in:
@@ -35,7 +35,7 @@ use serde::{Deserialize, Deserializer};
|
||||
|
||||
/// Configuration for pruning receipts not associated with logs emitted by the specified contracts.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Default, Deref, DerefMut, From)]
|
||||
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize, serde::Deserialize))]
|
||||
#[cfg_attr(any(test, feature = "serde"), derive(serde::Serialize))]
|
||||
pub struct ReceiptsLogPruneConfig(pub BTreeMap<Address, PruneMode>);
|
||||
|
||||
impl ReceiptsLogPruneConfig {
|
||||
@@ -49,19 +49,6 @@ impl ReceiptsLogPruneConfig {
|
||||
self.0.is_empty()
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "serde", feature = "std"))]
|
||||
pub(crate) fn deserialize<'de, D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let mut config = Self(BTreeMap::deserialize(deserializer)?);
|
||||
let errors = config.validate_and_fix();
|
||||
for error in errors {
|
||||
reth_tracing::tracing::warn!("Receipt log pruning config error: {}", error);
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
|
||||
/// Validates the configuration and fixes any issues if possible.
|
||||
pub fn validate_and_fix(&mut self) -> Vec<PruneSegmentError> {
|
||||
let mut errors = Vec::new();
|
||||
@@ -119,3 +106,18 @@ impl ReceiptsLogPruneConfig {
|
||||
Ok(map)
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "serde")]
|
||||
impl<'de> Deserialize<'de> for ReceiptsLogPruneConfig {
|
||||
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
|
||||
where
|
||||
D: Deserializer<'de>,
|
||||
{
|
||||
let mut config = Self(BTreeMap::deserialize(deserializer)?);
|
||||
let errors = config.validate_and_fix();
|
||||
for error in errors {
|
||||
reth_tracing::tracing::warn!("Receipt log pruning config error: {}", error);
|
||||
}
|
||||
Ok(config)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![allow(deprecated)] // necessary to all defining deprecated `PruneSegment` variants
|
||||
|
||||
use crate::{PruneMode, MINIMUM_PRUNING_DISTANCE};
|
||||
use crate::MINIMUM_PRUNING_DISTANCE;
|
||||
use alloy_primitives::Address;
|
||||
use derive_more::Display;
|
||||
use strum::{EnumIter, IntoEnumIterator};
|
||||
|
||||
@@ -102,10 +102,7 @@ pub struct PruneModes {
|
||||
/// Receipts log filtering has been deprecated and will be removed in a future release.
|
||||
#[cfg_attr(
|
||||
any(test, feature = "serde"),
|
||||
serde(
|
||||
skip_serializing_if = "ReceiptsLogPruneConfig::is_empty",
|
||||
deserialize_with = "ReceiptsLogPruneConfig::deserialize"
|
||||
)
|
||||
serde(skip_serializing_if = "ReceiptsLogPruneConfig::is_empty",)
|
||||
)]
|
||||
pub receipts_log_filter: ReceiptsLogPruneConfig,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user