IntersectMBO / IntersectMBO/ouroboros-consensus

Immutable DB: provide Reader-like functionality

Open
#775 1 comment 0 reactions 0 assignees View on GitHub
technical debt
Dominant language
Haskell
Stars
67
Forks
43
Avg merge
5d 13h
Merged PRs (30d)
43

Description

Iterators can be used to stream from the ImmutableDB. However, upon initialisation, the bounds of an iterator are fixed, even when the upper bound is open. This means that blocks added after the iterator was opened will not be included in its stream.

The ChainDB has iterators with the same behaviour, but also *Readers*, which do include newly added blocks. These are implemented on top of ImmutableDB iterators. To simplify their implementation and to avoid having to reopen iterators (when reading from the tip of the ImmutableDB while new blocks are being added, we have to reopen the iterator to include these blocks), which is not cheap (a block is read every time), a part of this complexity could be shifted to the ImmutableDB.

A possible API:

```haskell
data Reader hash m a = Reader {
readerInstruction :: m (Maybe a)
, readerInstructionBlocking :: m a
, readerClose :: m ()
, readerId :: ReaderId
}
deriving (Functor)
```
where `a` will be instantiated with `ByteString`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.