Skip to content

Commit

Permalink
Rename to --min-sync-peer-threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
liuchengxu committed Dec 12, 2024
1 parent 62d8f34 commit b31353d
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
6 changes: 3 additions & 3 deletions crates/subcoin-network/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions crates/subcoin-network/src/network_processor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ pub struct Params<Block, Client> {
pub is_major_syncing: Arc<AtomicBool>,
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<dyn PeerStore>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -134,7 +134,7 @@ where
enable_block_sync,
peer_store.clone(),
sync_target,
min_peer_threshold,
min_sync_peer_threshold,
);

Self {
Expand Down
10 changes: 5 additions & 5 deletions crates/subcoin-network/src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ pub(crate) struct ChainSync<Block, Client> {
peer_store: Arc<dyn PeerStore>,
/// Target block of the syncing process.
sync_target: Option<u32>,
min_peer_threshold: usize,
min_sync_peer_threshold: usize,
_phantom: PhantomData<Block>,
}

Expand All @@ -207,7 +207,7 @@ where
enable_block_sync: bool,
peer_store: Arc<dyn PeerStore>,
sync_target: Option<u32>,
min_peer_threshold: usize,
min_sync_peer_threshold: usize,
) -> Self {
Self {
client,
Expand All @@ -221,7 +221,7 @@ where
rng: fastrand::Rng::new(),
peer_store,
sync_target,
min_peer_threshold,
min_sync_peer_threshold,
_phantom: Default::default(),
}
}
Expand Down Expand Up @@ -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;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/subcoin-network/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion crates/subcoin-node/src/cli/subcoin_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand Down
2 changes: 1 addition & 1 deletion crates/subcoin-node/src/commands/run.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b31353d

Please sign in to comment.