diff options
| author | tv <tv@krebsco.de> | 2026-10-26 05:38:41 +0100 |
|---|---|---|
| committer | tv <tv@krebsco.de> | 2026-10-26 05:38:41 +0100 |
| commit | f12a839d6e6bdd29a86ac52d5de836519a41aaf0 (patch) | |
| tree | b34da34a22292793c991b15a95908f6cd78bb70b /src/remake/catchup.rs | |
| parent | 504435444c65efc59c0f7c6881991296258538a7 (diff) | |
wrap unix timestamps in newtype
Diffstat (limited to 'src/remake/catchup.rs')
| -rw-r--r-- | src/remake/catchup.rs | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/remake/catchup.rs b/src/remake/catchup.rs index 405b9f9..b00a210 100644 --- a/src/remake/catchup.rs +++ b/src/remake/catchup.rs @@ -41,6 +41,7 @@ use super::kind::Translator; use super::local::{CatchUp, LocalStatus, Rejoin}; use super::quarantine; use super::snapshot::{self, EpochMetadata}; +use crate::clock::UnixMillis; use crate::document::replica::Epoch; /// Pause before trying the same target again after a failed rejoin. @@ -412,7 +413,7 @@ fn prepare( previous: Epoch, target: Epoch, mut own: Vec<ActorId>, - now: u64, + now: UnixMillis, ) -> Prepared { if copy.get_change_by_hash(&ChangeHash(target.id)).is_none() { return Prepared::NotYet(old); @@ -486,7 +487,7 @@ fn prepare( ), }, (Some(next), Ok(translator)) => { - let away_ms = now.saturating_sub(next.proposed_at); + let away_ms = now.ms_since(next.proposed_at); if next.policy.replay_window.covers(gap, away_ms) { Plan::Replay(paths, translator) } else { @@ -570,7 +571,7 @@ mod tests { previous: Epoch::GENESIS, base_heads: &base, policy, - proposed_at: 0, + proposed_at: UnixMillis(0), kind: "compact", content: None, translation: &JsonValue::Null, @@ -591,7 +592,14 @@ mod tests { #[test] fn replays_within_the_window() { let (old, swarm, target) = scenario(&json!({})); - match prepare(swarm, old, Epoch::GENESIS, target, Vec::new(), 0) { + match prepare( + swarm, + old, + Epoch::GENESIS, + target, + Vec::new(), + UnixMillis(0), + ) { Prepared::Ready { plan: Plan::Replay(paths, _), own_missing, @@ -607,7 +615,14 @@ mod tests { #[test] fn quarantines_outside_the_window() { let (old, swarm, target) = scenario(&json!({ "replayWindow": { "epochs": 0 } })); - match prepare(swarm, old, Epoch::GENESIS, target, Vec::new(), 0) { + match prepare( + swarm, + old, + Epoch::GENESIS, + target, + Vec::new(), + UnixMillis(0), + ) { Prepared::Ready { plan: Plan::Quarantine { paths, .. }, .. @@ -626,7 +641,7 @@ mod tests { Epoch::GENESIS, target, Vec::new(), - 0 + UnixMillis(0) ), Prepared::Ready { plan: Plan::Nothing, @@ -646,7 +661,7 @@ mod tests { Epoch::GENESIS, target, Vec::new(), - 0 + UnixMillis(0) ), Prepared::NotYet(_) )); |
