Skip to content
This repository was archived by the owner on Aug 18, 2020. It is now read-only.

Commit 857b31c

Browse files
committed
[DAE-111] Fix cache saving
1 parent 3e6542f commit 857b31c

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/Pos/Wallet/Web/State/Storage.hs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ getNextUpdate :: Query (Maybe CUpdateInfo)
8787
getNextUpdate = preview (wsReadyUpdates . _head)
8888

8989
getHistoryCache :: CAddress -> Query (Maybe (HeaderHash, Utxo, [CTx]))
90-
getHistoryCache cAddr = preview $ wsHistoryCache . ix cAddr
90+
getHistoryCache cAddr = view $ wsHistoryCache . at cAddr
9191

9292
createWallet :: CAddress -> CWalletMeta -> Update ()
9393
createWallet cAddr wMeta = wsWalletMetas . at cAddr .= Just (wMeta, mempty)
@@ -120,10 +120,8 @@ removeNextUpdate = wsReadyUpdates %= drop 1
120120

121121
updateHistoryCache :: CAddress -> HeaderHash -> Utxo -> [CTx] -> Update ()
122122
updateHistoryCache cAddr cHash utxo cTxs = do
123-
let entry = wsHistoryCache . at cAddr . _Just
124-
entry . _1 .= cHash
125-
entry . _2 .= utxo
126-
entry . _3 %= (cTxs <>)
123+
oldTxs <- use $ wsHistoryCache . at cAddr . _Just . _3
124+
wsHistoryCache . at cAddr .= Just (cHash, utxo, cTxs <> oldTxs)
127125

128126
deriveSafeCopySimple 0 'base ''CProfile
129127
deriveSafeCopySimple 0 'base ''CHash

0 commit comments

Comments
 (0)