Skip to content

Commit a94a0b1

Browse files
committed
Use createAndDiscardArchive in one more place
1 parent a5f7fb4 commit a94a0b1

File tree

1 file changed

+7
-13
lines changed

1 file changed

+7
-13
lines changed

src/RSCoin/Explorer/Server.hs

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,16 @@ module RSCoin.Explorer.Server
44
( serve
55
) where
66

7-
87
import Control.Exception (throwIO)
98
import Control.Lens ((^.))
10-
import Control.Monad (unless, void, when)
9+
import Control.Monad (unless, when)
1110
import Control.Monad.Extra (whenJust)
1211
import Control.Monad.Trans (MonadIO (liftIO))
13-
import Data.Acid (createArchive, createCheckpoint)
12+
import Data.Acid (createCheckpoint)
1413
import Data.Acid.Advanced (query', update')
15-
import qualified Data.Text as T
1614
import Formatting (build, int, sformat, (%))
17-
import System.FilePath ((</>))
18-
import qualified Turtle.Prelude as TURT
1915

16+
import Serokell.Util.AcidState (createAndDiscardArchive)
2017
import Serokell.Util.Text (listBuilderJSONIndent)
2118

2219
import qualified RSCoin.Core as C
@@ -76,13 +73,10 @@ handleNewHBlock ch st bankPublicKey storagePath newBlockId (newBlock,emission) s
7673
{ ciTransactions = C.hbTransactions newBlock
7774
}
7875
liftIO $ createCheckpoint st
79-
whenJust storagePath $ \stpath ->
80-
when (newBlockId `mod` 5 == 0) $ liftIO $ do
81-
createArchive st
82-
void $
83-
TURT.shellStrict
84-
(T.pack $ "rm -rf " ++ (stpath </> "Archive"))
85-
(return "")
76+
whenJust storagePath $
77+
\stpath ->
78+
when (newBlockId `mod` 5 == 0) $
79+
createAndDiscardArchive st stpath
8680
ret (newBlockId + 1)
8781
if expectedPid == newBlockId
8882
then upd

0 commit comments

Comments
 (0)