@@ -30,7 +30,7 @@ import Cardano.BM.Trace
30
30
import qualified Cardano.Db as DB
31
31
import Cardano.DbSync.Cache.Epoch (rollbackMapEpochInCache )
32
32
import qualified Cardano.DbSync.Cache.LRU as LRU
33
- import Cardano.DbSync.Cache.Types (CacheInternal (.. ), CacheNew (.. ), CacheStatistics (.. ), CacheStatus (.. ), StakeAddrCache , initCacheStatistics )
33
+ import Cardano.DbSync.Cache.Types (CacheInternal (.. ), CacheStatistics (.. ), CacheStatus (.. ), CacheUpdateAction (.. ), StakeAddrCache , initCacheStatistics )
34
34
import qualified Cardano.DbSync.Era.Shelley.Generic.Util as Generic
35
35
import Cardano.DbSync.Era.Shelley.Query
36
36
import Cardano.DbSync.Era.Util
@@ -84,24 +84,24 @@ getCacheStatistics cs =
84
84
queryOrInsertRewardAccount ::
85
85
(MonadBaseControl IO m , MonadIO m ) =>
86
86
CacheStatus ->
87
- CacheNew ->
87
+ CacheUpdateAction ->
88
88
Ledger. RewardAccount StandardCrypto ->
89
89
ReaderT SqlBackend m DB. StakeAddressId
90
- queryOrInsertRewardAccount cacheStatus cacheNew rewardAddr = do
91
- eiAddrId <- queryRewardAccountWithCacheRetBs cacheStatus cacheNew rewardAddr
90
+ queryOrInsertRewardAccount cacheStatus cacheUA rewardAddr = do
91
+ eiAddrId <- queryRewardAccountWithCacheRetBs cacheStatus cacheUA rewardAddr
92
92
case eiAddrId of
93
93
Left (_err, bs) -> insertStakeAddress rewardAddr (Just bs)
94
94
Right addrId -> pure addrId
95
95
96
96
queryOrInsertStakeAddress ::
97
97
(MonadBaseControl IO m , MonadIO m ) =>
98
98
CacheStatus ->
99
- CacheNew ->
99
+ CacheUpdateAction ->
100
100
Network ->
101
101
StakeCred ->
102
102
ReaderT SqlBackend m DB. StakeAddressId
103
- queryOrInsertStakeAddress cacheStatus cacheNew nw cred =
104
- queryOrInsertRewardAccount cacheStatus cacheNew $ Ledger. RewardAccount nw cred
103
+ queryOrInsertStakeAddress cacheStatus cacheUA nw cred =
104
+ queryOrInsertRewardAccount cacheStatus cacheUA $ Ledger. RewardAccount nw cred
105
105
106
106
-- If the address already exists in the table, it will not be inserted again (due to
107
107
-- the uniqueness constraint) but the function will return the 'StakeAddressId'.
@@ -124,73 +124,73 @@ queryRewardAccountWithCacheRetBs ::
124
124
forall m .
125
125
MonadIO m =>
126
126
CacheStatus ->
127
- CacheNew ->
127
+ CacheUpdateAction ->
128
128
Ledger. RewardAccount StandardCrypto ->
129
129
ReaderT SqlBackend m (Either (DB. LookupFail , ByteString ) DB. StakeAddressId )
130
- queryRewardAccountWithCacheRetBs cacheStatus cacheNew rwdAcc =
131
- queryStakeAddrWithCacheRetBs cacheStatus cacheNew (Ledger. raNetwork rwdAcc) (Ledger. raCredential rwdAcc)
130
+ queryRewardAccountWithCacheRetBs cacheStatus cacheUA rwdAcc =
131
+ queryStakeAddrWithCacheRetBs cacheStatus cacheUA (Ledger. raNetwork rwdAcc) (Ledger. raCredential rwdAcc)
132
132
133
133
queryStakeAddrWithCache ::
134
134
forall m .
135
135
MonadIO m =>
136
136
CacheStatus ->
137
- CacheNew ->
137
+ CacheUpdateAction ->
138
138
Network ->
139
139
StakeCred ->
140
140
ReaderT SqlBackend m (Either DB. LookupFail DB. StakeAddressId )
141
- queryStakeAddrWithCache cacheStatus cacheNew nw cred =
142
- mapLeft fst <$> queryStakeAddrWithCacheRetBs cacheStatus cacheNew nw cred
141
+ queryStakeAddrWithCache cacheStatus cacheUA nw cred =
142
+ mapLeft fst <$> queryStakeAddrWithCacheRetBs cacheStatus cacheUA nw cred
143
143
144
144
queryStakeAddrWithCacheRetBs ::
145
145
forall m .
146
146
MonadIO m =>
147
147
CacheStatus ->
148
- CacheNew ->
148
+ CacheUpdateAction ->
149
149
Network ->
150
150
StakeCred ->
151
151
ReaderT SqlBackend m (Either (DB. LookupFail , ByteString ) DB. StakeAddressId )
152
- queryStakeAddrWithCacheRetBs cacheStatus cacheNew nw cred = do
152
+ queryStakeAddrWithCacheRetBs cacheStatus cacheUA nw cred = do
153
153
case cacheStatus of
154
154
NoCache -> do
155
155
let ! bs = Ledger. serialiseRewardAccount (Ledger. RewardAccount nw cred)
156
156
mapLeft (,bs) <$> queryStakeAddress bs
157
157
ActiveCache ci -> do
158
158
mp <- liftIO $ readTVarIO (cStakeCreds ci)
159
- (mAddrId, mp') <- queryStakeAddrAux cacheNew mp (cStats ci) nw cred
159
+ (mAddrId, mp') <- queryStakeAddrAux cacheUA mp (cStats ci) nw cred
160
160
liftIO $ atomically $ writeTVar (cStakeCreds ci) mp'
161
161
pure mAddrId
162
162
163
163
queryStakeAddrAux ::
164
164
MonadIO m =>
165
- CacheNew ->
165
+ CacheUpdateAction ->
166
166
StakeAddrCache ->
167
167
StrictTVar IO CacheStatistics ->
168
168
Network ->
169
169
StakeCred ->
170
170
ReaderT SqlBackend m (Either (DB. LookupFail , ByteString ) DB. StakeAddressId , StakeAddrCache )
171
- queryStakeAddrAux cacheNew mp sts nw cred =
171
+ queryStakeAddrAux cacheUA mp sts nw cred =
172
172
case Map. lookup cred mp of
173
173
Just addrId -> do
174
174
liftIO $ hitCreds sts
175
- case cacheNew of
176
- EvictAndReturn -> pure (Right addrId, Map. delete cred mp)
175
+ case cacheUA of
176
+ EvictAndUpdateCache -> pure (Right addrId, Map. delete cred mp)
177
177
_ -> pure (Right addrId, mp)
178
178
Nothing -> do
179
179
liftIO $ missCreds sts
180
180
let ! bs = Ledger. serialiseRewardAccount (Ledger. RewardAccount nw cred)
181
181
mAddrId <- mapLeft (,bs) <$> queryStakeAddress bs
182
- case (mAddrId, cacheNew ) of
183
- (Right addrId, CacheNew ) -> pure (Right addrId, Map. insert cred addrId mp)
182
+ case (mAddrId, cacheUA ) of
183
+ (Right addrId, UpdateCache ) -> pure (Right addrId, Map. insert cred addrId mp)
184
184
(Right addrId, _) -> pure (Right addrId, mp)
185
185
(err, _) -> pure (err, mp)
186
186
187
187
queryPoolKeyWithCache ::
188
188
MonadIO m =>
189
189
CacheStatus ->
190
- CacheNew ->
190
+ CacheUpdateAction ->
191
191
PoolKeyHash ->
192
192
ReaderT SqlBackend m (Either DB. LookupFail DB. PoolHashId )
193
- queryPoolKeyWithCache cacheStatus cacheNew hsh =
193
+ queryPoolKeyWithCache cacheStatus cacheUA hsh =
194
194
case cacheStatus of
195
195
NoCache -> do
196
196
mPhId <- queryPoolHashId (Generic. unKeyHashRaw hsh)
@@ -203,7 +203,7 @@ queryPoolKeyWithCache cacheStatus cacheNew hsh =
203
203
Just phId -> do
204
204
liftIO $ hitPools (cStats ci)
205
205
-- hit so we can't cache even with 'CacheNew'
206
- when (cacheNew == EvictAndReturn ) $
206
+ when (cacheUA == EvictAndUpdateCache ) $
207
207
liftIO $
208
208
atomically $
209
209
modifyTVar (cPools ci) $
@@ -216,7 +216,7 @@ queryPoolKeyWithCache cacheStatus cacheNew hsh =
216
216
Nothing -> pure $ Left (DB. DbLookupMessage " PoolKeyHash" )
217
217
Just phId -> do
218
218
-- missed so we can't evict even with 'EvictAndReturn'
219
- when (cacheNew == CacheNew ) $
219
+ when (cacheUA == UpdateCache ) $
220
220
liftIO $
221
221
atomically $
222
222
modifyTVar (cPools ci) $
@@ -226,10 +226,10 @@ queryPoolKeyWithCache cacheStatus cacheNew hsh =
226
226
insertPoolKeyWithCache ::
227
227
(MonadBaseControl IO m , MonadIO m ) =>
228
228
CacheStatus ->
229
- CacheNew ->
229
+ CacheUpdateAction ->
230
230
PoolKeyHash ->
231
231
ReaderT SqlBackend m DB. PoolHashId
232
- insertPoolKeyWithCache cacheStatus cacheNew pHash =
232
+ insertPoolKeyWithCache cacheStatus cacheUA pHash =
233
233
case cacheStatus of
234
234
NoCache ->
235
235
DB. insertPoolHash $
@@ -242,7 +242,7 @@ insertPoolKeyWithCache cacheStatus cacheNew pHash =
242
242
case Map. lookup pHash mp of
243
243
Just phId -> do
244
244
liftIO $ hitPools (cStats ci)
245
- when (cacheNew == EvictAndReturn ) $
245
+ when (cacheUA == EvictAndUpdateCache ) $
246
246
liftIO $
247
247
atomically $
248
248
modifyTVar (cPools ci) $
@@ -256,7 +256,7 @@ insertPoolKeyWithCache cacheStatus cacheNew pHash =
256
256
{ DB. poolHashHashRaw = Generic. unKeyHashRaw pHash
257
257
, DB. poolHashView = Generic. unKeyHashView pHash
258
258
}
259
- when (cacheNew == CacheNew ) $
259
+ when (cacheUA == UpdateCache ) $
260
260
liftIO $
261
261
atomically $
262
262
modifyTVar (cPools ci) $
@@ -268,12 +268,12 @@ queryPoolKeyOrInsert ::
268
268
Text ->
269
269
Trace IO Text ->
270
270
CacheStatus ->
271
- CacheNew ->
271
+ CacheUpdateAction ->
272
272
Bool ->
273
273
PoolKeyHash ->
274
274
ReaderT SqlBackend m DB. PoolHashId
275
- queryPoolKeyOrInsert txt trce cacheStatus cacheNew logsWarning hsh = do
276
- pk <- queryPoolKeyWithCache cacheStatus cacheNew hsh
275
+ queryPoolKeyOrInsert txt trce cacheStatus cacheUA logsWarning hsh = do
276
+ pk <- queryPoolKeyWithCache cacheStatus cacheUA hsh
277
277
case pk of
278
278
Right poolHashId -> pure poolHashId
279
279
Left err -> do
@@ -289,7 +289,7 @@ queryPoolKeyOrInsert txt trce cacheStatus cacheNew logsWarning hsh = do
289
289
, txt
290
290
, " . We will assume that the pool exists and move on."
291
291
]
292
- insertPoolKeyWithCache cacheStatus cacheNew hsh
292
+ insertPoolKeyWithCache cacheStatus cacheUA hsh
293
293
294
294
queryMAWithCache ::
295
295
MonadIO m =>
0 commit comments