A module that provides interfaces to work with persisted blockchain data.
See also the documentation page on storage.
Database is a container for data persistence. Internally, a
a collection of named key-value stores (aka column families)
with reading isolation and atomic writes. The database is assumed to be embedded,
that is, the Exonum process has exclusive access to the DB during blockchain operation.
You can interact with the
Database from multiple threads by cloning its instance.
Snapshots and forks facilitate access to the database.
If you need to read the data, you can create a
Snapshot using the
Database instance. Snapshots provide read isolation, so you are guaranteed to work
with consistent values even if the data in the database changes between reads.
provides all the necessary methods for reading data from the database, so
is used as a storage view for creating a read-only representation of the indices.
If you need to make changes to the database, you need to create a
fork method of the
Fork provides read isolation,
but also allows creating a sequence of changes to the database that are specified
Patch. A patch can be atomically
merged into a database. Different threads
If you need to use your own data types as keys or values in the storage, you need to implement
BinaryValue traits respectively. These traits have already been
implemented for most standard types.
Indices are structures representing data collections stored in the database. This concept is similar to tables in relational databases. The interfaces of the indices are similar to ordinary collections (like arrays, maps and sets).
Each index occupies a certain set of keys in a single column family of the
On the other hand, multiple indices can be stored in the same column family, provided
that their key spaces do not intersect. Isolation is commonly achieved with the help
of column families; see
new_in_family constructor in the built-in index types.
Merkelized indices can generate cryptographic proofs about inclusion of entries. Having such a proof, an external client may verify locally that the received data was authorized by the blockchain validators, without having to replicate the entire blockchain contents.
Exonum provides the following index types:
Entryis a specific index that stores only one value. Useful for global values, such as configuration. Similar to a combination of
ListIndexis a list of items stored in a sequential order. Similar to
SparseListIndexis a list of items stored in a sequential order. Similar to
ListIndex, but may contain indices without elements.
MapIndexis a map of keys and values. Similar to
ProofListIndexis a Merkelized version of
ListIndexthat supports cryptographic proofs of existence and is implemented as a Merkle tree.
ProofMapIndexis a Merkelized version of
MapIndexthat supports cryptographic proofs of existence and is implemented as a binary Merkle Patricia tree.
ValueSetIndexare sets of items, similar to
An implementation of a set for items that utilize the
An implementation of an array list of items.
An implementation of a key-value map.
An implementation of a Merkelized version of an array list (Merkle tree).
An implementation of a Merkelized version of a map (Merkle Patricia tree).
An implementation of an array list of items with spaces.
An implementation of a set of items that utilize the
Map containing changes with a corresponding key.
Iterator over the
Options for the database.
An index that may only contain one element.
The error type for I/O operations with storage.
A combination of a database snapshot and a sequence of changes on top of it.
Represents address of the index in the database.
Struct responsible for creating
A set of serial changes that should be applied to a storage atomically.
Iterator over the
Encapsulates a proof of absence for
Utility trait to provide immutable references to
Utility trait to provide mutable references to
Database implementation on top of
Wrapper over the
Represents current view of the database by specified
An enum that represents a type of change made to some key in the storage.
An enum that represents a proof of existence for a proof list elements.
A type that can be (de)serialized as a key in the blockchain storage.
A type that can be (de)serialized as a value in the blockchain storage.
Low-level storage backend implementing a collection of named key-value stores (aka column families).
Base trait that allows to access and modify indexes.
A trait that defines a streaming iterator over storage view entries. Unlike
Trait used to obtain references to database objects.
A common trait for the ability to compute a unique hash.
A read-only snapshot of a storage backend.
Computes a Merkle root hash for a the given list of hashes.
A generalized iterator over the storage views.