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.Pure.Implementation

Description

An implementation of the wallet database using only pure functions.

These functions and types model the behaviour of the SQLite database backend, and are used for QuickCheck state machine testing, and the MVar database backend.

Synopsis

Model Types

data Database wid s xprv Source #

Model database, parameterised by the wallet ID type, the wallet AD state type, the target backend, and the private key type.

Tne type parameters exist so that simpler mock types can be used in place of actual wallet types.

Constructors

Database

Fields

Instances

Instances details
( Eq wid, Eq xprv, Eq s) => Eq ( Database wid s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Methods

(==) :: Database wid s xprv -> Database wid s xprv -> Bool Source #

(/=) :: Database wid s xprv -> Database wid s xprv -> Bool Source #

( Show wid, Show s, Show xprv) => Show ( Database wid s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Generic ( Database wid s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Associated Types

type Rep ( Database wid s xprv) :: Type -> Type Source #

Methods

from :: Database wid s xprv -> Rep ( Database wid s xprv) x Source #

to :: Rep ( Database wid s xprv) x -> Database wid s xprv Source #

( NFData wid, NFData s, NFData xprv) => NFData ( Database wid s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Methods

rnf :: Database wid s xprv -> () Source #

type Rep ( Database wid s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

type Rep ( Database wid s xprv) = D1 (' MetaData "Database" "Cardano.Wallet.DB.Pure.Implementation" "cardano-wallet-core-2022.7.1-AGKhlyz9liLKN3QqZD1gj" ' False ) ( C1 (' MetaCons "Database" ' PrefixI ' True ) ( S1 (' MetaSel (' Just "wallets") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Map wid ( WalletDatabase s xprv))) :*: S1 (' MetaSel (' Just "txs") ' NoSourceUnpackedness ' SourceStrict ' DecidedStrict ) ( Rec0 ( Map ( Hash "Tx") Tx ))))

data WalletDatabase s xprv Source #

Model database record for a single wallet.

Instances

Instances details
( Eq s, Eq xprv) => Eq ( WalletDatabase s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

( Show s, Show xprv) => Show ( WalletDatabase s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Generic ( WalletDatabase s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Associated Types

type Rep ( WalletDatabase s xprv) :: Type -> Type Source #

( NFData s, NFData xprv) => NFData ( WalletDatabase s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

type Rep ( WalletDatabase s xprv) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

emptyDatabase :: Ord wid => Database wid s xprv Source #

Produces an empty model database.

type TxHistory = [( Tx , TxMeta )] Source #

Shorthand for the readTxHistory result type.

type TxHistoryMap = Map ( Hash "Tx") ( Tx , TxMeta ) Source #

Shorthand for the putTxHistory argument type.

filterTxHistory :: Maybe Coin -> SortOrder -> Range SlotNo -> TxHistory -> TxHistory Source #

Apply optional filters on slotNo and sort using the default sort order (first time/slotNo, then by TxId) to a TxHistory .

Model Operation Types

type ModelOp wid s xprv a = Database wid s xprv -> ( Either ( Err wid) a, Database wid s xprv) Source #

A database model operation, which is a function that takes a database and returns: * a value, which is a query of the database, or an error; and * a (possibly) modified database.

data Err wid Source #

All of the possible errors that any of the model database functions might return.

Instances

Instances details
Functor Err Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Methods

fmap :: (a -> b) -> Err a -> Err b Source #

(<$) :: a -> Err b -> Err a Source #

Foldable Err Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Traversable Err Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Eq wid => Eq ( Err wid) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Show wid => Show ( Err wid) Source #
Instance details

Defined in Cardano.Wallet.DB.Pure.Implementation

Model database functions

mRemoveWallet :: Ord wid => wid -> ModelOp wid s xprv () Source #

mPutTxHistory :: forall wid s xprv. Ord wid => wid -> TxHistory -> ModelOp wid s xprv () Source #

mPutPrivateKey :: Ord wid => wid -> xprv -> ModelOp wid s xprv () Source #

mCheckWallet :: Ord wid => wid -> ModelOp wid s xprv () Source #