Skip to content

Commit 8d97d17

Browse files
committed
remove deadcode from project using weeder
1 parent db19ff4 commit 8d97d17

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+74
-3336
lines changed

cardano-db-sync/cardano-db-sync.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,6 @@ library
199199
, ouroboros-network-framework
200200
, ouroboros-network-protocols
201201
, plutus-ledger-api
202-
, pretty-show
203202
, prometheus
204203
, psqueues
205204
, random-shuffle
@@ -217,7 +216,6 @@ library
217216
, transformers
218217
, transformers-except
219218
, typed-protocols
220-
, unix
221219
, vector
222220
, wide-word
223221
, yaml

cardano-db-sync/src/Cardano/DbSync/Api.hs

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ module Cardano.DbSync.Api (
1212
setConsistentLevel,
1313
getConsistentLevel,
1414
isConsistent,
15-
getIsConsumedFixed,
1615
getDisableInOutState,
1716
getRanIndexes,
1817
runIndexesMigrations,
@@ -110,16 +109,6 @@ isConsistent env = do
110109
Consistent -> pure True
111110
_otherwise -> pure False
112111

113-
getIsConsumedFixed :: SyncEnv -> IO (Maybe Word64)
114-
getIsConsumedFixed env =
115-
case (DB.pcmPruneTxOut pcm, DB.pcmConsumedTxOut pcm) of
116-
(False, True) -> Just <$> DB.runDbIohkNoLogging backend (DB.queryWrongConsumedBy txOutVariantType)
117-
_otherwise -> pure Nothing
118-
where
119-
txOutVariantType = getTxOutVariantType env
120-
pcm = soptPruneConsumeMigration $ envOptions env
121-
backend = envDbEnv env
122-
123112
getDisableInOutState :: SyncEnv -> IO Bool
124113
getDisableInOutState syncEnv = do
125114
bst <- readTVarIO $ envBootstrap syncEnv

cardano-db-sync/src/Cardano/DbSync/Cache/Epoch.hs

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
{-# LANGUAGE NoImplicitPrelude #-}
33

44
module Cardano.DbSync.Cache.Epoch (
5-
readCacheEpoch,
65
readEpochBlockDiffFromCache,
76
readLastMapEpochFromCache,
87
rollbackMapEpochInCache,
@@ -25,14 +24,6 @@ import Data.Map.Strict (deleteMin, insert, lookupMax, size, split)
2524
-------------------------------------------------------------------------------------
2625
-- Epoch Cache
2726
-------------------------------------------------------------------------------------
28-
readCacheEpoch :: MonadIO m => CacheStatus -> m (Maybe CacheEpoch)
29-
readCacheEpoch cache =
30-
case cache of
31-
NoCache -> pure Nothing
32-
ActiveCache ci -> do
33-
cacheEpoch <- liftIO $ readTVarIO (cEpoch ci)
34-
pure $ Just cacheEpoch
35-
3627
readEpochBlockDiffFromCache :: MonadIO m => CacheStatus -> m (Maybe EpochBlockDiff)
3728
readEpochBlockDiffFromCache cache =
3829
case cache of

cardano-db-sync/src/Cardano/DbSync/Cache/LRU.hs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ module Cardano.DbSync.Cache.LRU (
88
optimise,
99
trim,
1010
insert,
11-
fromList,
12-
delete,
1311
lookup,
1412
getSize,
1513
getCapacity,
@@ -76,14 +74,6 @@ insert k v cache =
7674
where
7775
(_mbOldVal, queue) = OrdPSQ.insertView k (cTick cache) v (cQueue cache) -- Insert the new entry
7876

79-
-- fromList inserts into a cache from a list of key-value pairs.
80-
fromList :: Ord k => [(k, v)] -> LRUCache k v -> LRUCache k v
81-
fromList kvs cache = foldl' (\c (k, v) -> insert k v c) cache kvs
82-
83-
delete :: Ord k => k -> LRUCache k v -> LRUCache k v
84-
delete key cache =
85-
cache {cQueue = OrdPSQ.delete key (cQueue cache)}
86-
8777
-- lookup retrieves a value from the cache by its key, updating the access order.
8878
-- It returns the value and the updated cache.
8979
lookup :: Ord k => k -> LRUCache k v -> Maybe (v, LRUCache k v)

cardano-db-sync/src/Cardano/DbSync/Config.hs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ module Cardano.DbSync.Config (
1515
SyncProtocol (..),
1616
SyncNodeConfig (..),
1717
SyncNodeParams (..),
18-
cardanoLedgerConfig,
1918
genesisProtocolMagicId,
2019
readCardanoGenesisConfig,
2120
readSyncNodeConfig,

cardano-db-sync/src/Cardano/DbSync/Config/Cardano.hs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
module Cardano.DbSync.Config.Cardano (
99
GenesisConfig (..),
10-
cardanoLedgerConfig,
1110
genesisProtocolMagicId,
1211
mkTopLevelConfig,
1312
mkProtocolInfoCardano,
@@ -36,7 +35,6 @@ import qualified Ouroboros.Consensus.Cardano as Consensus
3635
import Ouroboros.Consensus.Cardano.Block (StandardCrypto)
3736
import Ouroboros.Consensus.Cardano.Node
3837
import Ouroboros.Consensus.Config (TopLevelConfig (..), emptyCheckpointsMap)
39-
import Ouroboros.Consensus.Ledger.Basics (LedgerConfig)
4038
import Ouroboros.Consensus.Node.ProtocolInfo (ProtocolInfo)
4139
import qualified Ouroboros.Consensus.Node.ProtocolInfo as Consensus
4240
import Ouroboros.Consensus.Shelley.Node (ShelleyGenesis (..))
@@ -72,9 +70,6 @@ readCardanoGenesisConfig enc =
7270

7371
-- -------------------------------------------------------------------------------------------------
7472

75-
cardanoLedgerConfig :: GenesisConfig -> LedgerConfig CardanoBlock
76-
cardanoLedgerConfig = topLevelConfigLedger . mkTopLevelConfig
77-
7873
mkTopLevelConfig :: GenesisConfig -> TopLevelConfig CardanoBlock
7974
mkTopLevelConfig cfg = Consensus.pInfoConfig $ fst $ mkProtocolInfoCardano cfg []
8075

cardano-db-sync/src/Cardano/DbSync/DbEvent.hs

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,13 @@ module Cardano.DbSync.DbEvent (
1414
writeDbEventQueue,
1515
waitRollback,
1616
waitRestartState,
17-
waitDoneInit,
18-
runAndSetDone,
1917
) where
2018

2119
import qualified Cardano.Db as DB
2220
import Cardano.DbSync.Error (SyncNodeError (..))
2321
import Cardano.DbSync.Types
2422
import Cardano.Prelude
25-
import Control.Concurrent.Class.MonadSTM.Strict (StrictTMVar, StrictTVar, newEmptyTMVarIO, newTVarIO, readTVar, readTVarIO, takeTMVar, writeTVar)
23+
import Control.Concurrent.Class.MonadSTM.Strict (StrictTMVar, StrictTVar, newEmptyTMVarIO, newTVarIO, takeTMVar)
2624
import qualified Control.Concurrent.STM as STM
2725
import Control.Concurrent.STM.TBQueue (TBQueue)
2826
import qualified Control.Concurrent.STM.TBQueue as TBQ
@@ -82,21 +80,6 @@ waitRestartState tc = do
8280
writeDbEventQueue tc $ DbRestartState resultVar
8381
atomically $ takeTMVar resultVar
8482

85-
waitDoneInit :: ThreadChannels -> IO ()
86-
waitDoneInit tc = atomically $ do
87-
isDone <- readTVar (tcDoneInit tc)
88-
unless isDone retry
89-
90-
runAndSetDone :: ThreadChannels -> IO Bool -> IO Bool
91-
runAndSetDone tc action = do
92-
isDone <- readTVarIO (tcDoneInit tc)
93-
if isDone
94-
then pure True
95-
else do
96-
fl <- action
97-
atomically $ writeTVar (tcDoneInit tc) fl
98-
pure fl
99-
10083
lengthDbEventQueue :: ThreadChannels -> STM Natural
10184
lengthDbEventQueue = STM.lengthTBQueue . tcQueue
10285

cardano-db-sync/src/Cardano/DbSync/Era/Byron/Util.hs

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,14 @@
44
{-# LANGUAGE NoImplicitPrelude #-}
55

66
module Cardano.DbSync.Era.Byron.Util (
7-
boundaryEpochNumber,
8-
configSlotDuration,
97
mkSlotLeader,
108
slotLeaderHash,
119
unAbstractHash,
12-
unAddressHash,
13-
unCryptoHash,
1410
blockHash,
1511
blockNumber,
1612
blockPayload,
1713
blockPreviousHash,
1814
ebbPrevHash,
19-
prevHash,
20-
epochNumber,
2115
genesisToHeaderHash,
2216
protocolVersion,
2317
renderAbstractHash,
@@ -45,14 +39,6 @@ import qualified Data.ByteString.Base16 as Base16
4539
import qualified Data.ByteString.Char8 as BS
4640
import qualified Data.ByteString.Lazy.Char8 as LBS
4741
import qualified Data.Text.Encoding as Text
48-
import qualified Ouroboros.Consensus.Byron.Ledger.Block as Byron
49-
50-
boundaryEpochNumber :: Byron.ABoundaryBlock ByteString -> Word64
51-
boundaryEpochNumber = Byron.boundaryEpoch . Byron.boundaryHeader
52-
53-
configSlotDuration :: Byron.Config -> Word64
54-
configSlotDuration =
55-
fromIntegral . Byron.ppSlotDuration . Byron.gdProtocolParameters . Byron.configGenesisData
5642

5743
mkSlotLeader :: Byron.ABlock ByteString -> DB.SlotLeader
5844
mkSlotLeader blk =
@@ -75,12 +61,6 @@ slotLeaderHash =
7561
unAbstractHash :: Crypto.Hash Raw -> ByteString
7662
unAbstractHash = Crypto.abstractHashToBytes
7763

78-
unAddressHash :: Byron.AddressHash Byron.Address' -> ByteString
79-
unAddressHash = Crypto.abstractHashToBytes
80-
81-
unCryptoHash :: Crypto.Hash Raw -> ByteString
82-
unCryptoHash = Crypto.abstractHashToBytes
83-
8464
blockHash :: Byron.ABlock ByteString -> ByteString
8565
blockHash = unHeaderHash . Byron.blockHashAnnotated
8666

@@ -101,15 +81,6 @@ ebbPrevHash bblock =
10181
Left gh -> genesisToHeaderHash gh
10282
Right hh -> unHeaderHash hh
10383

104-
prevHash :: Byron.ByronBlock -> ByteString
105-
prevHash blk = case Byron.byronBlockRaw blk of
106-
Byron.ABOBBlock ablk -> blockPreviousHash ablk
107-
Byron.ABOBBoundary abblk -> ebbPrevHash abblk
108-
109-
epochNumber :: Byron.ABlock ByteString -> Word64 -> Word64
110-
epochNumber blk slotsPerEpoch =
111-
slotNumber blk `div` slotsPerEpoch
112-
11384
genesisToHeaderHash :: Byron.GenesisHash -> ByteString
11485
genesisToHeaderHash = unAbstractHash . Byron.unGenesisHash
11586

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Metadata.hs

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ module Cardano.DbSync.Era.Shelley.Generic.Metadata (
1515
fromShelleyMetadata,
1616
fromMaryMetadata,
1717
metadataValueToJsonNoSchema,
18-
txMetadataValueToText,
1918
fromMetadatum,
20-
toMetadatum,
2119
) where
2220

2321
import qualified Cardano.Ledger.Allegra.TxAuxData as Allegra
@@ -93,14 +91,6 @@ metadataValueToJsonNoSchema = conv
9391
. Aeson.Text.encodeToLazyText
9492
$ conv v
9593

96-
txMetadataValueToText :: TxMetadataValue -> Text
97-
txMetadataValueToText val
98-
| (TxMetaMap pairs) <- val = Text.intercalate ", " $ map (\(k, v) -> txMetadataValueToText k <> ": " <> txMetadataValueToText v) pairs
99-
| (TxMetaList values) <- val = "[" <> Text.intercalate ", " (map txMetadataValueToText values) <> "]"
100-
| (TxMetaNumber num) <- val = Text.pack (show num)
101-
| (TxMetaBytes bytes) <- val = Text.decodeUtf8 bytes
102-
| (TxMetaText text) <- val = text
103-
10494
-- -------------------------------------------------------------------------------------------------
10595

10696
-- | JSON strings that are base16 encoded and prefixed with 'bytesPrefix' will
@@ -115,11 +105,3 @@ fromMetadatum = \case
115105
Shelley.S x -> TxMetaText x
116106
Shelley.List xs -> TxMetaList $ map fromMetadatum xs
117107
Shelley.Map xs -> TxMetaMap $ map (both fromMetadatum) xs
118-
119-
toMetadatum :: TxMetadataValue -> Shelley.Metadatum
120-
toMetadatum = \case
121-
TxMetaNumber n -> Shelley.I n
122-
TxMetaBytes b -> Shelley.B b
123-
TxMetaText s -> Shelley.S s
124-
TxMetaList xs -> Shelley.List $ map toMetadatum xs
125-
TxMetaMap ms -> Shelley.Map $ map (both toMetadatum) ms

cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Generic/Rewards.hs

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,9 @@ module Cardano.DbSync.Era.Shelley.Generic.Rewards (
99
RewardRest (..),
1010
RewardRests (..),
1111
rewardsCount,
12-
rewardsTotalAda,
1312
) where
1413

15-
import Cardano.Db (Ada, RewardSource (..), word64ToAda)
14+
import Cardano.Db (RewardSource (..))
1615
import Cardano.DbSync.Types
1716
import Cardano.Ledger.Coin (Coin (..))
1817
import Cardano.Prelude
@@ -45,11 +44,3 @@ newtype RewardRests = RewardRests
4544

4645
rewardsCount :: Rewards -> Int
4746
rewardsCount = sum . map Set.size . Map.elems . unRewards
48-
49-
rewardsTotalAda :: Rewards -> Ada
50-
rewardsTotalAda rwds =
51-
word64ToAda
52-
. fromIntegral
53-
. sum
54-
. concatMap (map (unCoin . rewardAmount) . Set.toList)
55-
$ Map.elems (unRewards rwds)

0 commit comments

Comments
 (0)