Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions configs/network_config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"object_expiry": 300,
"pingout_duration": 240,

"opers": [
{
Expand Down
3 changes: 3 additions & 0 deletions sable_network/src/network/config/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ pub struct NetworkConfig {
pub alias_users: Vec<AliasUser>,

pub object_expiry: i64,
/// How long from sending a server ping before we force it to quit from the network
pub pingout_duration: i64,
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand All @@ -42,6 +44,7 @@ impl NetworkConfig {
default_roles: HashMap::new(),
alias_users: Vec::new(),
object_expiry: 0,
pingout_duration: 240,
}
}
}
4 changes: 1 addition & 3 deletions sable_network/src/node/pings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@ use wrapper::ObjectWrapper as _;

use super::*;

const PINGOUT_DURATION: i64 = 240;

impl<Policy: crate::policy::PolicyService> NetworkNode<Policy> {
pub(super) fn check_pings(&self) {
let now = utils::now();
Expand All @@ -13,7 +11,7 @@ impl<Policy: crate::policy::PolicyService> NetworkNode<Policy> {

for server in self.net.read().servers() {
let last_ping = server.last_ping();
if now - last_ping > PINGOUT_DURATION {
if now - last_ping > self.net.read().config().pingout_duration {
let data = server.raw();
tracing::info!(?last_ping, ?now, ?data, "Pinging out server");

Expand Down
1 change: 1 addition & 0 deletions sable_network/tests/utils/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ pub fn empty_network_config() -> NetworkConfig {
default_roles: HashMap::new(),
alias_users: Vec::new(),
object_expiry: 0,
pingout_duration: 240,
}
}

Expand Down
Loading