From 15b50ce6a544bdb7d22e124d486eeb933456f87e Mon Sep 17 00:00:00 2001 From: cloudhead Date: Mon, 14 Aug 2023 10:31:35 +0200 Subject: [PATCH] radicle: Fix config deserialization This is a fix for the breaking changes introduced with `PeerConfig`. --- radicle/src/node/config.rs | 8 ++++++++ radicle/src/serde_ext.rs | 7 +++++++ 2 files changed, 15 insertions(+) diff --git a/radicle/src/node/config.rs b/radicle/src/node/config.rs index a696e0fc..db986efe 100644 --- a/radicle/src/node/config.rs +++ b/radicle/src/node/config.rs @@ -131,21 +131,29 @@ pub struct Config { /// Node alias. pub alias: Alias, /// Peer configuration. + #[serde(default)] pub peers: PeerConfig, /// Peers to connect to on startup. /// Connections to these peers will be maintained. + #[serde(default)] pub connect: HashSet, /// Specify the node's public addresses + #[serde(default)] pub external_addresses: Vec
, /// Peer-to-peer network. + #[serde(default)] pub network: Network, /// Whether or not our node should relay inventories. + #[serde(default = "crate::serde_ext::bool::yes")] pub relay: bool, /// Configured service limits. + #[serde(default)] pub limits: Limits, /// Default tracking policy. + #[serde(default)] pub policy: Policy, /// Default tracking scope. + #[serde(default)] pub scope: Scope, } diff --git a/radicle/src/serde_ext.rs b/radicle/src/serde_ext.rs index 0755f4d4..de0b30a0 100644 --- a/radicle/src/serde_ext.rs +++ b/radicle/src/serde_ext.rs @@ -1,3 +1,10 @@ +pub mod bool { + /// Function that always returns `true`, for use in `serde(default)` attributes. + pub fn yes() -> bool { + true + } +} + pub mod string { use std::fmt::Display; use std::str::FromStr;