MCPcopy Create free account
hub / github.com/BitVM/BitVM / read_disk_cache

Function read_disk_cache

bridge/src/utils.rs:118–128  ·  view source on GitHub ↗
(file_path: &Path)

Source from the content-addressed store, hash-verified

116}
117
118pub fn read_disk_cache<T>(file_path: &Path) -> std::io::Result<T>
119where
120 T: for<'de> Decode<'de>,
121{
122 println!("Reading cache from {}...", file_path.display());
123 let compressed_data = std::fs::read(file_path)?;
124 let encoded_data: Vec<u8> = decompress(&compressed_data)?;
125 let decoded = bitcode::decode(&encoded_data).map_err(std::io::Error::other)?;
126
127 Ok(decoded)
128}
129
130pub fn cleanup_cache_files(prefix: &str, cache_location: &Path, max_cache_files: u32) {
131 let mut paths: Vec<PathBuf> = std::fs::read_dir(cache_location)

Callers 2

lock_scripts_bytesMethod · 0.85

Calls 1

decompressFunction · 0.85

Tested by 1