mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
fix(libmdbx): Some options can only be set after mdbx_env_open (#11328)
This commit is contained in:
@ -643,8 +643,6 @@ impl EnvironmentBuilder {
|
||||
}
|
||||
for (opt, v) in [
|
||||
(ffi::MDBX_opt_max_db, self.max_dbs),
|
||||
(ffi::MDBX_opt_sync_bytes, self.sync_bytes),
|
||||
(ffi::MDBX_opt_sync_period, self.sync_period),
|
||||
(ffi::MDBX_opt_rp_augment_limit, self.rp_augment_limit),
|
||||
(ffi::MDBX_opt_loose_limit, self.loose_limit),
|
||||
(ffi::MDBX_opt_dp_reserve_limit, self.dp_reserve_limit),
|
||||
@ -698,6 +696,15 @@ impl EnvironmentBuilder {
|
||||
mode,
|
||||
))?;
|
||||
|
||||
for (opt, v) in [
|
||||
(ffi::MDBX_opt_sync_bytes, self.sync_bytes),
|
||||
(ffi::MDBX_opt_sync_period, self.sync_period),
|
||||
] {
|
||||
if let Some(v) = v {
|
||||
mdbx_result(ffi::mdbx_env_set_option(env, opt, v))?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})() {
|
||||
ffi::mdbx_env_close_ex(env, false);
|
||||
|
||||
@ -119,8 +119,11 @@ pub enum Error {
|
||||
/// Read transaction has been timed out.
|
||||
#[error("read transaction has been timed out")]
|
||||
ReadTransactionTimeout,
|
||||
/// Permission defined
|
||||
#[error("permission denied to setup database")]
|
||||
Permission,
|
||||
/// Unknown error code.
|
||||
#[error("unknown error code")]
|
||||
#[error("unknown error code: {0}")]
|
||||
Other(i32),
|
||||
}
|
||||
|
||||
@ -157,6 +160,7 @@ impl Error {
|
||||
ffi::MDBX_EACCESS => Self::Access,
|
||||
ffi::MDBX_TOO_LARGE => Self::TooLarge,
|
||||
ffi::MDBX_EBADSIGN => Self::BadSignature,
|
||||
ffi::MDBX_EPERM => Self::Permission,
|
||||
other => Self::Other(other),
|
||||
}
|
||||
}
|
||||
@ -196,6 +200,7 @@ impl Error {
|
||||
Self::WriteTransactionUnsupportedInReadOnlyMode |
|
||||
Self::NestedTransactionsUnsupportedWithWriteMap => ffi::MDBX_EACCESS,
|
||||
Self::ReadTransactionTimeout => -96000, // Custom non-MDBX error code
|
||||
Self::Permission => ffi::MDBX_EPERM,
|
||||
Self::Other(err_code) => *err_code,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user