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

Function write_scripts_to_separate_files

bitvm/src/chunk/api.rs:431–446  ·  view source on GitHub ↗
(
            sig_cache: HashMap<u32, Vec<ScriptBuf>>,
            file: &str,
        )

Source from the content-addressed store, hash-verified

429 }
430
431 pub fn write_scripts_to_separate_files(
432 sig_cache: HashMap<u32, Vec<ScriptBuf>>,
433 file: &str,
434 ) {
435 let mut buf: HashMap<u32, Vec<Vec<u8>>> = HashMap::new();
436 std::fs::create_dir_all("bridge_data/chunker_data")
437 .expect("Failed to create directory structure");
438
439 for (k, v) in sig_cache {
440 let file = format!("bridge_data/chunker_data/{file}_{k}.json");
441 let vs = v.into_iter().map(|x| x.to_bytes()).collect();
442 buf.insert(k, vs);
443 write_map_to_file(&buf, &file).unwrap();
444 buf.clear();
445 }
446 }
447
448 pub fn read_scripts_from_file(file: &str) -> HashMap<u32, Vec<ScriptBuf>> {
449 let mut scr: HashMap<u32, Vec<ScriptBuf>> = HashMap::new();

Callers 1

test_fn_compileFunction · 0.85

Calls 1

write_map_to_fileFunction · 0.85

Tested by 1

test_fn_compileFunction · 0.68