Skip to main content

Crate signet_hot_mdbx

Crate signet_hot_mdbx 

Source
Expand description

Implementation of the hot key-value storage using MDBX as the underlying database.

§Notes on implementation

This module provides an implementation of the HotKv trait using MDBX as the underlying database. It includes functionality for opening and managing the MDBX environment, handling read-only and read-write transactions, and managing database tables.

The DatabaseEnv struct encapsulates the MDBX environment and provides methods for starting transactions. The DatabaseArguments struct allows for configuring various parameters of the database environment, such as geometry, sync mode, and maximum readers.

§Table Metadata

This implementation uses the default MDBX table to store metadata about each table, including whether it uses dual keys or fixed-size values. This metadata is cached in memory for efficient access during the lifetime of the environment. Each time a table is opened, its metadata is checked against the cached values to ensure consistency.

Rough Edges:

  • The cache does not respect dropped transactions. Creating multiple tables with the same name but different metadata in different transactions may lead to inconsistencies.
  • Tables created outside of this implementation (e.g., via external tools) will not have their metadata cached, which may lead to inconsistencies if the same table is later opened with different metadata.

Overall, we do NOT recommend using this to open existing databases that were not created and managed by this implementation.

§Feature Flags

  • test-utils: Enables the test_utils module with MDBX test helpers and conformance tests. Adds a tempfile dependency.
  • disable-lock: Disables the storage lock file, allowing multiple processes to open the same database. Intended for testing scenarios.

Modules§

test_utilstest-utils
Utilities for testing MDBX storage implementation.

Structs§

Cursor
Cursor wrapper to access KV items.
DatabaseArguments
Arguments for database initialization.
DatabaseEnv
MDBX database environment. Wraps the low-level Environment, and implements the HotKv trait.
StorageLock
A file lock for a storage directory to ensure exclusive read-write access across different processes.
Tx
Wrapper around signet_libmdbx::tx::Tx, with an additional cache to store FixedSizeInfo for tables.

Enums§

DatabaseEnvKind
Environment used when opening a MDBX environment. Read-only or Read-write.
FixedSizeInfo
Information about fixed size values in a database.
MdbxError
Error type for signet_libmdbx based hot storage.
StorageLockError
Storage lock error.

Constants§

GIGABYTE
1 GB in bytes
KILOBYTE
1 KB in bytes
MEGABYTE
1 MB in bytes
TERABYTE
1 TB in bytes

Type Aliases§

CursorRo
Read only Cursor.
CursorRoSync
Synchronized read only cursor.
CursorRw
Read write cursor.
CursorRwSync
Synchronized read write cursor.