1#![allow(warnings)]
2#![crate_type = "lib"]
20
21pub mod database;
22pub mod keys;
23pub mod scanner;
24pub mod csv_loader;
25pub mod utils;
26pub mod utxo;
27#[allow(missing_docs)]
28
29use lazy_static::lazy_static; use std::fs;
31use std::path::Path;
32use std::sync::Mutex;
33use crate::scanner::Stats;
34use std::collections::BTreeMap;
35
36lazy_static! {
37 static ref BITCOIN_DATADIR: Mutex<String> = Mutex::new("".to_string());
38}
39pub fn scan(bitcoin_datadir: &str, create_rocksdb: bool, csv_file: Option<&str>, testnet: bool) -> Stats {
44 *BITCOIN_DATADIR.lock().unwrap() = bitcoin_datadir
45 .to_string()
46 .trim_end_matches("/")
47 .to_string();
48
49 let stats = scanner::scan(create_rocksdb, csv_file, testnet);
50 stats
51}
52
53pub fn reset_rocksdb(bitcoin_datadir: &str) {
55 let dirname = format!("{}/rocksdb", bitcoin_datadir.trim_end_matches("/"));
57 if !Path::new(&dirname).exists() {
58 return;
59 }
60
61 match fs::remove_dir_all(&dirname) {
63 Ok(_dir) => {}
64 Err(e) => panic!("Unable to remove directory at {}, error: {}.", dirname, e),
65 };
66}
67
68
69pub fn load_from_csv(csv_file: &str) -> BTreeMap<String, Vec<u64>> {
72 let map = csv_loader::load(csv_file);
73 map
74}
75
76