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))]
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;
38mod txn_pool;
39
40#[cfg(test)]
41mod test_utils {
42 use super::*;
43 use byteorder::{ByteOrder, LittleEndian};
44 use tempfile::tempdir;
45
46 #[test]
50 fn issue_21_regression() {
51 const HEIGHT_KEY: [u8; 1] = [0];
52
53 let dir = tempdir().unwrap();
54
55 let env = {
56 let mut builder = Environment::builder();
57 builder.set_max_dbs(2);
58 builder
59 .set_geometry(Geometry { size: Some(1_000_000..1_000_000), ..Default::default() });
60 builder.open(dir.path()).expect("open mdbx env")
61 };
62
63 for height in 0..1000 {
64 let mut value = [0u8; 8];
65 LittleEndian::write_u64(&mut value, height);
66 let tx = env.begin_rw_txn().expect("begin_rw_txn");
67 let index = tx.create_db(None, DatabaseFlags::DUP_SORT).expect("open index db");
68 tx.put(index.dbi(), HEIGHT_KEY, value, WriteFlags::empty()).expect("tx.put");
69 tx.commit().expect("tx.commit");
70 }
71 }
72}