Skip to content

Commit

Permalink
Fix stylish and hlint
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed May 26, 2022
1 parent ecb5ecd commit bd15a2d
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 23 deletions.
6 changes: 3 additions & 3 deletions cardano-chain-gen/src/Cardano/Mock/Forging/Tx/Alonzo.hs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

module Cardano.Mock.Forging.Tx.Alonzo where

import Cardano.Prelude hiding (sum, (.))
import Cardano.Prelude hiding (head, sum, (.))

import qualified Data.Map.Strict as Map
import Data.Maybe (fromJust)
Expand Down Expand Up @@ -39,7 +39,7 @@ import Cardano.Ledger.Hashes
import Cardano.Ledger.Keys
import Cardano.Ledger.Mary.Value
import Cardano.Ledger.Shelley.Metadata
import Cardano.Ledger.Shelley.PParams hiding (emptyPParamsUpdate, _protocolVersion)
import Cardano.Ledger.Shelley.PParams hiding (_protocolVersion, emptyPParamsUpdate)
import Cardano.Ledger.Shelley.TxBody (DCert (..), PoolCert (..), PoolMetadata (..),
PoolParams (..), StakePoolRelay (..), Wdrl (..))
import Cardano.Ledger.ShelleyMA.Timelocks
Expand Down Expand Up @@ -86,7 +86,7 @@ mkHFTx =
mkSimpleTx True $ TxBody a b c d e f n (Strict.SJust upd) i j k l m
where
TxBody a b c d e f n _ i j k l m = emptyTxBody
upd = Update (ProposedPPUpdates $ Map.singleton (unregisteredGenesisKeys !! 0) pparams) (EpochNo 1)
upd = Update (ProposedPPUpdates $ Map.singleton (head unregisteredGenesisKeys) pparams) (EpochNo 1)
pparams = emptyPParamsUpdate {_protocolVersion = Strict.SJust $ ProtVer 7 0}

addValidityInterval :: SlotNo
Expand Down
6 changes: 4 additions & 2 deletions cardano-db-sync/src/Cardano/DbSync/Cache.hs
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,8 @@ queryMAWithCache cache policyId asset =
case cache of
UninitiatedCache -> do
let !bs = Generic.unScriptHash $ policyID policyId
fmap (maybe (Left bs) Right) $ DB.queryMultiAssetId bs (unAssetName asset)
maybe (Left bs) Right
<$> DB.queryMultiAssetId bs (unAssetName asset)
Cache ci -> do
mp <- liftIO $ readTVarIO (cMultiAssets ci)
case LRU.lookup (policyId, asset) mp of
Expand All @@ -352,7 +353,8 @@ queryMAWithCache cache policyId asset =
liftIO $ missMAssets (cStats ci)
-- miss. The lookup doesn't change the cache on a miss.
let !bs = Generic.unScriptHash $ policyID policyId
maId <- fmap (maybe (Left bs) Right) $ DB.queryMultiAssetId bs (unAssetName asset)
maId <- maybe (Left bs) Right
<$> DB.queryMultiAssetId bs (unAssetName asset)
whenRight maId $
liftIO . atomically . modifyTVar (cMultiAssets ci) . LRU.insert (policyId, asset)
pure maId
Expand Down
5 changes: 3 additions & 2 deletions cardano-db-sync/src/Cardano/DbSync/Default.hs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ import Cardano.DbSync.Era.Shelley.Insert (insertShelleyBlock)
import Cardano.DbSync.Era.Shelley.Insert.Epoch (insertPoolDepositRefunds, insertRewards)
import Cardano.DbSync.Era.Shelley.Validate (validateEpochRewards)
import Cardano.DbSync.Error
import Cardano.DbSync.LedgerState (LedgerEvent (..), ApplyResult (..), applyBlockAndSnapshot)
import Cardano.DbSync.LedgerState (ApplyResult (..), LedgerEvent (..),
applyBlockAndSnapshot)
import Cardano.DbSync.Rollback (rollbackToPoint)
import Cardano.DbSync.Types
import Cardano.DbSync.Util
Expand All @@ -43,8 +44,8 @@ import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.Strict.Maybe as Strict

import Database.Persist.SqlBackend.Internal.StatementCache
import Database.Persist.SqlBackend.Internal
import Database.Persist.SqlBackend.Internal.StatementCache

import Ouroboros.Consensus.Cardano.Block (HardForkBlock (..))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ data Reward = Reward
-- Shelley/Allegra/Mary. This is a huge pain in the neck for `db-sync` so we define a
-- generic one instead.
newtype Rewards = Rewards
{ rwdRewards :: (Map StakeCred (Set Reward))
{ rwdRewards :: Map StakeCred (Set Reward)
} deriving (Eq, Show)

elemCount :: Rewards -> Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ import qualified Cardano.Ledger.Shelley.LedgerState as Shelley

import Cardano.DbSync.Types

import Data.VMap (VB, VMap (..), VP)
import qualified Data.VMap as VMap
import qualified Data.Map.Strict as Map
import qualified Data.Vector.Generic as VG
import Data.VMap (VB, VMap (..), VP)
import qualified Data.VMap as VMap

import Ouroboros.Consensus.Block
import Ouroboros.Consensus.Cardano.Block (LedgerState (..), StandardCrypto)
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ insertStaking tracer cache blkId genesis = do
}
let params = zip [0..] $ Map.elems (sgsPools $ sgStaking genesis)
let network = sgNetworkId genesis
forM_ params $ uncurry (insertPoolRegister tracer uninitiatedCache (\_ -> False) network 0 blkId txId)
forM_ params $ uncurry (insertPoolRegister tracer uninitiatedCache (const False) network 0 blkId txId)
let stakes = zip [0..] $ Map.toList (sgsStake $ sgStaking genesis)
forM_ stakes $ \(n, (keyStaking, keyPool)) -> do
insertStakeRegistration (EpochNo 0) txId (2 * n) (Generic.annotateStakingCred network (KeyHashObj keyStaking))
Expand Down
6 changes: 2 additions & 4 deletions cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Insert.hs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE TypeOperators #-}

