Skip to content

Commit

Permalink
Rename DB file to slasher.redb
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelsproul committed Jul 1, 2024
1 parent 9186d18 commit 4c247c3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
1 change: 1 addition & 0 deletions slasher/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ pub const DEFAULT_BACKEND: DatabaseBackend = DatabaseBackend::Disabled;
pub const MAX_HISTORY_LENGTH: usize = 1 << 16;
pub const MEGABYTE: usize = 1 << 20;
pub const MDBX_DATA_FILENAME: &str = "mdbx.dat";
pub const REDB_DATA_FILENAME: &str = "slasher.redb";

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Config {
Expand Down
11 changes: 3 additions & 8 deletions slasher/src/database/redb_impl.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#![cfg(feature = "redb")]
use crate::{
config::REDB_DATA_FILENAME,
database::{
interface::{Key, OpenDatabases, Value},
*,
Expand All @@ -10,8 +11,6 @@ use derivative::Derivative;
use redb::{ReadableTable, TableDefinition};
use std::{borrow::Cow, path::PathBuf};

const BASE_DB: &str = "slasher_db";

#[derive(Debug)]
pub struct Environment {
_db_count: usize,
Expand Down Expand Up @@ -43,12 +42,8 @@ pub struct Cursor<'env> {

impl Environment {
pub fn new(config: &Config) -> Result<Environment, Error> {
let db_path = match config.database_path.join(BASE_DB).as_path().to_str() {
Some(path) => path.to_string(),
None => "".to_string(),
};

let database = redb::Database::create(db_path.clone())?;
let db_path = config.database_path.join(REDB_DATA_FILENAME);
let database = redb::Database::create(db_path)?;

Ok(Environment {
_db_count: MAX_NUM_DBS,
Expand Down

0 comments on commit 4c247c3

Please sign in to comment.