Module casper_node::storage
source · Expand description
Central storage component.
The central storage component is in charge of persisting data to disk. Its core functionalities are
- storing and loading blocks,
- storing and loading deploys,
- [temporary until refactored] holding
DeployMetadata
for each deploy, - keeping an index of blocks by height and
- unimplemented managing disk usage by pruning blocks and deploys from storage.
Any I/O performed by the component is done on the event handling thread, this is on purpose as the assumption is that caching by LMDB will offset any gains from offloading it onto a separate thread, while keeping the maximum event processing time reasonable.
§Consistency
The storage upholds a few invariants internally, namely:
- [temporary until refactored] Storing an execution result for a deploy in the context of a block is guaranteed to be idempotent: Storing the same result twice is a no-op, whilst attempting to store a differing one will cause a fatal error.
- Only one block can ever be associated with a specific block height. Attempting to store a block with a different block already existing at the same height causes a fatal error.
- Storing a deploy or block that already exists (same hash) is fine and will silently be accepted.
§Errors
The storage component itself is panic free and in general reports three classes of errors: Corruption, temporary resource exhaustion and potential bugs.
Structs§
- On-disk storage configuration.
- The storage component.
Enums§
- A fatal storage component error.
Functions§
- Returns all
Transform::WriteTransfer
s from the execution effects if this is anExecutionResult::Success
, or an emptyVec
ifExecutionResult::Failure
.