-
Notifications
You must be signed in to change notification settings - Fork 220
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into connect_to_staging
- Loading branch information
Showing
16 changed files
with
414 additions
and
179 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{-# LANGUAGE RankNTypes #-} | ||
|
||
-- | | ||
-- Copyright: © 2018-2019 IOHK | ||
-- License: MIT | ||
-- | ||
-- Dummy implementation of the database-layer, using MVar. This may be good for | ||
-- state-machine testing in order to compare it with an implementation on a real | ||
-- data store. | ||
|
||
module Cardano.DBLayer.MVar | ||
( newDBLayer | ||
) where | ||
|
||
import Prelude | ||
|
||
import Cardano.DBLayer | ||
( DBLayer (..) ) | ||
import Control.Concurrent.MVar | ||
( modifyMVar_, newMVar, readMVar ) | ||
|
||
import qualified Data.Map.Strict as Map | ||
|
||
|
||
-- | Instantiate a new in-memory "database" layer that simply stores data in | ||
-- a local MVar. Data vanishes if the software is shut down. | ||
newDBLayer :: forall s. IO (DBLayer IO s) | ||
newDBLayer = do | ||
wallets <- newMVar mempty | ||
return $ DBLayer | ||
{ putCheckpoints = \key cps -> | ||
modifyMVar_ wallets (return . Map.insert key cps) | ||
, readCheckpoints = \key -> | ||
Map.lookup key <$> readMVar wallets | ||
, readWallets = | ||
Map.keys <$> readMVar wallets | ||
} |
Oops, something went wrong.