You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ifself.buffer.is_empty(){returnOk(());}// Need more data
53
+
54
+
let version = self.buffer[0];
55
+
if version != 1{
56
+
returnErr(());// Bad Version
57
+
}
58
+
59
+
// Accumulate Header Byte?
60
+
// User: "Running Hash Accumulator... incrementall per applied command"
61
+
// Usually Header is part of the "WAL Log Hash".
62
+
// I will include it.
63
+
self.wal_accumulator.update(&[version]);
64
+
65
+
self.buffer.remove(0);// Inefficient for Vec, but low freq (once).
66
+
self.header_processed = true;
67
+
}
68
+
69
+
ifself.buffer.is_empty(){break;}
70
+
71
+
// 2. Try Apply Command
72
+
// We pass a slice.
73
+
match wal::try_apply_command(self.state,&self.buffer){
74
+
wal::ApplyResult::Applied(bytes_consumed) => {
75
+
// Update Hash with consumed bytes (Command Data)
76
+
let cmd_bytes = &self.buffer[0..bytes_consumed];
77
+
self.wal_accumulator.update(cmd_bytes);
78
+
79
+
// Remove from buffer (inefficient drain from front, use VecDeque if std available, or circular buf if optimization needed. For Phase 4, Vec::drain is acceptable for correctness proof).
80
+
// self.buffer.drain(0..bytes_consumed); // drain returns iterator, drop it.
0 commit comments