mirror of
https://github.com/darkrenaissance/darkfi.git
synced 2026-04-28 03:00:18 -04:00
Add skeleton for sled blockchain store.
This commit is contained in:
@@ -200,6 +200,10 @@ blockchain = [
|
||||
"net",
|
||||
]
|
||||
|
||||
blockchain2 = [
|
||||
"sled",
|
||||
]
|
||||
|
||||
system = [
|
||||
"fxhash",
|
||||
"rand",
|
||||
|
||||
12
src/blockchain2/blockstore.rs
Normal file
12
src/blockchain2/blockstore.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use crate::Result;
|
||||
|
||||
const SLED_BLOCK_TREE: &[u8] = b"_blocks";
|
||||
|
||||
pub struct BlockStore(sled::Tree);
|
||||
|
||||
impl BlockStore {
|
||||
pub fn new(db: &sled::Db) -> Result<Self> {
|
||||
let tree = db.open_tree(SLED_BLOCK_TREE)?;
|
||||
Ok(Self(tree))
|
||||
}
|
||||
}
|
||||
4
src/blockchain2/mod.rs
Normal file
4
src/blockchain2/mod.rs
Normal file
@@ -0,0 +1,4 @@
|
||||
pub mod blockstore;
|
||||
pub mod nfstore;
|
||||
pub mod rootstore;
|
||||
pub mod txstore;
|
||||
12
src/blockchain2/nfstore.rs
Normal file
12
src/blockchain2/nfstore.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use crate::Result;
|
||||
|
||||
const SLED_NULLIFIER_TREE: &[u8] = b"_nullifiers";
|
||||
|
||||
pub struct NullifierStore(sled::Tree);
|
||||
|
||||
impl NullifierStore {
|
||||
pub fn new(db: &sled::Db) -> Result<Self> {
|
||||
let tree = db.open_tree(SLED_NULLIFIER_TREE)?;
|
||||
Ok(Self(tree))
|
||||
}
|
||||
}
|
||||
12
src/blockchain2/rootstore.rs
Normal file
12
src/blockchain2/rootstore.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use crate::Result;
|
||||
|
||||
const SLED_ROOTS_TREE: &[u8] = b"_merkleroots";
|
||||
|
||||
pub struct RootStore(sled::Tree);
|
||||
|
||||
impl RootStore {
|
||||
pub fn new(db: &sled::Db) -> Result<Self> {
|
||||
let tree = db.open_tree(SLED_ROOTS_TREE)?;
|
||||
Ok(Self(tree))
|
||||
}
|
||||
}
|
||||
12
src/blockchain2/txstore.rs
Normal file
12
src/blockchain2/txstore.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
use crate::Result;
|
||||
|
||||
const SLED_TX_TREE: &[u8] = b"_transactions";
|
||||
|
||||
pub struct TxStore(sled::Tree);
|
||||
|
||||
impl TxStore {
|
||||
pub fn new(db: &sled::Db) -> Result<Self> {
|
||||
let tree = db.open_tree(SLED_TX_TREE)?;
|
||||
Ok(Self(tree))
|
||||
}
|
||||
}
|
||||
@@ -218,6 +218,10 @@ pub enum Error {
|
||||
#[cfg(feature = "wasm-runtime")]
|
||||
#[error("wasm runtime out of memory")]
|
||||
WasmerOomError,
|
||||
|
||||
#[cfg(feature = "blockchain2")]
|
||||
#[error(transparent)]
|
||||
SledError(#[from] sled::Error),
|
||||
}
|
||||
|
||||
#[cfg(feature = "node")]
|
||||
|
||||
@@ -4,6 +4,9 @@ pub use error::{Error, Result};
|
||||
#[cfg(feature = "blockchain")]
|
||||
pub mod blockchain;
|
||||
|
||||
#[cfg(feature = "blockchain2")]
|
||||
pub mod blockchain2;
|
||||
|
||||
#[cfg(feature = "blockchain")]
|
||||
pub mod consensus;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user