Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
199 additions
and
167 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,42 @@ | ||
{-# LANGUAGE DeriveAnyClass #-} | ||
{-# LANGUAGE DeriveGeneric #-} | ||
{-# LANGUAGE LambdaCase #-} | ||
{-# LANGUAGE RankNTypes #-} | ||
{-# LANGUAGE ScopedTypeVariables #-} | ||
{-# OPTIONS_GHC -Wno-deprecations #-} | ||
{- HLINT ignore "Use head" -} | ||
module Cardano.Analysis.ChainFilter (module Cardano.Analysis.ChainFilter) where | ||
|
||
import Cardano.Prelude hiding (head) | ||
|
||
import Data.Aeson | ||
|
||
import Cardano.Unlog.SlotStats | ||
|
||
|
||
-- | Conditions for chain subsetting | ||
data ChainFilter | ||
= CBlock BlockCond | ||
| CSlot SlotCond | ||
deriving (FromJSON, Generic, NFData, Show, ToJSON) | ||
|
||
-- | Block classification -- primary for validity as subjects of analysis. | ||
data BlockCond | ||
= BUnitaryChainDelta | ||
-- ^ All timings account for processing of a single block. | ||
| BFullnessAbove Double | ||
-- ^ Block fullness is above fraction. | ||
deriving (FromJSON, Generic, NFData, Show, ToJSON) | ||
|
||
|
||
cfIsSlotCond, cfIsBlockCond :: ChainFilter -> Bool | ||
cfIsSlotCond = \case { CSlot{} -> True; _ -> False; } | ||
cfIsBlockCond = \case { CBlock{} -> True; _ -> False; } | ||
|
||
catSlotFilters :: [ChainFilter] -> [SlotCond] | ||
catSlotFilters = go [] where | ||
go :: [SlotCond] -> [ChainFilter] -> [SlotCond] | ||
go acc = \case | ||
[] -> reverse acc | ||
CSlot c:rest -> go (c:acc) rest | ||
_:rest -> go acc rest |
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
Oops, something went wrong.