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.Layer

Description

An implementation of the DBLayer which uses Persistent and SQLite.

Synopsis

Directory of single-file wallet databases

newDBFactory Source #

Arguments

:: 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

Instances details
Eq DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Show DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Generic DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

ToText DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

HasPrivacyAnnotation DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Methods

getPrivacyAnnotation :: DBFactoryLog -> PrivacyAnnotation

HasSeverityAnnotation DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

type Rep DBFactoryLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

type Rep DBFactoryLog = D1 (' MetaData "DBFactoryLog" "Cardano.Wallet.DB.Layer" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) (( C1 (' MetaCons "MsgFoundDatabase" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 FilePath ) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text )) :+: ( C1 (' MetaCons "MsgUnknownDBFile" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 FilePath )) :+: C1 (' MetaCons "MsgRemoving" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text )))) :+: (( C1 (' MetaCons "MsgRemovingInUse" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text ) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Int )) :+: C1 (' MetaCons "MsgRemovingDatabaseFile" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text ) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 DeleteSqliteDatabaseLog ))) :+: ( C1 (' MetaCons "MsgWaitingForDatabase" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 Text ) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 ( Maybe Int ))) :+: C1 (' MetaCons "MsgWalletDB" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 FilePath ) :*: S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 WalletDBLog )))))

Internal implementation

withDBLayer Source #

Arguments

:: 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.

withDBLayerInMemory Source #

Arguments

:: 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 #

Constructors

MsgDB DBLog

Instances

Instances details
Eq WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Show WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Generic WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

ToText WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

HasPrivacyAnnotation WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

Methods

getPrivacyAnnotation :: WalletDBLog -> PrivacyAnnotation

HasSeverityAnnotation WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

type Rep WalletDBLog Source #
Instance details

Defined in Cardano.Wallet.DB.Layer

type Rep WalletDBLog = D1 (' MetaData "WalletDBLog" "Cardano.Wallet.DB.Layer" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' True ) ( C1 (' MetaCons "MsgDB" ' PrefixI ' False ) ( S1 (' MetaSel (' Nothing :: Maybe Symbol ) ' NoSourceUnpackedness ' NoSourceStrictness ' DecidedLazy ) ( Rec0 DBLog )))

Unbracketed internal implementation

newDBLayerWith Source #

Arguments

:: 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.

newDBLayerInMemory Source #

Arguments

:: 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)

Creates a DBLayer backed by a sqlite in-memory database.

Returns a cleanup function which you should always use exactly once when finished with the DBLayer .

Interfaces

class AddressBookIso s => PersistAddressBook s where Source #

Functions for saving loading the wallet's address book to from SQLite

Instances

Instances details
PersistAddressBook ( RndState n) Source #

Persisting RndState requires that the wallet root key has already been added to the database with putPrivateKey . Unlike sequential AD, random address discovery requires a root key to recognize addresses.

Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

PersistAddressBook ( RndAnyState n p) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

( PersistPublicKey (key ' AccountK ), PersistPublicKey (key ' AddressK ), PersistPublicKey (key ' PolicyK ), MkKeyFingerprint key ( Proxy n, key ' AddressK XPub ), PaymentAddress n key, SoftDerivation key, Typeable n, (key == SharedKey ) ~ ' False , Eq ( SeqState n key)) => PersistAddressBook ( SeqState n key) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

( PersistPublicKey (key ' AccountK ), SupportsDiscovery n key, WalletKey key, key ~ SharedKey ) => PersistAddressBook ( SharedState n key) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

( Eq ( SeqState n k), (k == SharedKey ) ~ ' False , PersistAddressBook ( SeqState n k)) => PersistAddressBook ( SeqAnyState n k p) Source #
Instance details

Defined in Cardano.Wallet.DB.Store.Checkpoints

Migration Support