Skip to content

Commit

Permalink
Make readTotalProduction fail fast on encountering a parse failure.
Browse files Browse the repository at this point in the history
In response to review feedback:

#2111 (comment)
  • Loading branch information
jonathanknowles committed Sep 8, 2020
1 parent f1cca8b commit 88ce82e
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/core/src/Cardano/Pool/DB/Sqlite.hs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,12 @@ newDBLayer trace fp timeInterpreter = do
pure (foldl' toMap Map.empty production)

readTotalProduction =
Map.fromList . rights . fmap parseRow <$> rawSql query []
Map.fromList . fmap (assertSuccess . parseRow) <$> rawSql query []
where
assertSuccess = flip either id $ \e -> error $ mconcat
[ "readTotalProduction: unexpected parse failure: "
, show e
]
query = T.unwords
[ "SELECT pool_id, count(pool_id) as block_count"
, "FROM pool_production"
Expand Down

0 comments on commit 88ce82e

Please sign in to comment.