diff --git a/Cargo.lock b/Cargo.lock index 2811dd743..8a016d7a7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2033,9 +2033,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4" [[package]] name = "humantime-serde" -version = "1.0.1" +version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058" +checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c" dependencies = [ "humantime", "serde", @@ -6245,6 +6245,7 @@ dependencies = [ "chrono", "futures", "hex", + "humantime-serde", "lazy_static", "metrics", "ordered-map", @@ -6405,6 +6406,7 @@ dependencies = [ "futures", "gumdrop", "hex", + "humantime-serde", "hyper", "indexmap", "inferno", diff --git a/zebra-network/Cargo.toml b/zebra-network/Cargo.toml index ed85d41c9..c98d9dc73 100644 --- a/zebra-network/Cargo.toml +++ b/zebra-network/Cargo.toml @@ -18,6 +18,7 @@ byteorder = "1.4.3" bytes = "1.1.0" chrono = "0.4.19" hex = "0.4.3" +humantime-serde = "1.1.1" lazy_static = "1.4.0" ordered-map = "0.4.2" pin-project = "1.0.10" diff --git a/zebra-network/src/config.rs b/zebra-network/src/config.rs index ec1a4562a..cb993059f 100644 --- a/zebra-network/src/config.rs +++ b/zebra-network/src/config.rs @@ -77,9 +77,7 @@ pub struct Config { /// - regularly, every time `crawl_new_peer_interval` elapses, and /// - if the peer set is busy, and there aren't any peer addresses for the /// next connection attempt. - // - // Note: Durations become a TOML table, so they must be the final item in the config - // We'll replace them with a more user-friendly format in #2847 + #[serde(with = "humantime_serde")] pub crawl_new_peer_interval: Duration, } @@ -301,7 +299,7 @@ impl<'de> Deserialize<'de> for Config { initial_mainnet_peers: HashSet, initial_testnet_peers: HashSet, peerset_initial_target_size: usize, - #[serde(alias = "new_peer_interval")] + #[serde(alias = "new_peer_interval", with = "humantime_serde")] crawl_new_peer_interval: Duration, } diff --git a/zebrad/Cargo.toml b/zebrad/Cargo.toml index 7e5b1e813..cb2437073 100644 --- a/zebrad/Cargo.toml +++ b/zebrad/Cargo.toml @@ -59,6 +59,7 @@ zebra-state = { path = "../zebra-state" } abscissa_core = "0.5" gumdrop = "0.7" chrono = "0.4.19" +humantime-serde = "1.1.1" indexmap = "1.8.2" lazy_static = "1.4.0" serde = { version = "1.0.137", features = ["serde_derive"] } diff --git a/zebrad/src/components/mempool/config.rs b/zebrad/src/components/mempool/config.rs index c1afa2805..01708680a 100644 --- a/zebrad/src/components/mempool/config.rs +++ b/zebrad/src/components/mempool/config.rs @@ -8,17 +8,6 @@ use serde::{Deserialize, Serialize}; #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields, default)] pub struct Config { - /// If the state's best chain tip has reached this height, always enable the mempool, - /// regardless of Zebra's sync status. - /// - /// Set to `None` by default: Zebra always checks the sync status before enabling the mempool. - // - // TODO: - // - allow the mempool to be enabled before the genesis block is committed? - // we could replace `Option` with an enum that has an `AlwaysEnable` variant - // - move debug configs last (needs #2847) - pub debug_enable_at_height: Option, - /// The mempool transaction cost limit. /// /// This limits the total serialized byte size of all transactions in the mempool. @@ -39,10 +28,18 @@ pub struct Config { /// /// This corresponds to `mempoolevictionmemoryminutes` from /// [ZIP-401](https://zips.z.cash/zip-0401#specification). - /// - // Note: Durations become a TOML table, so they must be the final item in the config - // We'll replace them with a more user-friendly format in #2847 + #[serde(with = "humantime_serde")] pub eviction_memory_time: Duration, + + /// If the state's best chain tip has reached this height, always enable the mempool, + /// regardless of Zebra's sync status. + /// + /// Set to `None` by default: Zebra always checks the sync status before enabling the mempool. + // + // TODO: + // - allow the mempool to be enabled before the genesis block is committed? + // we could replace `Option` with an enum that has an `AlwaysEnable` variant + pub debug_enable_at_height: Option, } impl Default for Config {