From b31353dfd272539812bdf3b7682cf01fd5e63536 Mon Sep 17 00:00:00 2001 From: Liu-Cheng Xu Date: Thu, 12 Dec 2024 11:01:11 +0800 Subject: [PATCH] Rename to --min-sync-peer-threshold --- crates/subcoin-network/src/lib.rs | 6 +++--- crates/subcoin-network/src/network_processor.rs | 6 +++--- crates/subcoin-network/src/sync.rs | 10 +++++----- crates/subcoin-network/src/tests.rs | 2 +- crates/subcoin-node/src/cli/subcoin_params.rs | 2 +- crates/subcoin-node/src/commands/run.rs | 2 +- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/crates/subcoin-network/src/lib.rs b/crates/subcoin-network/src/lib.rs index 32295a1e..b61b5087 100644 --- a/crates/subcoin-network/src/lib.rs +++ b/crates/subcoin-network/src/lib.rs @@ -240,7 +240,7 @@ pub struct Config { /// Maximum number of inbound peer connections. pub max_inbound_peers: usize, /// Minimum peer threshold to start the block sync. - pub min_peer_threshold: usize, + pub min_sync_peer_threshold: usize, /// Persistent peer latency threshold in milliseconds (ms). pub persistent_peer_latency_threshold: u128, /// Major sync strategy. @@ -452,7 +452,7 @@ where network, max_inbound_peers, max_outbound_peers, - min_peer_threshold, + min_sync_peer_threshold, sync_strategy, block_sync, sync_target, @@ -500,7 +500,7 @@ where is_major_syncing, connection_initiator, max_outbound_peers, - min_peer_threshold, + min_sync_peer_threshold, enable_block_sync, peer_store: Arc::new(persistent_peer_store_handle), sync_target, diff --git a/crates/subcoin-network/src/network_processor.rs b/crates/subcoin-network/src/network_processor.rs index 0fb018f3..55fc2e6d 100644 --- a/crates/subcoin-network/src/network_processor.rs +++ b/crates/subcoin-network/src/network_processor.rs @@ -64,7 +64,7 @@ pub struct Params { pub is_major_syncing: Arc, pub connection_initiator: ConnectionInitiator, pub max_outbound_peers: usize, - pub min_peer_threshold: usize, + pub min_sync_peer_threshold: usize, /// Whether to enable block sync on start. pub enable_block_sync: bool, pub peer_store: Arc, @@ -102,7 +102,7 @@ where is_major_syncing, connection_initiator, max_outbound_peers, - min_peer_threshold, + min_sync_peer_threshold, enable_block_sync, peer_store, sync_target, @@ -134,7 +134,7 @@ where enable_block_sync, peer_store.clone(), sync_target, - min_peer_threshold, + min_sync_peer_threshold, ); Self { diff --git a/crates/subcoin-network/src/sync.rs b/crates/subcoin-network/src/sync.rs index 842e55fe..21c7d52d 100644 --- a/crates/subcoin-network/src/sync.rs +++ b/crates/subcoin-network/src/sync.rs @@ -187,7 +187,7 @@ pub(crate) struct ChainSync { peer_store: Arc, /// Target block of the syncing process. sync_target: Option, - min_peer_threshold: usize, + min_sync_peer_threshold: usize, _phantom: PhantomData, } @@ -207,7 +207,7 @@ where enable_block_sync: bool, peer_store: Arc, sync_target: Option, - min_peer_threshold: usize, + min_sync_peer_threshold: usize, ) -> Self { Self { client, @@ -221,7 +221,7 @@ where rng: fastrand::Rng::new(), peer_store, sync_target, - min_peer_threshold, + min_sync_peer_threshold, _phantom: Default::default(), } } @@ -532,11 +532,11 @@ where return SyncAction::None; } - if self.peers.len() < self.min_peer_threshold { + if self.peers.len() < self.min_sync_peer_threshold { tracing::debug!( "Waiting for more sync peers, discovered {} peers, require {} peers", self.peers.len(), - self.min_peer_threshold + self.min_sync_peer_threshold ); return SyncAction::None; } diff --git a/crates/subcoin-network/src/tests.rs b/crates/subcoin-network/src/tests.rs index 6b5061dd..bcea77cc 100644 --- a/crates/subcoin-network/src/tests.rs +++ b/crates/subcoin-network/src/tests.rs @@ -290,7 +290,7 @@ impl TestNode { sync_target: None, max_outbound_peers: 10, max_inbound_peers: 10, - min_peer_threshold: 0, + min_sync_peer_threshold: 0, persistent_peer_latency_threshold: 200, sync_strategy, block_sync: crate::BlockSyncOption::Off, diff --git a/crates/subcoin-node/src/cli/subcoin_params.rs b/crates/subcoin-node/src/cli/subcoin_params.rs index bd0ff6ed..20855c1f 100644 --- a/crates/subcoin-node/src/cli/subcoin_params.rs +++ b/crates/subcoin-node/src/cli/subcoin_params.rs @@ -73,7 +73,7 @@ pub struct NetworkParams { /// The chain sync won't be started until the number of sync peers reaches this threshold. /// Set to `0` to disable the peer threshold limit. Default: 3 #[arg(long, default_value = "3")] - pub min_peer_threshold: usize, + pub min_sync_peer_threshold: usize, } #[derive(Debug, Clone, Parser)] diff --git a/crates/subcoin-node/src/commands/run.rs b/crates/subcoin-node/src/commands/run.rs index 8a154d0c..58efcf14 100644 --- a/crates/subcoin-node/src/commands/run.rs +++ b/crates/subcoin-node/src/commands/run.rs @@ -107,7 +107,7 @@ impl Run { sync_target: self.sync_target, max_outbound_peers: self.network_params.max_outbound_peers, max_inbound_peers: self.network_params.max_inbound_peers, - min_peer_threshold: self.network_params.min_peer_threshold, + min_sync_peer_threshold: self.network_params.min_sync_peer_threshold, persistent_peer_latency_threshold: self .network_params .persistent_peer_latency_threshold,