skip timeout offset for the first element in the ban index

This commit is contained in:
yggverse 2025-08-14 02:03:47 +03:00
parent f903d1e83f
commit 2486dabb38

View file

@ -47,7 +47,11 @@ impl Ban {
/// * return expiration time /// * return expiration time
pub fn add(&mut self, key: Id20) -> DateTime<Local> { pub fn add(&mut self, key: Id20) -> DateTime<Local> {
let t = self.index.values().max().map_or(Local::now(), |t| *t) + self.timeout; let t = self
.index
.values()
.max()
.map_or(Local::now(), |t| *t + self.timeout);
assert!(self.index.insert(key, t).is_none()); assert!(self.index.insert(key, t).is_none());
t t
} }