summaryrefslogtreecommitdiffstats
path: root/src/node.rs
diff options
context:
space:
mode:
authortv <tv@krebsco.de>2026-10-25 23:00:56 +0100
committertv <tv@krebsco.de>2026-10-25 23:00:56 +0100
commit539f84c217aec506c894379643e97c20624dc72c (patch)
tree4cc71b5c3282f589144a02d9a4bf236ccc9cec57 /src/node.rs
parentea0b45fd82d421c97cd3a52c75979adae97678b0 (diff)
add clock module
The Clock module is the system clock that every unix timestamp new goes through. It comes with an offset that only tests can set.
Diffstat (limited to 'src/node.rs')
-rw-r--r--src/node.rs6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/node.rs b/src/node.rs
index 57d961c..5005d30 100644
--- a/src/node.rs
+++ b/src/node.rs
@@ -12,6 +12,7 @@ use automerge::{ActorId, AutoCommit};
use tokio::sync::{RwLock, broadcast, mpsc, watch};
use tracing::trace;
+use crate::clock::Clock;
use crate::document::file::DocumentFile;
use crate::document::replica::{Epoch, Replica};
use crate::files::Files;
@@ -46,6 +47,8 @@ pub(crate) struct NodeConfig {
pub(crate) document_file: Option<Arc<DocumentFile>>,
/// For `GET /admin/config`.
pub(crate) config_report: serde_json::Value,
+ /// The node's wall clock; `Clock::default()` outside tests.
+ pub(crate) clock: Arc<Clock>,
}
/// A built node whose workers haven't started yet.
@@ -91,7 +94,7 @@ impl Node {
initial_sync_done: Arc::new(AtomicBool::new(false)),
change_events,
timing: config.timing,
- remake: Arc::new(remake::RemakeState::default()),
+ remake: Arc::new(remake::RemakeState::new(config.clock.now_millis())),
swarm_key: config.swarm_key,
run_id: uuid::Uuid::new_v4().into_bytes(),
neighbours_k: config.neighbours_k,
@@ -114,6 +117,7 @@ impl Node {
catch_up_source: Default::default(),
catch_up_preference: Default::default(),
catch_up_avoided: Default::default(),
+ clock: config.clock,
};
for actor in config.earlier_actors {
state.remake.add_own_actor(actor);