mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
chore: make eyre optional in reth-db (#9351)
This commit is contained in:
@ -18,16 +18,19 @@ reth-primitives.workspace = true
|
|||||||
reth-primitives-traits.workspace = true
|
reth-primitives-traits.workspace = true
|
||||||
reth-fs-util.workspace = true
|
reth-fs-util.workspace = true
|
||||||
reth-storage-errors.workspace = true
|
reth-storage-errors.workspace = true
|
||||||
reth-libmdbx = { workspace = true, optional = true, features = [
|
|
||||||
"return-borrowed",
|
|
||||||
"read-tx-timeouts",
|
|
||||||
] }
|
|
||||||
reth-nippy-jar.workspace = true
|
reth-nippy-jar.workspace = true
|
||||||
reth-prune-types.workspace = true
|
reth-prune-types.workspace = true
|
||||||
reth-stages-types.workspace = true
|
reth-stages-types.workspace = true
|
||||||
reth-tracing.workspace = true
|
reth-tracing.workspace = true
|
||||||
reth-trie-common.workspace = true
|
reth-trie-common.workspace = true
|
||||||
|
|
||||||
|
# mdbx
|
||||||
|
reth-libmdbx = { workspace = true, optional = true, features = [
|
||||||
|
"return-borrowed",
|
||||||
|
"read-tx-timeouts",
|
||||||
|
] }
|
||||||
|
eyre = { workspace = true, optional = true }
|
||||||
|
|
||||||
# codecs
|
# codecs
|
||||||
serde = { workspace = true, default-features = false }
|
serde = { workspace = true, default-features = false }
|
||||||
|
|
||||||
@ -41,7 +44,6 @@ page_size = "0.6.0"
|
|||||||
thiserror.workspace = true
|
thiserror.workspace = true
|
||||||
tempfile = { workspace = true, optional = true }
|
tempfile = { workspace = true, optional = true }
|
||||||
derive_more.workspace = true
|
derive_more.workspace = true
|
||||||
eyre.workspace = true
|
|
||||||
paste.workspace = true
|
paste.workspace = true
|
||||||
rustc-hash.workspace = true
|
rustc-hash.workspace = true
|
||||||
sysinfo = { version = "0.30", default-features = false }
|
sysinfo = { version = "0.30", default-features = false }
|
||||||
@ -75,8 +77,8 @@ assert_matches.workspace = true
|
|||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["mdbx"]
|
default = ["mdbx"]
|
||||||
test-utils = ["tempfile", "arbitrary"]
|
mdbx = ["dep:reth-libmdbx", "dep:eyre"]
|
||||||
mdbx = ["reth-libmdbx"]
|
test-utils = ["dep:tempfile", "arbitrary"]
|
||||||
bench = []
|
bench = []
|
||||||
arbitrary = ["reth-primitives/arbitrary", "reth-db-api/arbitrary"]
|
arbitrary = ["reth-primitives/arbitrary", "reth-db-api/arbitrary"]
|
||||||
optimism = []
|
optimism = []
|
||||||
|
|||||||
@ -1,12 +1,12 @@
|
|||||||
//! Bindings for [MDBX](https://libmdbx.dqdkfa.ru/).
|
//! Bindings for [MDBX](https://libmdbx.dqdkfa.ru/).
|
||||||
|
|
||||||
pub use crate::implementation::mdbx::*;
|
|
||||||
pub use reth_libmdbx::*;
|
|
||||||
|
|
||||||
use crate::is_database_empty;
|
use crate::is_database_empty;
|
||||||
use eyre::Context;
|
use eyre::Context;
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
|
|
||||||
|
pub use crate::implementation::mdbx::*;
|
||||||
|
pub use reth_libmdbx::*;
|
||||||
|
|
||||||
/// Creates a new database at the specified path if it doesn't exist. Does NOT create tables. Check
|
/// Creates a new database at the specified path if it doesn't exist. Does NOT create tables. Check
|
||||||
/// [`init_db`].
|
/// [`init_db`].
|
||||||
pub fn create_db<P: AsRef<Path>>(path: P, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
pub fn create_db<P: AsRef<Path>>(path: P, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
||||||
@ -31,21 +31,17 @@ pub fn create_db<P: AsRef<Path>>(path: P, args: DatabaseArguments) -> eyre::Resu
|
|||||||
/// Opens up an existing database or creates a new one at the specified path. Creates tables if
|
/// Opens up an existing database or creates a new one at the specified path. Creates tables if
|
||||||
/// necessary. Read/Write mode.
|
/// necessary. Read/Write mode.
|
||||||
pub fn init_db<P: AsRef<Path>>(path: P, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
pub fn init_db<P: AsRef<Path>>(path: P, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
||||||
{
|
let client_version = args.client_version().clone();
|
||||||
let client_version = args.client_version().clone();
|
let db = create_db(path, args)?;
|
||||||
let db = create_db(path, args)?;
|
db.create_tables()?;
|
||||||
db.create_tables()?;
|
db.record_client_version(client_version)?;
|
||||||
db.record_client_version(client_version)?;
|
Ok(db)
|
||||||
Ok(db)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens up an existing database. Read only mode. It doesn't create it or create tables if missing.
|
/// Opens up an existing database. Read only mode. It doesn't create it or create tables if missing.
|
||||||
pub fn open_db_read_only(path: &Path, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
pub fn open_db_read_only(path: &Path, args: DatabaseArguments) -> eyre::Result<DatabaseEnv> {
|
||||||
{
|
DatabaseEnv::open(path, DatabaseEnvKind::RO, args)
|
||||||
DatabaseEnv::open(path, DatabaseEnvKind::RO, args)
|
.with_context(|| format!("Could not open database at path: {}", path.display()))
|
||||||
.with_context(|| format!("Could not open database at path: {}", path.display()))
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Opens up an existing database. Read/Write mode with `WriteMap` enabled. It doesn't create it or
|
/// Opens up an existing database. Read/Write mode with `WriteMap` enabled. It doesn't create it or
|
||||||
|
|||||||
Reference in New Issue
Block a user