Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(config): Duration fields #4587

Merged
merged 4 commits into from
Jun 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions zebra-network/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
6 changes: 2 additions & 4 deletions zebra-network/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}

Expand Down Expand Up @@ -301,7 +299,7 @@ impl<'de> Deserialize<'de> for Config {
initial_mainnet_peers: HashSet<String>,
initial_testnet_peers: HashSet<String>,
peerset_initial_target_size: usize,
#[serde(alias = "new_peer_interval")]
#[serde(alias = "new_peer_interval", with = "humantime_serde")]
crawl_new_peer_interval: Duration,
}

Expand Down
1 change: 1 addition & 0 deletions zebrad/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
25 changes: 11 additions & 14 deletions zebrad/src/components/mempool/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<u32>,

/// The mempool transaction cost limit.
///
/// This limits the total serialized byte size of all transactions in the mempool.
Expand All @@ -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<u32>,
upbqdn marked this conversation as resolved.
Show resolved Hide resolved
}

impl Default for Config {
Expand Down