Copyright | © 2018-2020 IOHK |
---|---|
License | Apache-2.0 |
Safe Haskell | None |
Language | Haskell2010 |
An implementation of the DBLayer which uses Persistent and SQLite.
Synopsis
- newDBFactory :: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK ), WalletKey k) => Tracer IO DBFactoryLog -> DefaultFieldValues -> TimeInterpreter IO -> Maybe FilePath -> IO ( DBFactory IO s k)
- findDatabases :: forall k. WalletKey k => Tracer IO DBFactoryLog -> FilePath -> IO [ WalletId ]
- data DBFactoryLog
- withDBLayer :: forall s k a. ( PersistAddressBook s, PersistPrivateKey (k ' RootK ), WalletKey k) => Tracer IO WalletDBLog -> DefaultFieldValues -> FilePath -> TimeInterpreter IO -> ( DBLayer IO s k -> IO a) -> IO a
- withDBLayerInMemory :: forall s k a. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) => Tracer IO WalletDBLog -> TimeInterpreter IO -> ( DBLayer IO s k -> IO a) -> IO a
- newtype WalletDBLog = MsgDB DBLog
- data CacheBehavior
- newDBLayerWith :: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) => CacheBehavior -> Tracer IO WalletDBLog -> TimeInterpreter IO -> SqliteContext -> IO ( DBLayer IO s k)
- newDBLayerInMemory :: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) => Tracer IO WalletDBLog -> TimeInterpreter IO -> IO ( IO (), DBLayer IO s k)
-
class
AddressBookIso
s =>
PersistAddressBook
s
where
- insertPrologue :: WalletId -> Prologue s -> SqlPersistT IO ()
- insertDiscoveries :: WalletId -> SlotNo -> Discoveries s -> SqlPersistT IO ()
- loadPrologue :: WalletId -> SqlPersistT IO ( Maybe ( Prologue s))
- loadDiscoveries :: WalletId -> SlotNo -> SqlPersistT IO ( Discoveries s)
- data DefaultFieldValues = DefaultFieldValues { }
Directory of single-file wallet databases
:: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK ), WalletKey k) | |
=> Tracer IO DBFactoryLog |
Logging object |
-> DefaultFieldValues |
Default database field values, used during migration. |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> Maybe FilePath |
Path to database directory, or Nothing for in-memory database |
-> IO ( DBFactory IO s k) |
Instantiate a
DBFactory
from a given directory, or in-memory for testing.
findDatabases :: forall k. WalletKey k => Tracer IO DBFactoryLog -> FilePath -> IO [ WalletId ] Source #
Return all wallet databases that match the specified key type within the specified directory.
data DBFactoryLog Source #
Instances
Internal implementation
:: forall s k a. ( PersistAddressBook s, PersistPrivateKey (k ' RootK ), WalletKey k) | |
=> Tracer IO WalletDBLog |
Logging object |
-> DefaultFieldValues |
Default database field values, used during migration. |
-> FilePath |
Path to database file |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> ( DBLayer IO s k -> IO a) |
Action to run. |
-> IO a |
Runs an action with a connection to the SQLite database.
Database migrations are run to create tables if necessary.
If the given file path does not exist, it will be created by the sqlite library.
:: forall s k a. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) | |
=> Tracer IO WalletDBLog |
Logging object |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> ( DBLayer IO s k -> IO a) | |
-> IO a |
Runs an IO action with a new
DBLayer
backed by a sqlite in-memory
database.
newtype WalletDBLog Source #
Instances
data CacheBehavior Source #
What to do with regards to caching. This is useful to disable caching in database benchmarks.
Instances
Eq CacheBehavior Source # | |
Defined in Cardano.Wallet.DB.Layer (==) :: CacheBehavior -> CacheBehavior -> Bool Source # (/=) :: CacheBehavior -> CacheBehavior -> Bool Source # |
|
Show CacheBehavior Source # | |
Defined in Cardano.Wallet.DB.Layer |
Unbracketed internal implementation
:: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) | |
=> CacheBehavior |
Option to disable caching. |
-> Tracer IO WalletDBLog |
Logging |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> SqliteContext |
A (thread-)safe wrapper for query execution. |
-> IO ( DBLayer IO s k) |
Like
newDBLayer
, but allows to explicitly specify the caching behavior.
:: forall s k. ( PersistAddressBook s, PersistPrivateKey (k ' RootK )) | |
=> Tracer IO WalletDBLog |
Logging object |
-> TimeInterpreter IO |
Time interpreter for slot to time conversions |
-> IO ( IO (), DBLayer IO s k) |
Interfaces
class AddressBookIso s => PersistAddressBook s where Source #
Functions for saving loading the wallet's address book to from SQLite
insertPrologue :: WalletId -> Prologue s -> SqlPersistT IO () Source #
insertDiscoveries :: WalletId -> SlotNo -> Discoveries s -> SqlPersistT IO () Source #
loadPrologue :: WalletId -> SqlPersistT IO ( Maybe ( Prologue s)) Source #
loadDiscoveries :: WalletId -> SlotNo -> SqlPersistT IO ( Discoveries s) Source #
Instances
Migration Support
data DefaultFieldValues Source #
A set of default field values that can be consulted when performing a database migration.