Skip to content

Commit

Permalink
Output hash to file even in case of expected-hash flag
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Sep 18, 2024
1 parent 432dedf commit 4f7cdac
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion cardano-cli/src/Cardano/CLI/Run/Hash.hs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ import Cardano.CLI.Types.Errors.HashCmdError
import Cardano.Crypto.Hash (hashToTextAsHex)

import Control.Exception (throw)
import Control.Monad (when)
import Control.Monad.Catch (Exception, Handler (Handler))
import qualified Data.ByteString as BS
import qualified Data.ByteString.Char8 as BS8
import qualified Data.ByteString.Lazy as BSL
import Data.Char (toLower)
import Data.Function
import Data.List (intercalate)
import Data.Maybe (isJust)
import qualified Data.Text as Text
import qualified Data.Text.Encoding as Text
import qualified Data.Text.IO as Text
Expand Down Expand Up @@ -68,7 +70,9 @@ runHashAnchorDataCmd Cmd.HashAnchorDataCmdArgs{toHash, mExpectedHash, mOutFile}
Just expectedHash
| hash /= expectedHash ->
left $ HashMismatchedHashError expectedHash hash
| otherwise -> liftIO $ putStrLn "Hashes match!"
| otherwise -> do
liftIO $ putStrLn "Hashes match!"
when (isJust mOutFile) $ writeHash hash
Nothing -> writeHash hash
where
writeHash :: L.SafeHash L.StandardCrypto i -> ExceptT HashCmdError IO ()
Expand Down

0 comments on commit 4f7cdac

Please sign in to comment.