refactor(node-builder): use datadir provided by the config (#8592)

This commit is contained in:
Alexey Shekhirin
2024-06-04 19:46:36 +01:00
committed by GitHub
parent d59fcf5ee2
commit ae9ab69f5f
26 changed files with 71 additions and 116 deletions

View File

@ -81,7 +81,7 @@ impl TableObject for ObjectLength {
impl<const LEN: usize> TableObject for [u8; LEN] {
fn decode(data_val: &[u8]) -> Result<Self, Error> {
if data_val.len() != LEN {
return Err(Error::DecodeErrorLenDiff);
return Err(Error::DecodeErrorLenDiff)
}
let mut a = [0; LEN];
a[..].copy_from_slice(data_val);

View File

@ -373,7 +373,7 @@ where
{
let res: Result<Option<((), ())>> = self.set_range(key);
if let Err(error) = res {
return Iter::Err(Some(error));
return Iter::Err(Some(error))
};
Iter::new(self, ffi::MDBX_GET_CURRENT, ffi::MDBX_NEXT)
}
@ -408,7 +408,7 @@ where
{
let res: Result<Option<((), ())>> = self.set_range(key);
if let Err(error) = res {
return IterDup::Err(Some(error));
return IterDup::Err(Some(error))
};
IterDup::new(self, ffi::MDBX_GET_CURRENT)
}
@ -424,7 +424,7 @@ where
Ok(Some(_)) => (),
Ok(None) => {
let _: Result<Option<((), ())>> = self.last();
return Iter::new(self, ffi::MDBX_NEXT, ffi::MDBX_NEXT);
return Iter::new(self, ffi::MDBX_NEXT, ffi::MDBX_NEXT)
}
Err(error) => return Iter::Err(Some(error)),
};

View File

@ -118,10 +118,10 @@ impl Environment {
warn!(target: "libmdbx", "Process stalled, awaiting read-write transaction lock.");
}
sleep(Duration::from_millis(250));
continue;
continue
}
break res;
break res
}?;
Ok(Transaction::new_from_ptr(self.clone(), txn.0))
}
@ -216,7 +216,7 @@ impl Environment {
for result in cursor.iter_slices() {
let (_key, value) = result?;
if value.len() < size_of::<usize>() {
return Err(Error::Corrupted);
return Err(Error::Corrupted)
}
let s = &value[..size_of::<usize>()];
@ -708,7 +708,7 @@ impl EnvironmentBuilder {
})() {
ffi::mdbx_env_close_ex(env, false);
return Err(e);
return Err(e)
}
}

View File

@ -504,7 +504,7 @@ impl Transaction<RW> {
/// Begins a new nested transaction inside of this transaction.
pub fn begin_nested_txn(&mut self) -> Result<Self> {
if self.inner.env.is_write_map() {
return Err(Error::NestedTransactionsUnsupportedWithWriteMap);
return Err(Error::NestedTransactionsUnsupportedWithWriteMap)
}
self.txn_execute(|txn| {
let (tx, rx) = sync_channel(0);
@ -576,7 +576,7 @@ impl TransactionPtr {
// because we're taking a lock for any actions on the transaction pointer, including a call
// to the `mdbx_txn_reset`.
if self.is_timed_out() {
return Err(Error::ReadTransactionTimeout);
return Err(Error::ReadTransactionTimeout)
}
Ok((f)(self.txn))