Skip to content

Commit

Permalink
fix: change metadata exchange interval to 5 seconds (#205)
Browse files Browse the repository at this point in the history
  • Loading branch information
stringhandler authored Dec 5, 2024
1 parent de3adbb commit ced846f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/server/p2p/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ pub(crate) struct Config {
pub user_agent: String,
pub grey_list_clear_interval: Duration,
pub black_list_clear_interval: Duration,
pub sync_interval: Duration,
pub chain_height_exchange_interval: Duration,
pub is_seed_peer: bool,
pub debug_print_chain: bool,
pub sync_job_enabled: bool,
Expand All @@ -186,7 +186,7 @@ impl Default for Config {
user_agent: "tari-p2pool".to_string(),
grey_list_clear_interval: Duration::from_secs(60 * 15),
black_list_clear_interval: Duration::from_secs(60 * 60),
sync_interval: Duration::from_secs(30),
chain_height_exchange_interval: Duration::from_secs(5),
is_seed_peer: false,
debug_print_chain: false,
sync_job_enabled: true,
Expand Down Expand Up @@ -1927,8 +1927,8 @@ where S: ShareChain

let mut black_list_clear_interval = tokio::time::interval(self.config.black_list_clear_interval);
black_list_clear_interval.set_missed_tick_behavior(MissedTickBehavior::Skip);
let mut sync_interval = tokio::time::interval(self.config.sync_interval);
sync_interval.set_missed_tick_behavior(MissedTickBehavior::Skip);
let mut chain_height_exchange_interval = tokio::time::interval(self.config.chain_height_exchange_interval);
chain_height_exchange_interval.set_missed_tick_behavior(MissedTickBehavior::Skip);

let mut whitelist_save_interval = tokio::time::interval(Duration::from_secs(60));
whitelist_save_interval.set_missed_tick_behavior(MissedTickBehavior::Skip);
Expand All @@ -1951,7 +1951,7 @@ where S: ShareChain
tokio::pin!(shutdown_signal);
tokio::pin!(grey_list_clear_interval);
tokio::pin!(black_list_clear_interval);
tokio::pin!(sync_interval);
tokio::pin!(chain_height_exchange_interval);
tokio::pin!(whitelist_save_interval);
tokio::pin!(connection_stats_publish);
tokio::pin!(seek_connections_interval);
Expand Down Expand Up @@ -2052,7 +2052,7 @@ where S: ShareChain
warn!(target: LOG_TARGET, "Peer info publishing took too long: {:?}", timer.elapsed());
}
},
_ = sync_interval.tick() => {
_ = chain_height_exchange_interval.tick() => {
let timer = Instant::now();
if !self.config.is_seed_peer && self.config.sync_job_enabled {
for peer in self.swarm.connected_peers().copied().collect::<Vec::<_>>() {
Expand All @@ -2076,7 +2076,7 @@ where S: ShareChain
// self.try_sync_from_best_peer().await;
}
if timer.elapsed() > MAX_ACCEPTABLE_NETWORK_EVENT_TIMEOUT {
warn!(target: LOG_TARGET, "Syncing took too long: {:?}", timer.elapsed());
warn!(target: LOG_TARGET, "Chain height exchange took too long: {:?}", timer.elapsed());
}
},
_ = whitelist_save_interval.tick() => {
Expand Down Expand Up @@ -2160,11 +2160,11 @@ where S: ShareChain
for b in blocks {
file.write_all(
format!(
"B{} [label=\"{} - {} ({}) {}\"]\n",
"B{} [label=\"{} - {} {}{}\"]\n",
&b.hash.to_hex()[0..8],
&b.height,
&b.hash.to_hex()[0..8],
if b.verified { "v" } else { "x" },
if b.verified { "" } else { "UNVERIFIED " },
formatter.format(b.target_difficulty().as_u64() as f64)
)
.as_bytes(),
Expand Down

0 comments on commit ced846f

Please sign in to comment.