reth_libmdbx/
lib.rs
1#![doc = include_str!("../README.md")]
2#![doc(
3 html_logo_url = "https://raw.githubusercontent.com/paradigmxyz/reth/main/assets/reth-docs.png",
4 html_favicon_url = "https://avatars0.githubusercontent.com/u/97369466?s=256",
5 issue_tracker_base_url = "https://github.com/paradigmxyz/reth/issues/"
6)]
7#![cfg_attr(not(test), warn(unused_crate_dependencies))]
8#![allow(missing_docs, clippy::needless_pass_by_ref_mut)]
9#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
10#![allow(clippy::borrow_as_ptr)]
11
12pub extern crate reth_mdbx_sys as ffi;
13
14pub use crate::{
15 codec::*,
16 cursor::{Cursor, Iter, IterDup},
17 database::Database,
18 environment::{
19 Environment, EnvironmentBuilder, EnvironmentKind, Geometry, HandleSlowReadersCallback,
20 HandleSlowReadersReturnCode, Info, PageSize, Stat,
21 },
22 error::{Error, Result},
23 flags::*,
24 transaction::{CommitLatency, Transaction, TransactionKind, RO, RW},
25};
26
27#[cfg(feature = "read-tx-timeouts")]
28pub use crate::environment::read_transactions::MaxReadTransactionDuration;
29
30mod codec;
31mod cursor;
32mod database;
33mod environment;
34mod error;
35mod flags;
36mod transaction;
37mod txn_manager;
38
39#[cfg(test)]
40mod test_utils {
41 use super::*;
42 use byteorder::{ByteOrder, LittleEndian};
43 use tempfile::tempdir;
44
45 #[test]
49 fn issue_21_regression() {
50 const HEIGHT_KEY: [u8; 1] = [0];
51
52 let dir = tempdir().unwrap();
53
54 let env = {
55 let mut builder = Environment::builder();
56 builder.set_max_dbs(2);
57 builder
58 .set_geometry(Geometry { size: Some(1_000_000..1_000_000), ..Default::default() });
59 builder.open(dir.path()).expect("open mdbx env")
60 };
61
62 for height in 0..1000 {
63 let mut value = [0u8; 8];
64 LittleEndian::write_u64(&mut value, height);
65 let tx = env.begin_rw_txn().expect("begin_rw_txn");
66 let index = tx.create_db(None, DatabaseFlags::DUP_SORT).expect("open index db");
67 tx.put(index.dbi(), HEIGHT_KEY, value, WriteFlags::empty()).expect("tx.put");
68 tx.commit().expect("tx.commit");
69 }
70 }
71}