@@ -12,9 +12,8 @@ module Cardano.Wallet.Kernel.BListener (
12
12
import Universum hiding (State )
13
13
14
14
import Control.Concurrent.MVar (modifyMVar_ )
15
- import Control.Lens (to , _Just )
15
+ import Control.Lens (_Just )
16
16
import Control.Monad.Except (throwError )
17
- import Data.Acid (createCheckpoint )
18
17
import Data.Acid.Advanced (update' )
19
18
import Data.List (scanl' )
20
19
import qualified Data.List.NonEmpty as NE
@@ -27,11 +26,10 @@ import qualified Formatting.Buildable
27
26
import Pos.Chain.Block (HeaderHash )
28
27
import Pos.Chain.Genesis (Config (.. ))
29
28
import Pos.Chain.Txp (TxId )
30
- import Pos.Core (getSlotIndex , siSlotL )
31
29
import Pos.Core.Chrono (OldestFirst (.. ))
32
30
import Pos.Crypto (EncryptedSecretKey )
33
31
import Pos.DB.Block (getBlund )
34
- import Pos.Util.Log (Severity (Info , Warning ))
32
+ import Pos.Util.Log (Severity (.. ))
35
33
36
34
import Cardano.Wallet.Kernel.DB.AcidState (ApplyBlock (.. ),
37
35
ObservableRollbackUseInTestsOnly (.. ), SwitchToFork (.. ),
@@ -138,32 +136,7 @@ applyBlock :: PassiveWallet
138
136
applyBlock pw@ PassiveWallet {.. } b = do
139
137
k <- Node. getSecurityParameter _walletNode
140
138
runExceptT (applyOneBlock k Nothing b) >>= either (handleApplyBlockErrors k) pure
141
-
142
139
where
143
- -- | Interim fix, see CBR-438 and
144
- -- https://github.com/acid-state/acid-state/issues/103. In brief, when
145
- -- the note initially syncs and lots of blocks gets passed to the wallet
146
- -- worker, a new `ApplyBlock` acidic transaction will be committed on the
147
- -- transaction log but not written to disk _yet_ (that's what checkpoints
148
- -- are for). However, this might lead to memory leaks if such checkpointing
149
- -- step doesn't happen fast enough. Therefore, every time we apply a block,
150
- -- we decrement this counter and when it reaches 0, we enforce a new
151
- -- checkpoint.
152
- createCheckpointIfNeeded :: IO ()
153
- createCheckpointIfNeeded = do
154
- -- Look at the 'ResolvedBlock' 's 'SlotId', and assess if a new
155
- -- checkpoint is needed by doing @localBlockIx `modulo` someConstant@
156
- -- where @someConstant@ is chosen to be 1000.
157
- let blockSlotIx = b ^. rbContext
158
- . bcSlotId
159
- . fromDb
160
- . siSlotL
161
- . to getSlotIndex
162
- checkpointNeeded = (blockSlotIx - 1 ) `mod` 1000 == 0
163
- when checkpointNeeded $ do
164
- _walletLogMessage Info " applyBlock: making an acid-state DB checkpoint..."
165
- createCheckpoint _wallets
166
-
167
140
handleApplyBlockErrors :: Node. SecurityParameter
168
141
-> NonEmptyMap HdAccountId ApplyBlockFailed
169
142
-> IO ()
@@ -222,7 +195,6 @@ applyBlock pw@PassiveWallet{..} b = do
222
195
Right confirmed -> do
223
196
modifyMVar_ _walletSubmission (return . Submission. remPending confirmed)
224
197
mapM_ (putTxMeta _walletMeta) metas
225
- createCheckpointIfNeeded
226
198
return $ Right ()
227
199
228
200
-- Determine if a failure in 'ApplyBlock' was due to the account being ahead, behind,
0 commit comments