Skip to content

Commit 4a6d871

Browse files
jonathanknowlesKtorZ
authored andcommitted
Rename delistPools to putDelistedPools.
This operation completely replaces the set of delisted pools, rather than augmenting it. Therefore, the name `delistPools` is slightly misleading, as it gives the impression that the existing set will be augmented, which is no longer true. In response to review feedback: #2277 (comment)
1 parent 4ac83b9 commit 4a6d871

File tree

6 files changed

+21
-20
lines changed

6 files changed

+21
-20
lines changed

lib/core/src/Cardano/Pool/DB.hs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -213,14 +213,15 @@ data DBLayer m = forall stm. (MonadFail stm, MonadIO stm) => DBLayer
213213
-> stm ()
214214
-- ^ Remove all entries of slot ids newer than the argument
215215

216-
, delistPools
216+
, putDelistedPools
217217
:: [PoolId]
218218
-> stm ()
219-
-- ^ Mark pools as delisted, e.g. due to non-compliance.
220-
-- This is stored as an attribute in the pool_registration table.
219+
-- ^ Overwrite the set of delisted pools with a completely new set.
220+
-- Pools may be delisted for reasons such as non-compliance.
221221

222222
, readDelistedPools
223223
:: stm [PoolId]
224+
-- ^ Fetch the set of delisted pools.
224225

225226
, removePools
226227
:: [PoolId]

lib/core/src/Cardano/Pool/DB/MVar.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,11 @@ import Cardano.Pool.DB.Model
2626
, emptyPoolDatabase
2727
, mCleanDatabase
2828
, mCleanPoolMetadata
29-
, mDelistPools
3029
, mListHeaders
3130
, mListPoolLifeCycleData
3231
, mListRegisteredPools
3332
, mListRetiredPools
33+
, mPutDelistedPools
3434
, mPutFetchAttempt
3535
, mPutHeader
3636
, mPutLastMetadataGC
@@ -150,8 +150,8 @@ newDBLayer timeInterpreter = do
150150
rollbackTo =
151151
void . alterPoolDB (const Nothing) db . mRollbackTo timeInterpreter
152152

153-
delistPools =
154-
void . alterPoolDB (const Nothing) db . mDelistPools
153+
putDelistedPools =
154+
void . alterPoolDB (const Nothing) db . mPutDelistedPools
155155

156156
readDelistedPools =
157157
readPoolDB db mReadDelistedPools

lib/core/src/Cardano/Pool/DB/Model.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ module Cardano.Pool.DB.Model
5151
, mPutPoolRetirement
5252
, mReadPoolRetirement
5353
, mUnfetchedPoolMetadataRefs
54+
, mPutDelistedPools
5455
, mPutFetchAttempt
5556
, mPutPoolMetadata
5657
, mListPoolLifeCycleData
@@ -61,7 +62,6 @@ module Cardano.Pool.DB.Model
6162
, mRollbackTo
6263
, mReadCursor
6364
, mRemovePools
64-
, mDelistPools
6565
, mReadDelistedPools
6666
, mRemoveRetiredPools
6767
, mReadSettings
@@ -431,8 +431,8 @@ mRollbackTo ti point = do
431431
| point' <= getPoint point = Just v
432432
| otherwise = Nothing
433433

434-
mDelistPools :: [PoolId] -> ModelOp ()
435-
mDelistPools = modify #delisted . const . Set.fromList
434+
mPutDelistedPools :: [PoolId] -> ModelOp ()
435+
mPutDelistedPools = modify #delisted . const . Set.fromList
436436

437437
mReadDelistedPools :: ModelOp [PoolId]
438438
mReadDelistedPools = Set.toList <$> get #delisted

lib/core/src/Cardano/Pool/DB/Sqlite.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ newDBLayer trace fp timeInterpreter = do
491491
deleteWhere [ BlockSlot >. point ]
492492
-- TODO: remove dangling metadata no longer attached to a pool
493493

