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

Method open_encrypted

nodedb/src/wal/manager/encryption.rs:11–28  ·  view source on GitHub ↗

Open with encryption key loaded from a file.

(
        path: &Path,
        use_direct_io: bool,
        key_path: &Path,
    )

Source from the content-addressed store, hash-verified

9impl WalManager {
10 /// Open with encryption key loaded from a file.
11 pub fn open_encrypted(
12 path: &Path,
13 use_direct_io: bool,
14 key_path: &Path,
15 ) -> crate::Result<Self> {
16 let key =
17 nodedb_wal::crypto::WalEncryptionKey::from_file(key_path).map_err(crate::Error::Wal)?;
18 let ring = nodedb_wal::crypto::KeyRing::new(key);
19 let mut mgr = Self::open(path, use_direct_io)?;
20 {
21 let mut wal = mgr.wal.lock().unwrap_or_else(|p| p.into_inner());
22 wal.set_encryption_ring(ring.clone())
23 .map_err(crate::Error::Wal)?;
24 }
25 mgr.encryption_ring = Some(ring);
26 info!(key_path = %key_path.display(), "WAL encryption enabled");
27 Ok(mgr)
28 }
29
30 /// Open with key rotation: current key + previous key for dual-key reads.
31 ///

Callers

nothing calls this directly

Calls 4

lockMethod · 0.80
openFunction · 0.50
set_encryption_ringMethod · 0.45
cloneMethod · 0.45

Tested by

no test coverage detected