@@ -39,7 +39,8 @@ import Cardano.DbSync.Ledger.Event
39
39
import Cardano.DbSync.Types
40
40
import Cardano.DbSync.Util (whenStrictJust )
41
41
import Cardano.DbSync.Util.Constraint (constraintNameEpochStake , constraintNameReward )
42
- import Cardano.Ledger.Address (RewardAccount (.. ))
42
+ import Cardano.DbSync.Util.Whitelist (shelleyStakeAddrWhitelistCheck )
43
+ import qualified Cardano.Ledger.Address as Ledger
43
44
import Cardano.Ledger.BaseTypes (Network , unEpochInterval )
44
45
import qualified Cardano.Ledger.BaseTypes as Ledger
45
46
import Cardano.Ledger.Binary.Version (getVersion )
@@ -215,21 +216,23 @@ insertEpochStake syncEnv nw epochNo stakeChunk = do
215
216
CacheStatus ->
216
217
(StakeCred , (Shelley. Coin , PoolKeyHash )) ->
217
218
ExceptT SyncNodeError (ReaderT SqlBackend m ) (Maybe DB. EpochStake )
218
- mkStake cache (saddr, (coin, pool)) = do
219
- mSaId <- lift $ queryOrInsertStakeAddress syncEnv cache CacheNew nw saddr
220
- poolId <- lift $ queryPoolKeyOrInsert " insertEpochStake" syncEnv cache CacheNew (isShelleyEnabled $ ioShelley iopts) pool
221
- case mSaId of
222
- Nothing -> pure Nothing
223
- Just saId ->
224
- pure $
225
- Just $
226
- DB. EpochStake
227
- { DB. epochStakeAddrId = saId
228
- , DB. epochStakePoolId = poolId
229
- , DB. epochStakeAmount = Generic. coinToDbLovelace coin
230
- , DB. epochStakeEpochNo = unEpochNo epochNo -- The epoch where this delegation becomes valid.
231
- }
232
-
219
+ mkStake cache (saddr, (coin, pool)) =
220
+ -- Check if the stake address is in the shelley whitelist
221
+ if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger. RewardAcnt nw saddr
222
+ then
223
+ ( do
224
+ saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache nw saddr
225
+ poolId <- lift $ queryPoolKeyOrInsert " insertEpochStake" syncEnv cache UpdateCache (isShelleyNotDisabled $ ioShelley iopts) pool
226
+ pure $
227
+ Just $
228
+ DB. EpochStake
229
+ { DB. epochStakeAddrId = saId
230
+ , DB. epochStakePoolId = poolId
231
+ , DB. epochStakeAmount = Generic. coinToDbLovelace coin
232
+ , DB. epochStakeEpochNo = unEpochNo epochNo -- The epoch where this delegation becomes valid.
233
+ }
234
+ )
235
+ else pure Nothing
233
236
iopts = getInsertOptions syncEnv
234
237
235
238
insertRewards ::
@@ -252,11 +255,13 @@ insertRewards syncEnv nw earnedEpoch spendableEpoch cache rewardsChunk = do
252
255
(MonadBaseControl IO m , MonadIO m ) =>
253
256
(StakeCred , Set Generic. Reward ) ->
254
257
ExceptT SyncNodeError (ReaderT SqlBackend m ) [DB. Reward ]
255
- mkRewards (saddr, rset) = do
256
- mSaId <- lift $ queryOrInsertStakeAddress syncEnv cache CacheNew nw saddr
257
- case mSaId of
258
- Nothing -> pure []
259
- Just saId -> mapM (prepareReward saId) (Set. toList rset)
258
+ mkRewards (saddr, rset) =
259
+ -- Check if the stake address is in the shelley whitelist
260
+ if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger. RewardAcnt nw saddr
261
+ then do
262
+ saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache nw saddr
263
+ mapM (prepareReward saId) (Set. toList rset)
264
+ else pure []
260
265
261
266
prepareReward ::
262
267
(MonadBaseControl IO m , MonadIO m ) =>
@@ -280,8 +285,7 @@ insertRewards syncEnv nw earnedEpoch spendableEpoch cache rewardsChunk = do
280
285
PoolKeyHash ->
281
286
ExceptT SyncNodeError (ReaderT SqlBackend m ) DB. PoolHashId
282
287
queryPool poolHash =
283
- lift (queryPoolKeyOrInsert " insertRewards" syncEnv cache CacheNew (isShelleyEnabled $ ioShelley iopts) poolHash)
284
-
288
+ lift (queryPoolKeyOrInsert " insertRewards" syncEnv cache UpdateCache (isShelleyEnabled $ ioShelley iopts) poolHash)
285
289
iopts = getInsertOptions syncEnv
286
290
287
291
insertRewardRests ::
@@ -303,11 +307,13 @@ insertInstantRewards syncEnv nw earnedEpoch spendableEpoch cache rewardsChunk =
303
307
(MonadBaseControl IO m , MonadIO m ) =>
304
308
(StakeCred , Set Generic. RewardRest ) ->
305
309
ExceptT SyncNodeError (ReaderT SqlBackend m ) [DB. RewardRest ]
306
- mkRewards (saddr, rset) = do
307
- mSaId <- lift $ queryOrInsertStakeAddress syncEnv cache CacheNew nw saddr
308
- case mSaId of
309
- Nothing -> pure []
310
- Just saId -> pure $ map (prepareReward saId) (Set. toList rset)
310
+ mkRewards (saddr, rset) =
311
+ -- Check if the stake address is in the shelley whitelist
312
+ if shelleyStakeAddrWhitelistCheck syncEnv $ Ledger. RewardAccount nw saddr
313
+ then do
314
+ saId <- lift $ queryOrInsertStakeAddress syncEnv cache UpdateCache nw saddr
315
+ pure $ map (prepareReward saId) (Set. toList rset)
316
+ else pure []
311
317
312
318
prepareReward ::
313
319
DB. StakeAddressId ->
0 commit comments