1pub mod raw;
10pub mod rawkey;
12
13pub type DagMapId = [u8];
15
16pub fn gen_dag_map_id_num() -> u128 {
21 use crate::{Orphan, ValueEnDe};
22 use parking_lot::Mutex;
23 use ruc::*;
24 use std::{fs, io::ErrorKind, sync::LazyLock};
25
26 static ID_NUM: LazyLock<Mutex<Orphan<u128>>> = LazyLock::new(|| {
27 let mut meta_path = vsdb_core::vsdb_get_custom_dir().to_owned();
28 meta_path.push("id_num");
29
30 match fs::read(&meta_path) {
31 Ok(m) => Mutex::new(ValueEnDe::decode(&m).unwrap()),
32 Err(e) => match e.kind() {
33 ErrorKind::NotFound => {
34 let i = Orphan::new(0);
35 fs::write(&meta_path, i.encode()).unwrap();
36 Mutex::new(i)
37 }
38 _ => {
39 pnk!(Err(eg!("Error!")))
40 }
41 },
42 }
43 });
44
45 let mut hdr = ID_NUM.lock();
46 let mut hdr = hdr.get_mut();
47 *hdr += 1;
48 *hdr
49}