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
DeployMetadatafor each deploy, - holding a read-only copy of the chainspec,
- 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.
Indices
The current implementation keeps only in-memory indices, which are not persisted, based upon the estimate that they are reasonably quick to rebuild on start-up and do not take up much memory.
Errors
The storage component itself is panic free and in general reports three classes of errors: Corruption, temporary resource exhaustion and potential bugs.
Structs
Enums
A storage component error.
