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

Method import_snapshot

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

Import a Loro snapshot from a remote replica. After merging the snapshot, `generator.observe(remote_hlc)` is called so the local generator incorporates the remote clock. A fresh `schema_hlc` is then generated via `generator.next()` so that any subsequent local writes have an HLC strictly greater than `remote_hlc`.

(
        &mut self,
        bytes: &[u8],
        remote_hlc: Hlc,
        generator: &HlcGenerator,
    )

Source from the content-addressed store, hash-verified

122 /// subsequent local writes have an HLC strictly greater than
123 /// `remote_hlc`.
124 pub fn import_snapshot(
125 &mut self,
126 bytes: &[u8],
127 remote_hlc: Hlc,
128 generator: &HlcGenerator,
129 ) -> ArrayResult<()> {
130 let loro_bytes = strip_envelope(bytes)?;
131 self.doc
132 .import(loro_bytes)
133 .map_err(|e| ArrayError::LoroError {
134 detail: format!("loro import failed: {e}"),
135 })?;
136 generator.observe(remote_hlc)?;
137 self.schema_hlc = generator.next()?;
138 Ok(())
139 }
140
141 /// Import a Loro snapshot from a Raft-committed entry.
142 ///

Calls 4

strip_envelopeFunction · 0.85
importMethod · 0.45
observeMethod · 0.45
nextMethod · 0.45

Tested by 4

import_garbage_errorsFunction · 0.36