MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / record

Method record

nodedb/src/control/array_sync/ack_registry.rs:184–202  ·  view source on GitHub ↗

Record an ack from `replica_id` for `array` at `ack_hlc`. Monotonically advances the stored value — older acks are ignored. Persists the updated HLC immediately.

(&self, array: &str, replica_id: ReplicaId, ack_hlc: Hlc)

Source from the content-addressed store, hash-verified

182 /// Monotonically advances the stored value — older acks are ignored.
183 /// Persists the updated HLC immediately.
184 pub fn record(&self, array: &str, replica_id: ReplicaId, ack_hlc: Hlc) {
185 {
186 let mut cache = self.cache.write().unwrap_or_else(|p| p.into_inner());
187 cache
188 .entry(array.to_owned())
189 .or_default()
190 .record(replica_id, ack_hlc);
191 }
192 // Persist outside the write-lock to avoid holding it across I/O.
193 if let Some(key) = ack_key(array, replica_id.as_u64())
194 && let Err(e) = self.persist_row(&key, ack_hlc)
195 {
196 warn!(
197 array = %array,
198 error = %e,
199 "ack_registry: persist failed — in-memory ack advanced but disk not updated"
200 );
201 }
202 }
203
204 fn persist_row(&self, key: &[u8], hlc: Hlc) -> crate::Result<()> {
205 let txn = self.db.begin_write().map_err(|e| crate::Error::Storage {

Callers 6

load_cacheMethod · 0.45
single_replica_ackFunction · 0.45
ack_is_monotonicFunction · 0.45
known_arraysFunction · 0.45
handle_ackMethod · 0.45

Calls 5

ack_keyFunction · 0.85
entryMethod · 0.80
persist_rowMethod · 0.80
writeMethod · 0.45
as_u64Method · 0.45

Tested by 4

single_replica_ackFunction · 0.36
ack_is_monotonicFunction · 0.36
known_arraysFunction · 0.36