From 6cc1627a5d67f9673d908acd10e8759d614dd998 Mon Sep 17 00:00:00 2001 From: Henry de Valence Date: Thu, 18 Jun 2020 13:34:05 -0700 Subject: [PATCH] zebrad: apply serde(default) to config sections Each subsection has to have `serde(default)` to get the behaviour we want (delete all fields except the ones that have been changed); otherwise, we can delete only entire sections. --- zebra-network/src/config.rs | 2 +- zebrad/src/config.rs | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index 721e5092..049f4af7 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -9,7 +9,7 @@ use zebra_chain::Network; /// Configuration for networking code. #[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] +#[serde(deny_unknown_fields, default)] pub struct Config { /// The address on which this node should listen for connections. pub listen_addr: SocketAddr, diff --git a/zebrad/src/config.rs b/zebrad/src/config.rs index 5fb2af7e..8bbbd8da 100644 --- a/zebrad/src/config.rs +++ b/zebrad/src/config.rs @@ -16,8 +16,7 @@ use zebra_network::Config as NetworkSection; /// of each field is described in the documentation, although it may be necessary /// to click through to the sub-structures for each section. #[derive(Clone, Default, Debug, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] -#[serde(default)] +#[serde(deny_unknown_fields, default)] pub struct ZebradConfig { /// Tracing configuration pub tracing: TracingSection, @@ -29,7 +28,7 @@ pub struct ZebradConfig { /// Tracing configuration section. #[derive(Clone, Debug, Default, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] +#[serde(deny_unknown_fields, default)] pub struct TracingSection { /// The filter used for tracing events. pub filter: Option, @@ -45,7 +44,7 @@ impl TracingSection { /// Metrics configuration section. #[derive(Clone, Debug, Deserialize, Serialize)] -#[serde(deny_unknown_fields)] +#[serde(deny_unknown_fields, default)] pub struct MetricsSection { pub endpoint_addr: SocketAddr, }