Skip to main content

Module api

Module api 

Source
Expand description

§Storage Backend API

This module provides a thin, minimal interface for storage backends:

  • Thin: Minimal set of operations that databases must provide
  • Simple: Avoids type-system complexity and focuses on core functionality

Rather than implementing business logic in each database backend, this API provides low-level primitives that higher-level code can build upon. This eliminates code duplication and makes adding new database backends trivial.

The API differentiates between three types of database access:

  • Read views (StorageReadView): read-only views of the database, with no atomicity guarantees between operations.
  • Write batches (StorageWriteBatch): write batch functionality, with atomicity guarantees at commit time.
  • Locked views (StorageLockedView): read-only views of a point in time (snapshots), right now it’s only used during snap-sync.

Modules§

tables
Table names used by the storage engine.

Traits§

StorageBackend
This trait provides a minimal set of operations required from a database backend. Implementations should focus on providing efficient access to the underlying storage without implementing business logic.
StorageLockedView
Locked snapshot interface for batch read operations. Provides read-only access to a specific table with a persistent snapshot. This is optimized for scenarios where many reads are performed on the same table, such as trie traversal operations. This is currently only used in snapsync stage.
StorageReadView
Read-only transaction interface. Provides methods to read data from the database
StorageWriteBatch
Write transaction interface.

Type Aliases§

PrefixResult
Type alias for the result of a prefix iterator.