expose setting kademlia replication factor through node CLI (#14391)

* expose kademlia replication factor through node CLI

* set default CLI flag value for kademlia_replication_factor

Co-authored-by: Bastian Köcher <git@kchr.de>

* wrap CLI value as Option

* make kademlia replication factor non-optional

---------

Co-authored-by: Bastian Köcher <git@kchr.de>
This commit is contained in:
klbrvik
2023-06-21 23:21:54 +01:00
committed by GitHub
parent e783d98437
commit 1d2f16ab1f
4 changed files with 36 additions and 1 deletions
@@ -28,7 +28,7 @@ use sc_service::{
config::{Multiaddr, MultiaddrWithPeerId},
ChainSpec, ChainType,
};
use std::{borrow::Cow, path::PathBuf};
use std::{borrow::Cow, num::NonZeroUsize, path::PathBuf};
/// Parameters used to create the network configuration.
#[derive(Debug, Clone, Args)]
@@ -121,6 +121,13 @@ pub struct NetworkParams {
#[arg(long)]
pub kademlia_disjoint_query_paths: bool,
/// Kademlia replication factor determines to how many closest peers a record is replicated to.
///
/// Discovery mechanism requires successful replication to all
/// `kademlia_replication_factor` peers to consider record successfully put.
#[arg(long, default_value = "20")]
pub kademlia_replication_factor: NonZeroUsize,
/// Join the IPFS network and serve transactions over bitswap protocol.
#[arg(long)]
pub ipfs_server: bool,
@@ -233,6 +240,7 @@ impl NetworkParams {
enable_dht_random_walk: !self.reserved_only,
allow_non_globals_in_dht,
kademlia_disjoint_query_paths: self.kademlia_disjoint_query_paths,
kademlia_replication_factor: self.kademlia_replication_factor,
yamux_window_size: None,
ipfs_server: self.ipfs_server,
sync_mode: self.sync.into(),