Checkpoint: serialize all entries for persistence. When `kek` is `Some`, the msgpack payload is wrapped in an AES-256-GCM encrypted SEGV envelope. When `None`, raw msgpack bytes are returned.
(
&self,
kek: Option<&nodedb_wal::crypto::WalEncryptionKey>,
)
| 154 | /// When `kek` is `Some`, the msgpack payload is wrapped in an AES-256-GCM |
| 155 | /// encrypted SEGV envelope. When `None`, raw msgpack bytes are returned. |
| 156 | pub fn checkpoint_to_bytes( |
| 157 | &self, |
| 158 | kek: Option<&nodedb_wal::crypto::WalEncryptionKey>, |
| 159 | ) -> Result<Vec<u8>, crate::persist::RTreeCheckpointError> { |
| 160 | let snap = GeohashSnapshot { |
| 161 | collection: self.collection.clone(), |
| 162 | field: self.field.clone(), |
| 163 | precision: self.precision, |
| 164 | entries: self.entries.clone(), |
| 165 | }; |
| 166 | let msgpack = zerompk::to_msgpack_vec(&snap) |
| 167 | .map_err(crate::persist::RTreeCheckpointError::Serialize)?; |
| 168 | |
| 169 | if let Some(key) = kek { |
| 170 | return crate::persist::encrypt_geohash_payload(key, &msgpack); |
| 171 | } |
| 172 | |
| 173 | Ok(msgpack) |
| 174 | } |
| 175 | |
| 176 | /// Restore from checkpoint. |
| 177 | /// |