@@ -71,8 +71,8 @@ import Ouroboros.Consensus.Cardano.Block (StandardCrypto)
7171-- a different id.
7272-- NOTE: Other tables are not cleaned up since they are not rollbacked.
7373rollbackCache :: MonadIO m => CacheStatus -> DB. BlockId -> ReaderT SqlBackend m ()
74- rollbackCache UninitiatedCache _ = pure ()
75- rollbackCache (Cache cache) blockId = do
74+ rollbackCache NoCache _ = pure ()
75+ rollbackCache (ActiveCache cache) blockId = do
7676 liftIO $ do
7777 atomically $ writeTVar (cPrevBlock cache) Nothing
7878 atomically $ modifyTVar (cDatum cache) LRU. cleanup
@@ -92,7 +92,7 @@ queryOrInsertRewardAccount ::
9292 Ledger. RewardAccount StandardCrypto ->
9393 ReaderT SqlBackend m DB. StakeAddressId
9494queryOrInsertRewardAccount syncEnv cache cacheNew rewardAddr = do
95- eiAddrId <- queryRewardAccountWithCacheRetBs cache cacheNew rewardAddr
95+ eiAddrId <- queryRewardAccountWithCacheRetBs syncEnv cache cacheNew rewardAddr
9696 case eiAddrId of
9797 Left (_err, bs) -> insertStakeAddress syncEnv rewardAddr (Just bs)
9898 Right addrId -> pure addrId
@@ -130,36 +130,37 @@ insertStakeAddress _syncEnv rewardAddr stakeCredBs = do
130130queryRewardAccountWithCacheRetBs ::
131131 forall m .
132132 MonadIO m =>
133- Trace IO Text ->
133+ SyncEnv ->
134134 CacheStatus ->
135135 CacheAction ->
136136 Ledger. RewardAccount StandardCrypto ->
137137 ReaderT SqlBackend m (Either (DB. LookupFail , ByteString ) DB. StakeAddressId )
138- queryRewardAccountWithCacheRetBs trce cache cacheUA rwdAcc =
139- queryStakeAddrWithCacheRetBs trce cache cacheUA (Ledger. raNetwork rwdAcc) (Ledger. raCredential rwdAcc)
138+ queryRewardAccountWithCacheRetBs syncEnv cache cacheUA rwdAcc =
139+ queryStakeAddrWithCacheRetBs syncEnv cache cacheUA (Ledger. raNetwork rwdAcc) (Ledger. raCredential rwdAcc)
140140
141141queryStakeAddrWithCache ::
142142 forall m .
143143 MonadIO m =>
144- Trace IO Text ->
144+ SyncEnv ->
145145 CacheStatus ->
146146 CacheAction ->
147147 Network ->
148148 StakeCred ->
149149 ReaderT SqlBackend m (Either DB. LookupFail DB. StakeAddressId )
150- queryStakeAddrWithCache trce cache cacheUA nw cred =
151- mapLeft fst <$> queryStakeAddrWithCacheRetBs trce cache cacheUA nw cred
150+ queryStakeAddrWithCache syncEnv cache cacheUA nw cred =
151+ mapLeft fst <$> queryStakeAddrWithCacheRetBs syncEnv cache cacheUA nw cred
152152
153153queryStakeAddrWithCacheRetBs ::
154154 forall m .
155155 MonadIO m =>
156- Trace IO Text ->
156+ SyncEnv ->
157157 CacheStatus ->
158158 CacheAction ->
159159 Network ->
160160 StakeCred ->
161161 ReaderT SqlBackend m (Either (DB. LookupFail , ByteString ) DB. StakeAddressId )
162- queryStakeAddrWithCacheRetBs cache cacheUA nw cred = do
162+ queryStakeAddrWithCacheRetBs syncEnv cache cacheUA nw cred = do
163+ let ! bs = Ledger. serialiseRewardAccount (Ledger. RewardAccount nw cred)
163164 case cache of
164165 NoCache -> do
165166 mapLeft (,bs) <$> queryStakeAddress bs
@@ -170,10 +171,10 @@ queryStakeAddrWithCacheRetBs cache cacheUA nw cred = do
170171 currentCache <-
171172 if isNewCache
172173 then do
173- liftIO $ logInfo trce " Stake Raw Hashes cache is new and empty. Populating with addresses from db..."
174+ liftIO $ logInfo (getTrace syncEnv) " Stake Raw Hashes cache is new and empty. Populating with addresses from db..."
174175 queryRes <- DB. queryAddressWithReward (fromIntegral $ LRU. getCapacity prevCache)
175176 liftIO $ atomically $ writeTVar (cStakeRawHashes ci) $ LRU. fromList queryRes prevCache
176- liftIO $ logInfo trce " Population of cache complete."
177+ liftIO $ logInfo (getTrace syncEnv) " Population of cache complete."
177178 liftIO $ readTVarIO (cStakeRawHashes ci)
178179 else pure prevCache
179180
@@ -202,12 +203,11 @@ queryStakeAddrWithCacheRetBs cache cacheUA nw cred = do
202203
203204queryPoolKeyWithCache ::
204205 MonadIO m =>
205- SyncEnv ->
206206 CacheStatus ->
207207 CacheAction ->
208208 PoolKeyHash ->
209209 ReaderT SqlBackend m (Either DB. LookupFail DB. PoolHashId )
210- queryPoolKeyWithCache syncEnv cache cacheUA hsh =
210+ queryPoolKeyWithCache cache cacheUA hsh =
211211 case cache of
212212 NoCache -> do
213213 mPhId <- queryPoolHashId (Generic. unKeyHashRaw hsh)
@@ -290,13 +290,13 @@ queryPoolKeyOrInsert ::
290290 PoolKeyHash ->
291291 ReaderT SqlBackend m DB. PoolHashId
292292queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do
293- pk <- queryPoolKeyWithCache syncEnv cache cacheUA hsh
293+ pk <- queryPoolKeyWithCache cache cacheUA hsh
294294 case pk of
295295 Right poolHashId -> pure poolHashId
296296 Left err -> do
297297 when logsWarning $
298298 liftIO $
299- logWarning trce $
299+ logWarning (getTrace syncEnv) $
300300 mconcat
301301 [ " Failed with "
302302 , DB. textShow err
@@ -310,7 +310,7 @@ queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do
310310
311311queryMAWithCache ::
312312 MonadIO m =>
313- Cache ->
313+ CacheStatus ->
314314 PolicyID StandardCrypto ->
315315 AssetName ->
316316 ReaderT SqlBackend m (Either (ByteString , ByteString ) DB. MultiAssetId )
0 commit comments