Skip to content

Commit

Permalink
Remove putCheckpoint from DBLayer
Browse files Browse the repository at this point in the history
  • Loading branch information
HeinrichApfelmus committed Jun 5, 2023
1 parent d3ae8ce commit 96e9e99
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 25 deletions.
3 changes: 2 additions & 1 deletion lib/wallet/src/Cardano/Wallet/Checkpoints.hs
Expand Up @@ -135,8 +135,9 @@ type DeltasCheckpoints a = [DeltaCheckpoints a]

data DeltaCheckpoints a
= PutCheckpoint W.Slot a
-- ^ Insert a checkpoint at a specified slot.
| RollbackTo W.Slot
-- Rolls back to the latest checkpoint at or before this slot.
-- ^ Rolls back to the latest checkpoint at or before this slot.
| RestrictTo [W.Slot]
-- ^ Restrict to the intersection of this list with
-- the checkpoints that are already present.
Expand Down
12 changes: 0 additions & 12 deletions lib/wallet/src/Cardano/Wallet/DB.hs
Expand Up @@ -214,12 +214,6 @@ data DBLayer m s = forall stm. (MonadIO stm, MonadFail stm) => DBLayer
, transactionsStore :: Store stm QueryTxWalletsHistory DeltaTxWalletsHistory
-- ^ 'Store' containing all transactions of all wallets in the database.

, putCheckpoint :: Wallet s -> stm ()
-- ^ Replace the current checkpoint for a given wallet. We do not handle
-- rollbacks yet, and therefore only stores the latest available
-- checkpoint.
--

, readCheckpoint :: stm (Wallet s)
-- ^ Fetch the most recent checkpoint of a given wallet.

Expand Down Expand Up @@ -404,7 +398,6 @@ mkDBLayerFromParts ti wid_ DBLayerCollection{..} = DBLayer
{ walletId_ = wid_
, walletState = walletsDB_ dbCheckpoints
, transactionsStore = transactionsStore_
, putCheckpoint = putCheckpoint_ dbCheckpoints
, readCheckpoint = readCheckpoint'
, listCheckpoints = listCheckpoints_ dbCheckpoints
, readDelegation = do
Expand Down Expand Up @@ -491,11 +484,6 @@ data DBCheckpoints stm s = DBCheckpoints
-- Intended to replace 'putCheckpoint' and 'readCheckpoint' in the short-term,
-- and all other functions in the long-term.

, putCheckpoint_ :: Wallet s -> stm ()
-- ^ Replace the current checkpoint for a given wallet. We do not handle
-- rollbacks yet, and therefore only stores the latest available
-- checkpoint.

, readCheckpoint_ :: stm (Wallet s)
-- ^ Fetch the most recent checkpoint of a given wallet.
--
Expand Down
10 changes: 0 additions & 10 deletions lib/wallet/src/Cardano/Wallet/DB/Layer.hs
Expand Up @@ -131,9 +131,7 @@ import Cardano.Wallet.DB.WalletState
, DeltaWalletState1 (..)
, findNearestPoint
, fromGenesis
, fromWallet
, getLatest
, getSlot
)
import Cardano.Wallet.Flavor
( KeyFlavorS, WalletFlavorS, keyOfWallet )
Expand Down Expand Up @@ -563,14 +561,6 @@ newDBFreshFromDBOpen wF ti wid_ DBOpen{atomically=atomically_} =
dbCheckpoints = DBCheckpoints
{ walletsDB_ = walletState

, putCheckpoint_ = \cp ->
Delta.onDBVar walletState $ Delta.update $ \_ ->
let (prologue, wcp) = fromWallet cp
slot = getSlot wcp
in [ UpdateCheckpoints [ PutCheckpoint slot wcp ]
, ReplacePrologue prologue
]

, readCheckpoint_ = readCheckpoint

, listCheckpoints_ = do
Expand Down
2 changes: 0 additions & 2 deletions lib/wallet/src/Cardano/Wallet/DB/Pure/Layer.hs
Expand Up @@ -103,8 +103,6 @@ newDBFresh timeInterpreter wid = do
, walletState = error "MVar.walletState: not implemented"
, transactionsStore = error "MVar.transactionsStore: not implemented"

, putCheckpoint = error "MVar.putCheckpoint: implementation deleted"

, readCheckpoint = throwErrorReadDB db mReadCheckpoint

, listCheckpoints = fromMaybe [] <$> readDBMaybe db mListCheckpoints
Expand Down

0 comments on commit 96e9e99

Please sign in to comment.