cardano-wallet-core-2022.7.1: The Wallet Backend for a Cardano node.
Copyright © 2018-2020 IOHK
License Apache-2.0
Safe Haskell None
Language Haskell2010

Cardano.Wallet.DB

Description

Database / Persistence layer for the wallet backend. This is where we define the interface allowing us to store and fetch various data on our wallets.

Synopsis

Interface

data DBLayer m s k Source #

A Database interface for storing various things in a DB. In practice, we'll need some extra constraints on the wallet state that allows us to serialize and unserialize it (e.g. forall s. (Serialize s) => ... )

NOTE:

We can't use record accessors on the DBLayer as it carries an existential within its constructor. We are forced to pattern-match on the DBLayer record type in order to be able to use its methods in any context. With NamedFieldPuns, or RecordWildCards, this can be quite easy:

myFunction DBLayer{..} = do
    ...

myOtherFunction DBLayer{atomically,initializeWallet} = do
    ...

Alternatively, in some other context where the database may not be a function argument but come from a different source, it is possible to simply rely on 'Data.Function.(&)' to easily pattern match on it:

myFunction arg0 arg1 = db & DBLayer{..} -> do
    ...
  where
    db = ...

Note that it isn't possible to simply use a where clause or a let binding here as the semantic for those are slightly different: we really need a pattern match here!

Constructors

forall stm.( MonadIO stm, MonadFail stm) => DBLayer

Fields

data DBFactory m s k Source #

Instantiate database layers at will

Constructors

DBFactory

Fields

cleanDB :: DBLayer m s k -> m () Source #

Clean a database by removing all wallets.

Errors