Skip to content

Commit

Permalink
Remove custom mapAccumM in favour of standard impl
Browse files Browse the repository at this point in the history
  • Loading branch information
palas committed Mar 14, 2024
1 parent 035be55 commit f0601d3
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ import qualified Data.Sequence.Strict as Seq
import Data.String (fromString)
import qualified Data.Text as Text
import Data.Time (NominalDiffTime, UTCTime, addUTCTime, getCurrentTime)
import Data.Traversable (mapAccumM)
import Data.Tuple (swap)
import Data.Word (Word64)
import GHC.Generics (Generic)
Expand Down Expand Up @@ -264,7 +265,7 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs
cmd = DRep.GovernanceDRepKeyGenCmdArgs ConwayEraOnwardsConway vkeyFile skeyFile
liftIO $ createDirectoryIfMissing True drepDir
fst <$> DRep.runGovernanceDRepKeyGenCmd cmd
Transient -> liftIO $ mapAccumM (\g' _ -> swap . first getVerificationKey <$> generateInsecureSigningKey g' AsDRepKey)
Transient -> liftIO $ snd <$> mapAccumM (\g' _ -> swap . first getVerificationKey <$> generateInsecureSigningKey g' AsDRepKey)
g [ 1 .. numOfStakeDelegators ]

when (0 < numOfDRepCredentials && dRepCredentialGenerationMode == OnDisk) $ writeREADME drepsDir drepsREADME
Expand All @@ -274,7 +275,7 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs
g2 <- Random.getStdGen
delegatorKeys <- case stakeDelegatorsGenerationMode of
OnDisk -> forM stakeDelegatorsDirs $ \delegator -> createStakeDelegatorCredentials delegator
Transient -> liftIO $ mapAccumM (\g' _ -> computeInsecureStakeKeyAddr g') g2 [ 1 .. numOfStakeDelegators ]
Transient -> liftIO $ snd <$> mapAccumM (\g' _ -> computeInsecureStakeKeyAddr g') g2 [ 1 .. numOfStakeDelegators ]

let (delegsPerPool, delegsRemaining) =
if numPools == 0
Expand Down Expand Up @@ -357,12 +358,6 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs
zipWithDeepSeq f (h1:t1) (h2:t2) = let h = f h1 h2 in
h `deepseq` (h:zipWithDeepSeq f t1 t2)

mapAccumM :: (acc -> b -> IO (acc, c)) -> acc -> [b] -> IO [c]
mapAccumM _ _ [] = return []
mapAccumM f a (h:t) = do (a', h') <- f a h
rest <- mapAccumM f a' t
return $ h':rest

-- | The output format used all along this file
desiredKeyOutputFormat :: KeyOutputFormat
desiredKeyOutputFormat = KeyOutputFormatTextEnvelope
Expand Down

0 comments on commit f0601d3

Please sign in to comment.