Radish alpha
h
Radicle Heartwood Protocol & Stack
Radicle
Git (anonymous pull)
Log in to clone via SSH
REVIEW: Use `clap` for default
Lorenz Leutgeb committed 6 months ago
commit 7e87fc8eb9e9072ccb506ae5557b1e94589de54d
parent f7fa0d1ab54fd93ee16cbe0e81b445d0b9e0416c
2 files changed +7 -6
modified crates/radicle-cli/src/commands/sync/args.rs
@@ -111,8 +111,9 @@ pub(super) struct SyncArgs {
        value_name = "COUNT",
        value_parser = replicas_non_zero,
        conflicts_with = "inventory",
+
        default_value_t = radicle::node::sync::DEFAULT_REPLICATION_FACTOR,
    )]
-
    replicas: Option<usize>,
+
    replicas: usize,

    /// Synchronize with an upper bound number of seeds
    ///
@@ -150,10 +151,8 @@ impl SyncArgs {

    fn replication(&self) -> sync::ReplicationFactor {
        match (self.replicas, self.max_replicas) {
-
            (None, None) => sync::ReplicationFactor::default(),
-
            (None, Some(min)) => sync::ReplicationFactor::must_reach(min),
-
            (Some(min), None) => sync::ReplicationFactor::must_reach(min),
-
            (Some(min), Some(max)) => sync::ReplicationFactor::range(min, max),
+
            (min, None) => sync::ReplicationFactor::must_reach(min),
+
            (min, Some(max)) => sync::ReplicationFactor::range(min, max),
        }
    }
}
modified crates/radicle/src/node/sync.rs
@@ -11,6 +11,8 @@ use crate::prelude::Doc;

use super::NodeId;

+
pub const DEFAULT_REPLICATION_FACTOR: usize = 3;
+

/// A set of nodes that form a private network for fetching from.
///
/// This could be the set of allowed nodes for a private repository, using
@@ -72,7 +74,7 @@ pub struct ReplicationRange {

impl Default for ReplicationFactor {
    fn default() -> Self {
-
        Self::must_reach(3)
+
        Self::must_reach(DEFAULT_REPLICATION_FACTOR)
    }
}