ouroboros-consensus
Safe HaskellNone
LanguageHaskell2010

Ouroboros.Consensus.Storage.LeiosDB.Impl.SQLite

Synopsis

Documentation

newLeiosDBSQLite ∷ ResourceRegistry IO → Tracer IO TraceLeiosDb → FilePath → FilePath → IO (LeiosDbHandle IO) Source #

Create a new Leios database using the SQLite implementation.

Each call to openReader on the returned handle creates new SQLite connection; readers are not thread-safe and should not be shared across threads. All writers submit to the one write connection created here, on its own worker thread.

The registry owns the background threads (writer and a thread that samples the database's size) and the promoter's connection: closeLeiosDbHandle stops and closes them in order, and closing the registry releases whatever is still open.

Creates both files with their schemas before returning, so call it only once their directories may be non-empty (after the ChainDB marker check).

withLeiosDBSQLite ∷ Tracer IO TraceLeiosDb → FilePath → FilePath → (LeiosDbHandle IO → IO a) → IO a Source #

newLeiosDBSQLite bracketed with its closeLeiosDbHandle: on release every pending write has landed, the background threads are gone and the connections are closed, so e.g. the database files can be deleted.

SQL strings (re-exported for leios-schedule-gen)

sql_schema_vol ∷ String Source #

Schema of the volatile partition (leios.vol.db).

sql_schema_imm ∷ String Source #

Schema of the immutable partition (leios.imm.db). EBs land here complete and are never collected.