fix(config): Duration fields (#4587)
* use `humantime_serde` for config durations * move debug config option to the bottom * fix deserialization Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
This commit is contained in:
parent
3825caae03
commit
6d9bb2226a
|
@ -2033,9 +2033,9 @@ checksum = "9a3a5bfb195931eeb336b2a7b4d761daec841b97f947d34394601737a7bba5e4"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "humantime-serde"
|
name = "humantime-serde"
|
||||||
version = "1.0.1"
|
version = "1.1.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "ac34a56cfd4acddb469cc7fff187ed5ac36f498ba085caf8bbc725e3ff474058"
|
checksum = "57a3db5ea5923d99402c94e9feb261dc5ee9b4efa158b0315f788cf549cc200c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"humantime",
|
"humantime",
|
||||||
"serde",
|
"serde",
|
||||||
|
@ -6245,6 +6245,7 @@ dependencies = [
|
||||||
"chrono",
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
"hex",
|
"hex",
|
||||||
|
"humantime-serde",
|
||||||
"lazy_static",
|
"lazy_static",
|
||||||
"metrics",
|
"metrics",
|
||||||
"ordered-map",
|
"ordered-map",
|
||||||
|
@ -6405,6 +6406,7 @@ dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"gumdrop",
|
"gumdrop",
|
||||||
"hex",
|
"hex",
|
||||||
|
"humantime-serde",
|
||||||
"hyper",
|
"hyper",
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"inferno",
|
"inferno",
|
||||||
|
|
|
@ -18,6 +18,7 @@ byteorder = "1.4.3"
|
||||||
bytes = "1.1.0"
|
bytes = "1.1.0"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
hex = "0.4.3"
|
hex = "0.4.3"
|
||||||
|
humantime-serde = "1.1.1"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
ordered-map = "0.4.2"
|
ordered-map = "0.4.2"
|
||||||
pin-project = "1.0.10"
|
pin-project = "1.0.10"
|
||||||
|
|
|
@ -77,9 +77,7 @@ pub struct Config {
|
||||||
/// - regularly, every time `crawl_new_peer_interval` elapses, and
|
/// - regularly, every time `crawl_new_peer_interval` elapses, and
|
||||||
/// - if the peer set is busy, and there aren't any peer addresses for the
|
/// - if the peer set is busy, and there aren't any peer addresses for the
|
||||||
/// next connection attempt.
|
/// next connection attempt.
|
||||||
//
|
#[serde(with = "humantime_serde")]
|
||||||
// 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
|
|
||||||
pub crawl_new_peer_interval: Duration,
|
pub crawl_new_peer_interval: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -301,7 +299,7 @@ impl<'de> Deserialize<'de> for Config {
|
||||||
initial_mainnet_peers: HashSet<String>,
|
initial_mainnet_peers: HashSet<String>,
|
||||||
initial_testnet_peers: HashSet<String>,
|
initial_testnet_peers: HashSet<String>,
|
||||||
peerset_initial_target_size: usize,
|
peerset_initial_target_size: usize,
|
||||||
#[serde(alias = "new_peer_interval")]
|
#[serde(alias = "new_peer_interval", with = "humantime_serde")]
|
||||||
crawl_new_peer_interval: Duration,
|
crawl_new_peer_interval: Duration,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,7 @@ zebra-state = { path = "../zebra-state" }
|
||||||
abscissa_core = "0.5"
|
abscissa_core = "0.5"
|
||||||
gumdrop = "0.7"
|
gumdrop = "0.7"
|
||||||
chrono = "0.4.19"
|
chrono = "0.4.19"
|
||||||
|
humantime-serde = "1.1.1"
|
||||||
indexmap = "1.8.2"
|
indexmap = "1.8.2"
|
||||||
lazy_static = "1.4.0"
|
lazy_static = "1.4.0"
|
||||||
serde = { version = "1.0.137", features = ["serde_derive"] }
|
serde = { version = "1.0.137", features = ["serde_derive"] }
|
||||||
|
|
|
@ -8,17 +8,6 @@ use serde::{Deserialize, Serialize};
|
||||||
#[derive(Clone, Debug, Deserialize, Serialize)]
|
#[derive(Clone, Debug, Deserialize, Serialize)]
|
||||||
#[serde(deny_unknown_fields, default)]
|
#[serde(deny_unknown_fields, default)]
|
||||||
pub struct Config {
|
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<u32>,
|
|
||||||
|
|
||||||
/// The mempool transaction cost limit.
|
/// The mempool transaction cost limit.
|
||||||
///
|
///
|
||||||
/// This limits the total serialized byte size of all transactions in the mempool.
|
/// 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
|
/// This corresponds to `mempoolevictionmemoryminutes` from
|
||||||
/// [ZIP-401](https://zips.z.cash/zip-0401#specification).
|
/// [ZIP-401](https://zips.z.cash/zip-0401#specification).
|
||||||
///
|
#[serde(with = "humantime_serde")]
|
||||||
// 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
|
|
||||||
pub eviction_memory_time: Duration,
|
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<u32>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for Config {
|
impl Default for Config {
|
||||||
|
|
Loading…
Reference in New Issue