Add initial (#1)

This commit is contained in:
Dave Gallant
2020-06-21 02:20:36 -04:00
committed by GitHub
parent 966478aece
commit d6c5b13f67
13 changed files with 2133 additions and 1 deletions

23
src/db.rs Normal file
View File

@@ -0,0 +1,23 @@
pub fn hash_exists(hash: &str) -> bool {
let tree = sled::open("./deals_db").expect("open");
let result = tree.get(hash);
if result.is_err() {
error!("{:?}", &result);
}
if result == Ok(None) {
return false;
}
true
}
pub fn insert(hash: &str) {
let tree = sled::open("./deals_db").expect("open");
let result = tree.insert(&hash, "");
if result.is_err() {
error!("{:?}", &result);
}
let result = tree.flush();
if result.is_err() {
error!("{:?}", &result);
}
}