-
Notifications
You must be signed in to change notification settings - Fork 213
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2047: Add pool DB operation `removeRetiredPools`. r=jonathanknowles a=jonathanknowles # Issue Number #2018 # Overview Building on the work added in PRs #2024 and #2038, this PR: - [x] Adds a `removeRetiredPools` operation to the pool DB layer:<br><br> ```hs removeRetiredPools :: EpochNo -> stm [PoolRetirementCertificate] -- ^ Remove all pools with an active retirement epoch that is earlier -- than or equal to the specified epoch. -- -- Returns the retirement certificates of the pools that were removed. ``` - [x] Writes a bracketed `MsgRemovingRetiredPools` message to the log whenever the `removeRetiredPools` operation is called:<br><br> ``` Looking for pools that retired in or before epoch 1000. Removing the following retired pools: Pool 4355a46b with retirement epoch 999 Pool 53c234e5 with retirement epoch 999 Pool 121cfccd with retirement epoch 1000 Pool 917df332 with retirement epoch 1000 Finished removing retired pools. ``` # Further Work Before garbage collection can actually happen, the wallet needs to call `removeRetiredPools` at appropriate intervals. This work is deferred to a future PR. See issue #2019. Co-authored-by: Jonathan Knowles <jonathan.knowles@iohk.io>
- Loading branch information
Showing
13 changed files
with
127 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
{-# LANGUAGE LambdaCase #-} | ||
|
||
-- | | ||
-- Copyright: © 2018-2020 IOHK | ||
-- License: Apache-2.0 | ||
-- | ||
-- Logging types specific to the pool database. | ||
-- | ||
module Cardano.Pool.DB.Log | ||
( PoolDbLog (..) | ||
) where | ||
|
||
import Prelude | ||
|
||
import Cardano.BM.Data.Severity | ||
( Severity (..) ) | ||
import Cardano.BM.Data.Tracer | ||
( HasPrivacyAnnotation (..), HasSeverityAnnotation (..) ) | ||
import Cardano.DB.Sqlite | ||
( DBLog (..) ) | ||
import Cardano.Wallet.Logging | ||
( BracketLog ) | ||
import Cardano.Wallet.Primitive.Types | ||
( EpochNo, PoolId, PoolRetirementCertificate ) | ||
import Data.Text.Class | ||
( ToText (..), toText ) | ||
import Fmt | ||
( pretty ) | ||
|
||
import qualified Data.Text as T | ||
|
||
data PoolDbLog | ||
= MsgGeneric DBLog | ||
| MsgRemovingPool PoolId | ||
| MsgRemovingRetiredPools [PoolRetirementCertificate] | ||
| MsgRemovingRetiredPoolsForEpoch EpochNo BracketLog | ||
deriving (Eq, Show) | ||
|
||
instance HasPrivacyAnnotation PoolDbLog | ||
|
||
instance HasSeverityAnnotation PoolDbLog where | ||
getSeverityAnnotation = \case | ||
MsgGeneric e -> getSeverityAnnotation e | ||
MsgRemovingPool {} -> Notice | ||
MsgRemovingRetiredPools {} -> Debug | ||
MsgRemovingRetiredPoolsForEpoch {} -> Debug | ||
|
||
instance ToText PoolDbLog where | ||
toText = \case | ||
MsgGeneric e -> toText e | ||
MsgRemovingPool p -> mconcat | ||
[ "Removing the following pool from the database: " | ||
, toText p | ||
, "." | ||
] | ||
MsgRemovingRetiredPools [] -> | ||
"There are no retired pools to remove." | ||
MsgRemovingRetiredPools poolRetirementCerts -> T.unlines | ||
[ "Removing the following retired pools:" | ||
, T.unlines (pretty <$> poolRetirementCerts) | ||
] | ||
MsgRemovingRetiredPoolsForEpoch epoch nestedMessage -> T.concat | ||
[ "Removing pools that retired in or before epoch " | ||
, toText epoch | ||
, ": " | ||
, toText nestedMessage | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters