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

Method apply_snapshot

nodedb-raft/src/log.rs:142–153  ·  view source on GitHub ↗

Apply a snapshot: discard all entries up to `last_included_index`.

(&mut self, last_included_index: u64, last_included_term: u64)

Source from the content-addressed store, hash-verified

140
141 /// Apply a snapshot: discard all entries up to `last_included_index`.
142 pub fn apply_snapshot(&mut self, last_included_index: u64, last_included_term: u64) {
143 // Remove entries already covered by the snapshot.
144 if last_included_index > self.snapshot_index {
145 let new_start = last_included_index + 1;
146 self.entries.retain(|e| e.index >= new_start);
147 self.snapshot_index = last_included_index;
148 self.snapshot_term = last_included_term;
149 let _ = self
150 .storage
151 .compact(last_included_index, last_included_term);
152 }
153 }
154
155 pub fn snapshot_index(&self) -> u64 {
156 self.snapshot_index

Calls 1

compactMethod · 0.45