Skip to content

Commit 71ec784

Browse files
committed
Make pingout_duration configurable
In irctest I use faketime in some tests to make time pass 15 times faster for Sable so it does not have to actually wait a long time for some expiries to occur. Along with Github CI's flakiness, this means that nodes sometimes exceed this timeout and kill each other, so I need it to be higher.
1 parent 85d8591 commit 71ec784

File tree

4 files changed

+6
-3
lines changed

4 files changed

+6
-3
lines changed

configs/network_config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"object_expiry": 300,
3+
"pingout_duration": 240,
34

45
"opers": [
56
{

sable_network/src/network/config/mod.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ pub struct NetworkConfig {
1616
pub alias_users: Vec<AliasUser>,
1717

1818
pub object_expiry: i64,
19+
/// How long from sending a server ping before we force it to quit from the network
20+
pub pingout_duration: i64,
1921
}
2022

2123
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -42,6 +44,7 @@ impl NetworkConfig {
4244
default_roles: HashMap::new(),
4345
alias_users: Vec::new(),
4446
object_expiry: 0,
47+
pingout_duration: 240,
4548
}
4649
}
4750
}

sable_network/src/node/pings.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ use wrapper::ObjectWrapper as _;
22

33
use super::*;
44

5-
const PINGOUT_DURATION: i64 = 240;
6-
75
impl<Policy: crate::policy::PolicyService> NetworkNode<Policy> {
86
pub(super) fn check_pings(&self) {
97
let now = utils::now();
@@ -13,7 +11,7 @@ impl<Policy: crate::policy::PolicyService> NetworkNode<Policy> {
1311

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

sable_network/tests/utils/mod.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ pub fn empty_network_config() -> NetworkConfig {
1111
default_roles: HashMap::new(),
1212
alias_users: Vec::new(),
1313
object_expiry: 0,
14+
pingout_duration: 240,
1415
}
1516
}
1617

0 commit comments

Comments
 (0)