From 6d128ad96ef165eb9781677b2659fcdfcfdee0b2 Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 24 Oct 2026 21:27:01 +0200 Subject: add votes register --- src/remake/local.rs | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'src/remake/local.rs') diff --git a/src/remake/local.rs b/src/remake/local.rs index ec2f70a..0d6c6c7 100644 --- a/src/remake/local.rs +++ b/src/remake/local.rs @@ -17,12 +17,23 @@ use super::records::{Retention, unix_millis}; use super::snapshot::Snapshot; use crate::document::replica::Epoch; -#[derive(Default)] pub(crate) struct RemakeState { + /// When this node started (Unix milliseconds): votes it cast before may be lost + /// (`vote`). + started_at: u64, // A std mutex: every access is short and never spans an await. inner: Mutex, } +impl Default for RemakeState { + fn default() -> Self { + Self { + started_at: unix_millis(), + inner: Mutex::default(), + } + } +} + #[derive(Default)] struct Inner { /// Built by the coordinator at commit time; consumed by the local switch. @@ -130,6 +141,10 @@ pub(crate) struct ArchivedEpoch { } impl RemakeState { + pub(crate) fn started_at(&self) -> u64 { + self.started_at + } + fn lock(&self) -> MutexGuard<'_, Inner> { self.inner .lock() -- cgit v1.3.1