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

Function write_disk_cache

bridge/src/utils.rs:106–116  ·  view source on GitHub ↗
(file_path: &Path, data: &impl Encode)

Source from the content-addressed store, hash-verified

104}
105
106pub fn write_disk_cache(file_path: &Path, data: &impl Encode) -> std::io::Result<()> {
107 println!("Writing cache to {}...", file_path.display());
108 if let Some(parent) = file_path.parent() {
109 if !parent.exists() {
110 std::fs::create_dir_all(parent)?;
111 }
112 }
113 let encoded_data = bitcode::encode(data);
114 let compressed_data = compress(&encoded_data, DEFAULT_COMPRESSION_LEVEL)?;
115 std::fs::write(file_path, compressed_data)
116}
117
118pub fn read_disk_cache<T>(file_path: &Path) -> std::io::Result<T>
119where

Callers 2

lock_scripts_bytesMethod · 0.85

Calls 1

compressFunction · 0.70

Tested by 1