@@ -71,8 +71,8 @@ import Ouroboros.Consensus.Cardano.Block (StandardCrypto)
71
71
-- a different id.
72
72
-- NOTE: Other tables are not cleaned up since they are not rollbacked.
73
73
rollbackCache :: 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
76
76
liftIO $ do
77
77
atomically $ writeTVar (cPrevBlock cache) Nothing
78
78
atomically $ modifyTVar (cDatum cache) LRU. cleanup
@@ -92,7 +92,7 @@ queryOrInsertRewardAccount ::
92
92
Ledger. RewardAccount StandardCrypto ->
93
93
ReaderT SqlBackend m DB. StakeAddressId
94
94
queryOrInsertRewardAccount syncEnv cache cacheNew rewardAddr = do
95
- eiAddrId <- queryRewardAccountWithCacheRetBs cache cacheNew rewardAddr
95
+ eiAddrId <- queryRewardAccountWithCacheRetBs syncEnv cache cacheNew rewardAddr
96
96
case eiAddrId of
97
97
Left (_err, bs) -> insertStakeAddress syncEnv rewardAddr (Just bs)
98
98
Right addrId -> pure addrId
@@ -130,36 +130,37 @@ insertStakeAddress _syncEnv rewardAddr stakeCredBs = do
130
130
queryRewardAccountWithCacheRetBs ::
131
131
forall m .
132
132
MonadIO m =>
133
- Trace IO Text ->
133
+ SyncEnv ->
134
134
CacheStatus ->
135
135
CacheAction ->
136
136
Ledger. RewardAccount StandardCrypto ->
137
137
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)
140
140
141
141
queryStakeAddrWithCache ::
142
142
forall m .
143
143
MonadIO m =>
144
- Trace IO Text ->
144
+ SyncEnv ->
145
145
CacheStatus ->
146
146
CacheAction ->
147
147
Network ->
148
148
StakeCred ->
149
149
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
152
152
153
153
queryStakeAddrWithCacheRetBs ::
154
154
forall m .
155
155
MonadIO m =>
156
- Trace IO Text ->
156
+ SyncEnv ->
157
157
CacheStatus ->
158
158
CacheAction ->
159
159
Network ->
160
160
StakeCred ->
161
161
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)
163
164
case cache of
164
165
NoCache -> do
165
166
mapLeft (,bs) <$> queryStakeAddress bs
@@ -170,10 +171,10 @@ queryStakeAddrWithCacheRetBs cache cacheUA nw cred = do
170
171
currentCache <-
171
172
if isNewCache
172
173
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..."
174
175
queryRes <- DB. queryAddressWithReward (fromIntegral $ LRU. getCapacity prevCache)
175
176
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."
177
178
liftIO $ readTVarIO (cStakeRawHashes ci)
178
179
else pure prevCache
179
180
@@ -202,12 +203,11 @@ queryStakeAddrWithCacheRetBs cache cacheUA nw cred = do
202
203
203
204
queryPoolKeyWithCache ::
204
205
MonadIO m =>
205
- SyncEnv ->
206
206
CacheStatus ->
207
207
CacheAction ->
208
208
PoolKeyHash ->
209
209
ReaderT SqlBackend m (Either DB. LookupFail DB. PoolHashId )
210
- queryPoolKeyWithCache syncEnv cache cacheUA hsh =
210
+ queryPoolKeyWithCache cache cacheUA hsh =
211
211
case cache of
212
212
NoCache -> do
213
213
mPhId <- queryPoolHashId (Generic. unKeyHashRaw hsh)
@@ -290,13 +290,13 @@ queryPoolKeyOrInsert ::
290
290
PoolKeyHash ->
291
291
ReaderT SqlBackend m DB. PoolHashId
292
292
queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do
293
- pk <- queryPoolKeyWithCache syncEnv cache cacheUA hsh
293
+ pk <- queryPoolKeyWithCache cache cacheUA hsh
294
294
case pk of
295
295
Right poolHashId -> pure poolHashId
296
296
Left err -> do
297
297
when logsWarning $
298
298
liftIO $
299
- logWarning trce $
299
+ logWarning (getTrace syncEnv) $
300
300
mconcat
301
301
[ " Failed with "
302
302
, DB. textShow err
@@ -310,7 +310,7 @@ queryPoolKeyOrInsert txt syncEnv cache cacheUA logsWarning hsh = do
310
310
311
311
queryMAWithCache ::
312
312
MonadIO m =>
313
- Cache ->
313
+ CacheStatus ->
314
314
PolicyID StandardCrypto ->
315
315
AssetName ->
316
316
ReaderT SqlBackend m (Either (ByteString , ByteString ) DB. MultiAssetId )
0 commit comments