Skip to content

Commit 42b6061

Browse files
committed
db-analyser: don't let .Types depend on .Analysis
In a later commit, this is useful to avoid cyclic imports when adding new types to `.Types` that are also used in other modules.
1 parent a718db0 commit 42b6061

File tree

2 files changed

+53
-56
lines changed
  • ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser

2 files changed

+53
-56
lines changed

ouroboros-consensus-cardano/src/unstable-cardano-tools/Cardano/Tools/DBAnalyser/Analysis.hs

Lines changed: 13 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
{-# LANGUAGE BangPatterns #-}
2-
{-# LANGUAGE BlockArguments #-}
3-
{-# LANGUAGE DataKinds #-}
4-
{-# LANGUAGE FlexibleContexts #-}
5-
{-# LANGUAGE GADTs #-}
6-
{-# LANGUAGE GeneralisedNewtypeDeriving #-}
7-
{-# LANGUAGE LambdaCase #-}
8-
{-# LANGUAGE NamedFieldPuns #-}
9-
{-# LANGUAGE OverloadedStrings #-}
10-
{-# LANGUAGE ScopedTypeVariables #-}
11-
{-# LANGUAGE TupleSections #-}
12-
{-# LANGUAGE TypeApplications #-}
13-
{-# LANGUAGE TypeFamilies #-}
1+
{-# LANGUAGE BangPatterns #-}
2+
{-# LANGUAGE BlockArguments #-}
3+
{-# LANGUAGE DataKinds #-}
4+
{-# LANGUAGE FlexibleContexts #-}
5+
{-# LANGUAGE GADTs #-}
6+
{-# LANGUAGE LambdaCase #-}
7+
{-# LANGUAGE NamedFieldPuns #-}
8+
{-# LANGUAGE OverloadedStrings #-}
9+
{-# LANGUAGE ScopedTypeVariables #-}
10+
{-# LANGUAGE TupleSections #-}
11+
{-# LANGUAGE TypeApplications #-}
12+
{-# LANGUAGE TypeFamilies #-}
1413

1514
module Cardano.Tools.DBAnalyser.Analysis (
1615
AnalysisEnv (..)
@@ -33,6 +32,7 @@ import Cardano.Tools.DBAnalyser.CSV (computeAndWriteLine,
3332
writeHeaderLine)
3433
import Cardano.Tools.DBAnalyser.HasAnalysis (HasAnalysis)
3534
import qualified Cardano.Tools.DBAnalyser.HasAnalysis as HasAnalysis
35+
import Cardano.Tools.DBAnalyser.Types
3636
import Codec.CBOR.Encoding (Encoding)
3737
import Control.Monad (unless, void, when)
3838
import Control.Monad.Except (runExcept)
@@ -83,39 +83,6 @@ import qualified System.IO as IO
8383
Run the requested analysis
8484
-------------------------------------------------------------------------------}
8585

86-
data AnalysisName =
87-
ShowSlotBlockNo
88-
| CountTxOutputs
89-
| ShowBlockHeaderSize
90-
| ShowBlockTxsSize
91-
| ShowEBBs
92-
| OnlyValidation
93-
| StoreLedgerStateAt SlotNo LedgerApplicationMode
94-
| CountBlocks
95-
| CheckNoThunksEvery Word64
96-
| TraceLedgerProcessing
97-
| BenchmarkLedgerOps (Maybe FilePath)
98-
| ReproMempoolAndForge Int
99-
-- | Compute different block application metrics every 'NumberOfBlocks'.
100-
--
101-
-- The metrics will be written to the provided file path, or to
102-
-- the standard output if no file path is specified.
103-
| GetBlockApplicationMetrics NumberOfBlocks (Maybe FilePath)
104-
deriving Show
105-
106-
data AnalysisResult =
107-
ResultCountBlock Int
108-
| ResultMaxHeaderSize Word16
109-
deriving (Eq, Show)
110-
111-
newtype NumberOfBlocks = NumberOfBlocks { unNumberOfBlocks :: Word64 }
112-
deriving (Eq, Show, Num, Read)
113-
114-
-- | Whether to apply blocks to a ledger state via /reapplication/ (eg skipping
115-
-- signature checks/Plutus scripts) or full /application/ (much slower).
116-
data LedgerApplicationMode = LedgerReapply | LedgerApply
117-
deriving (Eq, Show)
118-
11986
runAnalysis ::
12087
forall blk.
12188
( HasAnalysis blk
@@ -877,8 +844,6 @@ reproMempoolForge numBlks env = do
877844
Auxiliary: processing all blocks in the DB
878845
-------------------------------------------------------------------------------}
879846

880-
data Limit = Limit Int | Unlimited
881-
882847
decreaseLimit :: Limit -> Maybe Limit
883848
decreaseLimit Unlimited = Just Unlimited
884849
decreaseLimit (Limit 0) = Nothing
Lines changed: 40 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
module Cardano.Tools.DBAnalyser.Types (
2-
module AnalysisTypes
3-
, module Cardano.Tools.DBAnalyser.Types
4-
) where
5-
6-
import Cardano.Tools.DBAnalyser.Analysis as AnalysisTypes
7-
(AnalysisName (..), AnalysisResult (..), Limit (..),
8-
NumberOfBlocks (..))
1+
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
2+
3+
module Cardano.Tools.DBAnalyser.Types (module Cardano.Tools.DBAnalyser.Types) where
4+
5+
import Data.Word
96
import Ouroboros.Consensus.Block
107

118
data SelectDB =
@@ -20,6 +17,41 @@ data DBAnalyserConfig = DBAnalyserConfig {
2017
, confLimit :: Limit
2118
}
2219

20+
data AnalysisName =
21+
ShowSlotBlockNo
22+
| CountTxOutputs
23+
| ShowBlockHeaderSize
24+
| ShowBlockTxsSize
25+
| ShowEBBs
26+
| OnlyValidation
27+
| StoreLedgerStateAt SlotNo LedgerApplicationMode
28+
| CountBlocks
29+
| CheckNoThunksEvery Word64
30+
| TraceLedgerProcessing
31+
| BenchmarkLedgerOps (Maybe FilePath)
32+
| ReproMempoolAndForge Int
33+
-- | Compute different block application metrics every 'NumberOfBlocks'.
34+
--
35+
-- The metrics will be written to the provided file path, or to
36+
-- the standard output if no file path is specified.
37+
| GetBlockApplicationMetrics NumberOfBlocks (Maybe FilePath)
38+
deriving Show
39+
40+
data AnalysisResult =
41+
ResultCountBlock Int
42+
| ResultMaxHeaderSize Word16
43+
deriving (Eq, Show)
44+
45+
newtype NumberOfBlocks = NumberOfBlocks { unNumberOfBlocks :: Word64 }
46+
deriving (Eq, Show, Num, Read)
47+
48+
data Limit = Limit Int | Unlimited
49+
2350
-- | The extent of the ChainDB on-disk files validation. This is completely
2451
-- unrelated to validation of the ledger rules.
2552
data ValidateBlocks = ValidateAllBlocks | MinimumBlockValidation
53+
54+
-- | Whether to apply blocks to a ledger state via /reapplication/ (eg skipping
55+
-- signature checks/Plutus scripts) or full /application/ (much slower).
56+
data LedgerApplicationMode = LedgerReapply | LedgerApply
57+
deriving (Eq, Show)

0 commit comments

Comments
 (0)