@@ -249,37 +249,37 @@ poolDelegationTransition = do
249
249
{ mismatchSupplied = ppCost
250
250
, mismatchExpected = minPoolCost
251
251
}
252
- let mbStakePoolState = Map. lookup ppId psStakePools
253
- let hasMatchingVRF = ((^. spsVrfL) <$> mbStakePoolState) == Just ppVrf
254
- when (hardforkConwayDisallowDuplicatedVRFKeys pv) $ do
255
- -- if the VRF key is not associated with this pool (either because the pool is not registered
256
- -- or because the VRF key is different from the one registered for this pool),
257
- -- then we check that this VRF key is not already in use
258
- hasMatchingVRF
259
- || Set. notMember ppVrf psVRFKeyHashes
260
- ?! VRFKeyHashAlreadyRegistered ppId ppVrf
261
- case mbStakePoolState of
252
+ case Map. lookup ppId psStakePools of
253
+ -- register new, Pool-Reg
262
254
Nothing -> do
263
- -- register new, Pool-Reg
255
+ when (hardforkConwayDisallowDuplicatedVRFKeys pv) $ do
256
+ Set. notMember ppVrf psVRFKeyHashes ?! VRFKeyHashAlreadyRegistered ppId ppVrf
257
+ let updateVRFKeyHash
258
+ | hardforkConwayDisallowDuplicatedVRFKeys pv = Set. insert ppVrf
259
+ | otherwise = id
264
260
tellEvent $ RegisterPool ppId
265
261
pure $
266
262
payPoolDeposit ppId pp $
267
263
ps
268
264
& psStakePoolsL %~ Map. insert ppId (mkStakePoolState poolParams)
269
- & psVRFKeyHashesL %~ Set. insert ppVrf
270
- Just _ -> do
271
- -- re-register Pool
272
-
273
- -- If a pool re-registers with a fresh VRF, we have to add it to the list,
274
- -- but also remove the previous VRFHashKey potentially stored in previous re-registration within the same epoch,
275
- -- which we can retrieve from futureStakePools. We first delete and then insert the new one,
276
- -- so in case they are the same, it will still end up in the set.
277
- let updateVRFs
278
- | hasMatchingVRF = id
279
- | otherwise = psVRFKeyHashesL %~ (Set. insert ppVrf . withoutFutureVrf)
280
- where
281
- withoutFutureVrf s = maybe s (`Set.delete` s) futureVrf
282
- futureVrf = (^. spsVrfL) <$> Map. lookup ppId psFutureStakePools
265
+ & psVRFKeyHashesL %~ updateVRFKeyHash
266
+ -- re-register Pool
267
+ Just stakePoolState -> do
268
+ when (hardforkConwayDisallowDuplicatedVRFKeys pv) $ do
269
+ ppVrf == stakePoolState ^. spsVrfL
270
+ || Set. notMember ppVrf psVRFKeyHashes ?! VRFKeyHashAlreadyRegistered ppId ppVrf
271
+ let updateFutureVRFKeyHash
272
+ | hardforkConwayDisallowDuplicatedVRFKeys pv =
273
+ -- If a pool re-registers with a fresh VRF, we have to add it to the list,
274
+ -- but also remove the previous VRFHashKey potentially stored in previous re-registration within the same epoch,
275
+ -- which we retrieve from futureStakePools.
276
+ case Map. lookup ppId psFutureStakePools of
277
+ Nothing -> Set. insert ppVrf
278
+ Just futureStakePoolState
279
+ | futureStakePoolState ^. spsVrfL /= ppVrf ->
280
+ Set. insert ppVrf . Set. delete (futureStakePoolState ^. spsVrfL)
281
+ | otherwise -> id
282
+ | otherwise = id
283
283
tellEvent $ ReregisterPool ppId
284
284
-- hk is already registered, so we want to reregister it. That means adding it
285
285
-- to the Future pool params (if it is not there already), and overriding the
@@ -294,7 +294,7 @@ poolDelegationTransition = do
294
294
ps
295
295
& psFutureStakePoolsL %~ Map. insert ppId (mkStakePoolState poolParams)
296
296
& psRetiringL %~ Map. delete ppId
297
- & updateVRFs
297
+ & psVRFKeyHashesL %~ updateFutureVRFKeyHash
298
298
RetirePool ppId e -> do
299
299
Map. member ppId psStakePools ?! StakePoolNotRegisteredOnKeyPOOL ppId
300
300
let maxEpoch = pp ^. ppEMaxL
0 commit comments