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

Method set_encryption_key

nodedb-wal/src/uring_writer.rs:128–140  ·  view source on GitHub ↗

Set the encryption key for WAL-at-rest encryption. Writes the 16-byte WAL preamble at the head of the segment. Must be called before the first `append`.

(&mut self, key: crate::crypto::WalEncryptionKey)

Source from the content-addressed store, hash-verified

126 /// Writes the 16-byte WAL preamble at the head of the segment.
127 /// Must be called before the first `append`.
128 pub fn set_encryption_key(&mut self, key: crate::crypto::WalEncryptionKey) -> Result<()> {
129 if self.file_offset != 0 || !self.buffer.is_empty() {
130 return Err(WalError::EncryptionError {
131 detail: "set_encryption_key must be called before writing any records".into(),
132 });
133 }
134 let epoch = *key.epoch();
135 let preamble = crate::preamble::SegmentPreamble::new_wal(epoch);
136 self.buffer.write(&preamble.to_bytes());
137 self.segment_preamble = Some(preamble);
138 self.encryption_key = Some(key);
139 Ok(())
140 }
141
142 /// Append a record to the in-memory buffer. Returns the assigned LSN.
143 ///

Callers

nothing calls this directly

Calls 4

is_emptyMethod · 0.45
epochMethod · 0.45
writeMethod · 0.45
to_bytesMethod · 0.45

Tested by

no test coverage detected