Legend:
Library
Module
Module type
Parameter
Class
Class type
Persistent block store with arborescent history
The floating block store is an append-only store where blocks are stored arbitrarily. This structure possess an indexed map Block_hash.t -> (offset × predecessors) which points to its offset in the associated file along with an exponential list of predecessors block hashes (as implemented in Block_store.compute_predecessors). The structure access/modification is protected by a mutex (Lwt_idle_waiter) and thus can be manipulated concurrently. Stored blocks may or may not contain metadata. The instance maintains an opened file descriptor. Therefore it must be properly closed or it might lead to a file descriptor leak.
Four different kind of instances are allowed to co-exist for an identical path: - RO, a read-only instance; - RW, a read-write instance - RO_TMP, RW_TMP, read-write instances; - Restore is a generic instance used to wrap leftover instances while fixing a crashed storage. See Block_store.
Invariants
This store is expected to respect the following invariant:
Every block stored is correctly indexed.
Files format
The floating block store is composed of the following files:
file: /<kind>_floating_block_store, a list of Block_repr.t:
| <block> * |
where <kind> is RO(_TMP), RW(_TMP) (see Naming) and <block>, a Block_repr.t value encoded using Block_repr.encoding (thus prefixed by the its size).
find_predecessors floating_store block_hash reads from the index the list of block_hash's predecessors if the block is stored in floating_store, returns None otherwise.
read_block_and_predecessors floating_store hash same as read_block but also returns the block's predecessors. Returns None if it fails to resolve the given hash.
append_block floating_store ?flush preds block stores the block in floating_store updating its index with the given predecessors preds and flushing if flush is set to true (defaults to true).
fold_left_s f e floating_store sequential fold left on the floating_store using f on every block and e as initial element. The function f is given the last read block.
fold_left_with_pred_s f e floating_store sequential fold left on the floating_store using f on every block and e as initial element. The function f is given the last read block along with its predecessors.