Skip to content

Commit

Permalink
Replace panicAbort with logError
Browse files Browse the repository at this point in the history
  • Loading branch information
kderme committed Oct 26, 2021
1 parent 1e964e0 commit 3bd5caf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cardano-db-sync/src/Cardano/DbSync/Era/Shelley/Validate.hs
Expand Up @@ -56,7 +56,7 @@ validateEpochRewards tracer nw currentEpoch rmap = do
[ "validateEpochRewards: total rewards that become spendable in epoch "
, textShow (unEpochNo currentEpoch), " is ", textShow actual, " ADA"
]
validateRewardWithdrawals currentEpoch
validateRewardWithdrawals tracer currentEpoch
where
expected :: Db.Ada
expected = Db.word64ToAda . fromIntegral . sum $ map unCoin (Map.elems rmap)
Expand Down
Expand Up @@ -8,6 +8,8 @@ import Control.Monad.IO.Class (MonadIO, liftIO)
import Control.Monad.Trans.Control (MonadBaseControl)
import Control.Monad.Trans.Reader (ReaderT)

import Cardano.BM.Trace (Trace, logError)

import Cardano.Db (Ada (..))
import qualified Cardano.Db as Db
import Cardano.Slotting.Slot (EpochNo (..))
Expand All @@ -31,16 +33,16 @@ import Database.Persist.Sql (SqlBackend)

validateRewardWithdrawals
:: (MonadBaseControl IO m, MonadIO m)
=> EpochNo -> ReaderT SqlBackend m ()
validateRewardWithdrawals (EpochNo epochNo) = do
=> Trace IO Text -> EpochNo -> ReaderT SqlBackend m ()
validateRewardWithdrawals trce (EpochNo epochNo) = do
res <- mapM validateAccounting =<< queryWithdrawalAddresses
_bad <- queryBadWithdrawals
liftIO $
case partitionEithers res of
([], _) -> pure ()
(xs, _) -> do
putStr $ show (length xs) ++ " errors, eg\n" ++ unlines (map reportError xs)
panicAbort $ "validateRewardWithdrawals: " <> textShow epochNo
logError trce $ textShow (length xs) <> " errors, eg\n" <> Text.unlines (map reportError xs)
logError trce $ "validateRewardWithdrawals: " <> textShow epochNo

-- -----------------------------------------------------------------------------

Expand All @@ -50,8 +52,8 @@ data AddressInfo = AddressInfo
, aiSumWithdrawals :: !Ada
} deriving (Eq, Ord, Show)

reportError :: AddressInfo -> String
reportError ai =
reportError :: AddressInfo -> Text
reportError ai = Text.pack $
mconcat
[ " ", Text.unpack (aiStakeAddress ai), " rewards are ", show (aiSumRewards ai)
, " ADA and withdrawals are ", show (aiSumWithdrawals ai), " ADA\n"
Expand Down

0 comments on commit 3bd5caf

Please sign in to comment.