Skip to content

Commit

Permalink
fix(rln): use config.open instead of sled::open
Browse files Browse the repository at this point in the history
  • Loading branch information
rymnc committed Aug 24, 2023
1 parent c6c1bfd commit a49f20a
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 23 deletions.
62 changes: 42 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 10 additions & 2 deletions rln/src/pm_tree_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ use std::path::PathBuf;
use std::str::FromStr;

use color_eyre::{Report, Result};
use rand::distributions::Alphanumeric;
use rand::{thread_rng, Rng};
use serde_json::Value;

use utils::pmtree::{Database, Hasher};
Expand Down Expand Up @@ -49,7 +51,13 @@ impl Hasher for PoseidonHash {
}

fn get_tmp_path() -> PathBuf {
std::env::temp_dir().join(format!("pmtree-{}", rand::random::<u64>()))
let rand_dir: String = thread_rng()
.sample_iter(&Alphanumeric)
.take(40)
.map(char::from)
.collect();

std::env::temp_dir().join(format!("pmtree-{}", rand_dir))
}

fn get_tmp() -> bool {
Expand Down Expand Up @@ -103,7 +111,7 @@ impl Default for PmtreeConfig {
let tmp_path = get_tmp_path();
PmtreeConfig(
Config::new()
.temporary(true)
.temporary(false)
.path(tmp_path)
.cache_capacity(150_000)
.mode(Mode::HighThroughput)
Expand Down
2 changes: 1 addition & 1 deletion utils/src/pm_tree/sled_adapter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ impl Database for SledDB {
}

fn load(config: Self::Config) -> PmtreeResult<Self> {
let db: Sled = match sled::open(&config.path) {
let db: Sled = match config.open() {
Ok(db) => db,
Err(e) => {
return Err(PmtreeErrorKind::DatabaseError(
Expand Down

0 comments on commit a49f20a

Please sign in to comment.