@@ -37,11 +37,12 @@ import Cardano.Wallet.Kernel.NodeStateAdaptor (LockContext (..),
37
37
import Cardano.Wallet.Kernel.PrefilterTx (PrefilteredBlock , WalletKey ,
38
38
toHdAddressId )
39
39
import Cardano.Wallet.Kernel.Types (WalletId )
40
+ import Cardano.Wallet.Kernel.Util.Core (utxoBalance )
40
41
41
42
import Pos.Chain.Block (BlockHeader , Blund , HeaderHash , blockHeader ,
42
43
headerHash , mainBlockSlot )
43
- import Pos.Chain.Txp (Utxo , getTotalCoinsInUtxo )
44
- import Pos.Core (Address , Coin , SlotId , flattenSlotIdExplicit )
44
+ import Pos.Chain.Txp (Utxo )
45
+ import Pos.Core (Address , Coin , SlotId , flattenSlotIdExplicit , mkCoin )
45
46
import Pos.Core.Txp (toaOut , txOutAddress )
46
47
import Pos.DB (MonadDBRead )
47
48
import Pos.DB.Block (getBlund , getFirstGenesisBlockHash ,
@@ -94,7 +95,7 @@ restoreWallet wallet hdRoot (wId, wdc) prefilter = do
94
95
95
96
-- Return the wallet's current balance.
96
97
let myUtxo = foldr (\ (u,_,_) -> M. union u) M. empty mine
97
- return (getTotalCoinsInUtxo myUtxo)
98
+ return (mkCoin . fromIntegral . utxoBalance $ myUtxo)
98
99
99
100
where
100
101
txoAddr = txOutAddress . toaOut . snd
@@ -140,18 +141,19 @@ restoreWalletHistoryAsync wallet wId target tgtSlot prefilter = do
140
141
-- MN TEMPORARY: slow your roll!
141
142
threadDelay 5000000 -- 5 sec
142
143
143
- -- Gather the information we will need to decide if we are within K blocks of the tip.
144
- slotCount <- getSlotCount (wallet ^. walletNode)
145
- let flat = flattenSlotIdExplicit slotCount
144
+ -- Update each account's historical checkpoints
145
+ whenRight block $ \ mb -> do
146
146
147
- k <- getSecurityParameter (wallet ^. walletNode)
147
+ -- Gather the information we will need to decide if we are within K blocks of the tip.
148
+ slotCount <- getSlotCount (wallet ^. walletNode)
149
+ let flat = flattenSlotIdExplicit slotCount
148
150
149
- -- Filter the blocks by account
150
- (prefilteredBlocks, txMetas) <- prefilter blund
151
- say (" found " <> pretty (length prefilteredBlocks) <> " relevant accounts." )
151
+ k <- getSecurityParameter (wallet ^. walletNode)
152
+
153
+ -- Filter the blocks by account
154
+ (prefilteredBlocks, txMetas) <- prefilter blund
155
+ say (" found " <> pretty (length prefilteredBlocks) <> " relevant accounts." )
152
156
153
- -- Update each account's historical checkpoints
154
- whenRight block $ \ mb -> do
155
157
let slotId = mb ^. mainBlockSlot
156
158
SecurityParameter k0 = k
157
159
say (" about to apply block for " <> pretty (mb ^. mainBlockSlot)
@@ -166,9 +168,9 @@ restoreWalletHistoryAsync wallet wId target tgtSlot prefilter = do
166
168
. (wriTargetSlot .~ flat tgtSlot)) wId
167
169
say " update done."
168
170
169
- -- Store the TxMetas
170
- forM_ txMetas (putTxMeta (wallet ^. walletMeta))
171
- when (length txMetas > 0 ) $ say (" txMetas: " <> pretty txMetas)
171
+ -- Store the TxMetas
172
+ forM_ txMetas (putTxMeta (wallet ^. walletMeta))
173
+ when (length txMetas > 0 ) $ say (" txMetas: " <> pretty txMetas)
172
174
173
175
-- Get the next block from the node and recurse.
174
176
nextBlock (block ^. blockHeader) >>= \ case
0 commit comments