diff --git a/src/Zenith/DB.hs b/src/Zenith/DB.hs index b84f344..1a24fd4 100644 --- a/src/Zenith/DB.hs +++ b/src/Zenith/DB.hs @@ -2030,6 +2030,21 @@ getUnconfPoolBalance pool za = do let oBal = sum oAmts return $ AccountBalance tBal sBal oBal +rewindWalletTransactions :: ConnectionPool -> Int -> IO () +rewindWalletTransactions pool b = do + runNoLoggingT $ + PS.retryOnBusy $ + flip PS.runSqlPool pool $ do + delete $ do + _ <- from $ table @UserTx + return () + delete $ do + txs <- from $ table @WalletTransaction + where_ $ txs ^. WalletTransactionBlock >. val b + return () + update $ \w -> do + set w [ZcashWalletLastSync =. val b] + clearWalletTransactions :: ConnectionPool -> IO () clearWalletTransactions pool = do runNoLoggingT $ @@ -2578,10 +2593,10 @@ completeSync pool st = do -- | Rewind the data store to a given block height rewindWalletData :: ConnectionPool -> Int -> IO () rewindWalletData pool b = do + rewindWalletTransactions pool b runNoLoggingT $ PS.retryOnBusy $ flip PS.runSqlPool pool $ delete $ do blk <- from $ table @ZcashBlock where_ $ blk ^. ZcashBlockHeight >=. val b - clearWalletTransactions pool