From 06f4a59664b5475631c94c684993ac329cf6272f Mon Sep 17 00:00:00 2001 From: teor Date: Thu, 20 Aug 2020 12:25:46 +1000 Subject: [PATCH] feature: Add a checkpoint_sync config option (The option doesn't do anything yet.) --- Cargo.lock | 1 + zebra-consensus/Cargo.toml | 5 +++-- zebra-consensus/src/config.rs | 22 ++++++++++++++++++++++ zebra-consensus/src/lib.rs | 4 ++++ zebrad/src/config.rs | 4 ++++ 5 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 zebra-consensus/src/config.rs diff --git a/Cargo.lock b/Cargo.lock index 929b2d27..ad98f283 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3085,6 +3085,7 @@ dependencies = [ "once_cell", "rand 0.7.3", "redjubjub", + "serde", "spandoc", "tokio", "tower", diff --git a/zebra-consensus/Cargo.toml b/zebra-consensus/Cargo.toml index 53c0e3c3..82e9bac7 100644 --- a/zebra-consensus/Cargo.toml +++ b/zebra-consensus/Cargo.toml @@ -8,18 +8,19 @@ edition = "2018" [dependencies] chrono = "0.4.13" color-eyre = "0.5" +once_cell = "1.4" rand = "0.7" redjubjub = "0.2" +serde = { version = "1", features = ["serde_derive"] } -metrics = "0.12" futures = "0.3.5" futures-util = "0.3.5" +metrics = "0.12" tokio = { version = "0.2.22", features = ["time", "sync", "stream", "tracing"] } tower = "0.3" tower-util = "0.3" tracing = "0.1.19" tracing-futures = "0.2.4" -once_cell = "1.4" tower-fallback = { path = "../tower-fallback/" } tower-batch = { path = "../tower-batch/" } diff --git a/zebra-consensus/src/config.rs b/zebra-consensus/src/config.rs new file mode 100644 index 00000000..661cd457 --- /dev/null +++ b/zebra-consensus/src/config.rs @@ -0,0 +1,22 @@ +//! Configuration for zebra-consensus + +use serde::{Deserialize, Serialize}; + +/// Consensus configuration. +#[derive(Clone, Debug, Deserialize, Serialize)] +#[serde(deny_unknown_fields, default)] +pub struct Config { + /// Should Zebra sync using checkpoints? + /// + /// Setting this option to true enables post-Sapling checkpoints. + /// (Zebra always checkpoints on Sapling activation.) + pub checkpoint_sync: bool, +} + +impl Default for Config { + fn default() -> Self { + Self { + checkpoint_sync: false, + } + } +} diff --git a/zebra-consensus/src/lib.rs b/zebra-consensus/src/lib.rs index 001fa878..f8a4c027 100644 --- a/zebra-consensus/src/lib.rs +++ b/zebra-consensus/src/lib.rs @@ -18,9 +18,13 @@ pub mod block; pub mod chain; pub mod checkpoint; +pub mod config; pub mod mempool; pub mod parameters; + #[allow(dead_code)] // Remove this once transaction verification is implemented mod primitives; mod script; mod transaction; + +pub use crate::config::Config; diff --git a/zebrad/src/config.rs b/zebrad/src/config.rs index 98acb91f..b32d2bbb 100644 --- a/zebrad/src/config.rs +++ b/zebrad/src/config.rs @@ -8,6 +8,7 @@ use std::{net::SocketAddr, path::PathBuf}; use serde::{Deserialize, Serialize}; +use zebra_consensus::Config as ConsensusSection; use zebra_network::Config as NetworkSection; use zebra_state::Config as StateSection; @@ -19,6 +20,9 @@ use zebra_state::Config as StateSection; #[derive(Clone, Default, Debug, Deserialize, Serialize)] #[serde(deny_unknown_fields, default)] pub struct ZebradConfig { + /// Consensus configuration + pub consensus: ConsensusSection, + /// Metrics configuration pub metrics: MetricsSection,