From 1202c0ba9bf49e7e31492c90b37af3e6c91b98b7 Mon Sep 17 00:00:00 2001 From: tv Date: Sun, 1 Nov 2026 13:34:26 +0100 Subject: state: drop epoch_tx The stamp is the only lock-free epoch label. --- src/state/mod.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/state/mod.rs') diff --git a/src/state/mod.rs b/src/state/mod.rs index 9ee08b7..5e4a4d3 100644 --- a/src/state/mod.rs +++ b/src/state/mod.rs @@ -59,10 +59,9 @@ pub(crate) struct AppState { /// The document and its epoch. Derefs to `Document`. pub(crate) doc: Arc, - /// Copy of `doc.epoch` for cheap, lock-free reads (handshakes, keepalives, /peers). - /// Only ever changed while holding `doc`'s write lock, together with `doc.epoch`. - pub(crate) epoch_tx: watch::Sender, - /// `doc`'s epoch label and heads, readable without its lock (`Replica::stamps`). + /// `doc`'s epoch label and heads, readable without its lock (`Replica::stamps`): + /// for cheap reads (handshakes, keepalives, /peers). Only ever changed while holding + /// `doc`'s write lock, together with `doc.epoch`. pub(crate) stamp: watch::Receiver, pub(crate) lifecycle: Arc>, @@ -231,7 +230,7 @@ impl AppState { /// The local epoch. Code that labels or applies sync messages must use the epoch /// of the locked `Replica` instead, so label and document can't disagree. pub(crate) fn local_epoch(&self) -> Epoch { - *self.epoch_tx.borrow() + self.stamp.borrow().epoch } /// The local epoch and `Replica::epoch_seq`, read together, without waiting for the -- cgit v1.3.1