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

Method import_snapshot_replicated

nodedb-array/src/sync/schema_crdt.rs:151–164  ·  view source on GitHub ↗

Import a Loro snapshot from a Raft-committed entry. Unlike [`import_snapshot`], this method sets `schema_hlc` to exactly `remote_hlc` rather than bumping past it. This is the correct behaviour for Raft replication: every replica must converge to the same* `schema_hlc` after applying the same log entry so that schema-gating checks on ops are consistent across the cluster. Call this only from the

(
        &mut self,
        bytes: &[u8],
        committed_hlc: Hlc,
    )

Source from the content-addressed store, hash-verified

149 /// Call this only from the distributed applier (Raft commit path), not
150 /// from the CRDT sync path where bumping is required.
151 pub fn import_snapshot_replicated(
152 &mut self,
153 bytes: &[u8],
154 committed_hlc: Hlc,
155 ) -> ArrayResult<()> {
156 let loro_bytes = strip_envelope(bytes)?;
157 self.doc
158 .import(loro_bytes)
159 .map_err(|e| ArrayError::LoroError {
160 detail: format!("loro import (replicated) failed: {e}"),
161 })?;
162 self.schema_hlc = committed_hlc;
163 Ok(())
164 }
165
166 /// Replace the stored schema with `schema`.
167 ///

Calls 2

strip_envelopeFunction · 0.85
importMethod · 0.45