Skip to content

Commit

Permalink
redb setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Gua00va committed Jun 24, 2023
1 parent cc780aa commit c9d8ef0
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 1 deletion.
26 changes: 26 additions & 0 deletions Cargo.lock

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

4 changes: 3 additions & 1 deletion slasher/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ authors = ["Michael Sproul <michael@sigmaprime.io>"]
edition = "2021"

[features]
default = ["lmdb"]
default = ["redb"]
mdbx = ["dep:mdbx"]
lmdb = ["lmdb-rkv", "lmdb-rkv-sys"]
redb = ["dep:redb"]

[dependencies]
bincode = "1.3.1"
Expand Down Expand Up @@ -35,6 +36,7 @@ strum = { version = "0.24.1", features = ["derive"] }
mdbx = { package = "libmdbx", git = "https://github.com/sigp/libmdbx-rs", tag = "v0.1.4", optional = true }
lmdb-rkv = { git = "https://github.com/sigp/lmdb-rs", rev = "f33845c6469b94265319aac0ed5085597862c27e", optional = true }
lmdb-rkv-sys = { git = "https://github.com/sigp/lmdb-rs", rev = "f33845c6469b94265319aac0ed5085597862c27e", optional = true }
redb = { git = "https://github.com/Gua00va/redb", rev = "93280c5", optional = true }

[dev-dependencies]
maplit = "1.0.2"
Expand Down
1 change: 1 addition & 0 deletions slasher/src/database.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
pub mod interface;
mod lmdb_impl;
mod mdbx_impl;
mod redb_impl;

use crate::{
metrics, AttesterRecord, AttesterSlashingStatus, CompactAttesterRecord, Config, Error,
Expand Down
2 changes: 2 additions & 0 deletions slasher/src/database/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ use std::path::PathBuf;
use crate::database::lmdb_impl;
#[cfg(feature = "mdbx")]
use crate::database::mdbx_impl;
#[cfg(feature = "redb")]
use crate::database::redb_impl;

#[derive(Debug)]
pub enum Environment {
Expand Down
30 changes: 30 additions & 0 deletions slasher/src/database/redb_impl.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#![cfg(feature = "redb")]

use std::marker::PhantomData;
use crate::config::{Config};

pub struct Builder {
builder: redb::Builder,
}

#[derive(Debug)]
pub struct Database<'db> {
db: redb::Database,
_phantom: PhantomData<&'db ()>
}

pub struct WriteTransaction<'db> {
txn: redb::WriteTransaction<'db>,
}

pub struct Table<'db, 'txn, K: redb::RedbKey + 'static, V: redb::RedbValue + 'static> {
table: redb::Table<'db, 'txn, K, V>
}

impl Builder {
pub fn new(config: &Config) -> Builder {
let builder = redb::Builder::new();

Builder{ builder }
}
}

0 comments on commit c9d8ef0

Please sign in to comment.