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

Method truncate_from

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

Truncate entries from `index` onward (inclusive).

(&mut self, index: u64)

Source from the content-addressed store, hash-verified

130
131 /// Truncate entries from `index` onward (inclusive).
132 fn truncate_from(&mut self, index: u64) {
133 if index <= self.snapshot_index {
134 return;
135 }
136 let offset = (index - self.snapshot_index - 1) as usize;
137 self.entries.truncate(offset);
138 let _ = self.storage.truncate(index);
139 }
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) {

Callers 1

append_entriesMethod · 0.80

Calls 1

truncateMethod · 0.45

Tested by

no test coverage detected