module Cardano.DbSync.Era.Shelley.Insert
( insertShelleyBlock
Expand Down Expand Up @@ -49,8 +47,8 @@ import qualified Cardano.Ledger.BaseTypes as Ledger
import Cardano.Ledger.Coin (Coin (..))
import qualified Cardano.Ledger.Coin as Ledger
import qualified Cardano.Ledger.Credential as Ledger
import qualified Cardano.Ledger.Keys as Ledger
import Cardano.Ledger.Keys
import qualified Cardano.Ledger.Keys as Ledger
import Cardano.Ledger.Mary.Value (AssetName (..), PolicyID (..), Value (..))
import qualified Cardano.Ledger.Shelley.API.Wallet as Shelley
import qualified Cardano.Ledger.Shelley.TxBody as Shelley
Expand Down Expand Up @@ -944,7 +942,7 @@ insertMultiAsset cache policy a@(AssetName aName) = do
mId <- queryMAWithCache cache policy a
case mId of
Right maId -> pure maId
Left (policyBs) -> DB.insertMultiAssetUnchecked $
Left policyBs -> DB.insertMultiAssetUnchecked $
DB.MultiAsset
{ DB.multiAssetPolicy = policyBs
, DB.multiAssetName = aName
Expand Down
8 changes: 4 additions & 4 deletions cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ import Cardano.DbSync.Util (textShow)

import Cardano.Ledger.Coin (Coin (..))
import Cardano.Ledger.Crypto (StandardCrypto)
import qualified Cardano.Ledger.Shelley.Rewards as Ledger
import Cardano.Ledger.Shelley.API (Network)
import qualified Cardano.Ledger.Shelley.Rewards as Ledger

import Cardano.Slotting.Slot (EpochNo (..))

Expand All @@ -35,14 +35,14 @@ import qualified Data.Map.Strict as Map
import qualified Data.Set as Set

import Database.Esqueleto.Experimental (InnerJoin (InnerJoin), SqlBackend, Value (Value),
desc, from, not_, on, orderBy, select, table, val, where_, (:&) ((:&)),
(==.), (^.))
desc, from, not_, on, orderBy, select, table, val, where_, (:&) ((:&)), (==.),
(^.))

{- HLINT ignore "Fuse on/on" -}

validateEpochRewards
:: (MonadBaseControl IO m, MonadIO m)
=> Trace IO Text -> Network -> EpochNo -> EpochNo -> (Map StakeCred (Set (Ledger.Reward StandardCrypto)))
=> Trace IO Text -> Network -> EpochNo -> EpochNo -> Map StakeCred (Set (Ledger.Reward StandardCrypto))
-> ReaderT SqlBackend m ()
validateEpochRewards tracer network _earnedEpochNo spendableEpochNo rmap = do
actualCount <- Db.queryNormalEpochRewardCount (unEpochNo spendableEpochNo)
Expand Down
2 changes: 1 addition & 1 deletion cardano-db-tool/src/Cardano/DbTool/Validate/Ledger.hs
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ module Cardano.DbTool.Validate.Ledger

import Control.Monad (when)
import Control.Monad.Trans.Except.Exit (orDie)
import Control.Tracer (nullTracer)
import Data.Text (Text)
import qualified Data.Text as Text
import Control.Tracer (nullTracer)
import Prelude

import qualified Cardano.Db as DB
Expand Down
6 changes: 3 additions & 3 deletions cardano-db/src/Cardano/Db/Query.hs
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ import Database.Esqueleto.Experimental (Entity, From, PersistEntity, P
SqlBackend, SqlExpr, SqlQuery, Value (Value, unValue), ValueList, count,
countRows, desc, entityKey, entityVal, exists, from, in_, innerJoin, isNothing,
just, leftJoin, limit, max_, min_, notExists, not_, on, orderBy, select,
subList_select, sum_, table, type (:&) ((:&)), unSqlBackendKey, val, valList, where_,
(&&.), (<=.), (==.), (>.), (>=.), (?.), (^.), (||.))
subList_select, sum_, table, type (:&) ((:&)), unSqlBackendKey, val, valList,
where_, (&&.), (<=.), (==.), (>.), (>=.), (?.), (^.), (||.))
import Database.Esqueleto.Experimental.From (ToFrom (..))
import Database.Persist.Class.PersistQuery (selectList)

Expand Down Expand Up @@ -447,7 +447,7 @@ queryNormalEpochRewardCount epochNum = do
res <- select $ do
rwd <- from $ table @Reward
where_ (rwd ^. RewardSpendableEpoch ==. val epochNum)
where_ (rwd ^. RewardType `in_` (valList [RwdMember, RwdLeader]))
where_ (rwd ^. RewardType `in_` valList [RwdMember, RwdLeader])
pure countRows
pure $ maybe 0 unValue (listToMaybe res)

Expand Down

0 comments on commit bd15a2d

Please sign in to comment.