494-
delistPools pools = do
494+
putDelistedPools pools = do
495495
deleteWhere ([] :: [Filter PoolDelistment])
496496
insertMany_ $ fmap PoolDelistment pools
497497

lib/core/test/unit/Cardano/Pool/DB/Properties.hs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,10 @@ properties = do
223223
(property . prop_modSettingsReadSettings)
224224
it "putLastMetadataGC . readLastMetadataGC == id"
225225
(property . prop_putLastMetadataGCReadLastMetadataGC)
226-
it "delistPools >> readDelistedPools shows the pool as delisted"
227-
(property . prop_delistPools)
226+
it "putDelistedPools >> readDelistedPools shows the pool as delisted"
227+
(property . prop_putDelistedPools)
228228
it "delisting a pools persists even if a new certificate is registered"
229-
(property . prop_delistPoolsPersists)
229+
(property . prop_putDelistedPoolsPersists)
230230

231231
{-------------------------------------------------------------------------------
232232
Properties
@@ -1459,11 +1459,11 @@ prop_putLastMetadataGCReadLastMetadataGC DBLayer{..} posixTime = do
14591459
assertWith "Setting sync time and reading afterwards works"
14601460
(time == Just posixTime)
14611461

1462-
prop_delistPools
1462+
prop_putDelistedPools
14631463
:: DBLayer IO
14641464
-> [(CertificatePublicationTime, PoolRegistrationCertificate)]
14651465
-> Property
1466-
prop_delistPools DBLayer {..} entries =
1466+
prop_putDelistedPools DBLayer {..} entries =
14671467
monadicIO (setup >> prop)
14681468
where
14691469
setup = run $ atomically cleanDB
@@ -1486,7 +1486,7 @@ prop_delistPools DBLayer {..} entries =
14861486

14871487
-- delist pools
14881488
let poolsToDelist = L.sort $ fmap (view #poolId . snd) entriesIn
1489-
run $ atomically $ delistPools poolsToDelist
1489+
run $ atomically $ putDelistedPools poolsToDelist
14901490
poolsDelisted <- L.sort <$> run (atomically readDelistedPools)
14911491
monitor $ counterexample $ unlines
14921492
[ "Pools to delist: "
@@ -1497,11 +1497,11 @@ prop_delistPools DBLayer {..} entries =
14971497
assertWith "poolsToDelist == poolsDelisted"
14981498
$ poolsToDelist == poolsDelisted
14991499

1500-
prop_delistPoolsPersists
1500+
prop_putDelistedPoolsPersists
15011501
:: DBLayer IO
15021502
-> (CertificatePublicationTime, PoolRegistrationCertificate)
15031503
-> Property
1504-
prop_delistPoolsPersists DBLayer {..} cert =
1504+
prop_putDelistedPoolsPersists DBLayer {..} cert =
15051505
monadicIO (setup >> prop)
15061506
where
15071507
setup = run $ atomically cleanDB
@@ -1510,7 +1510,7 @@ prop_delistPoolsPersists DBLayer {..} cert =
15101510

15111511
let poolid = view #poolId . snd $ cert
15121512
-- delist pool
1513-
run $ atomically $ delistPools [poolid]
1513+
run $ atomically $ putDelistedPools [poolid]
15141514
delisted <- run $ atomically readDelistedPools
15151515
let expected = [poolid]
15161516
assertWith "expected == delisted"

lib/shelley/src/Cardano/Wallet/Shelley/Pools.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -830,7 +830,7 @@ gcDelistedPools gcStatus tr DBLayer{..} fetchDelisted = forever $ do
830830
STM.atomically $ writeTVar gcStatus (HasRun currentTime)
831831
atomically $ do
832832
putLastMetadataGC currentTime
833-
delistPools delistedPools
833+
putDelistedPools delistedPools
834834

835835
-- Sleep for 60 seconds. This is useful in case
836836
-- something else is modifying the last sync time

0 commit comments

Comments
 (0)