Skip to content

Commit

Permalink
create-testnet-data: simplify some code (do not change behavior)
Browse files Browse the repository at this point in the history
  • Loading branch information
smelc committed Jan 19, 2024
1 parent cf62f83 commit 9a77245
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -573,14 +573,13 @@ updateCreateStakedOutputTemplate
-> ShelleyGenesis StandardCrypto -- ^ Template from which to build a genesis
-> ShelleyGenesis StandardCrypto -- ^ Updated genesis
updateCreateStakedOutputTemplate
(SystemStart start)
(SystemStart sgSystemStart)
genDelegMap mAmountNonDeleg nUtxoAddrsNonDeleg utxoAddrsNonDeleg pools stake
amountDeleg
nUtxoAddrsDeleg utxoAddrsDeleg stuffedUtxoAddrs
template = do
let pparamsFromTemplate = sgProtocolParams template
shelleyGenesis = template
{ sgSystemStart = start
template@ShelleyGenesis{ sgProtocolParams } =
template
{ sgSystemStart
, sgMaxLovelaceSupply = fromIntegral $ nonDelegCoin + delegCoin
, sgGenDelegs = shelleyDelKeys
, sgInitialFunds = ListMap.fromList
Expand All @@ -597,16 +596,16 @@ updateCreateStakedOutputTemplate
{ sgsPools = ListMap pools
, sgsStake = ListMap stake
}
, sgProtocolParams = pparamsFromTemplate
, sgProtocolParams
}
shelleyGenesis
where
maximumLovelaceSupply :: Word64
maximumLovelaceSupply = sgMaxLovelaceSupply template
-- If the initial funds are equal to the maximum funds, rewards cannot be created.
subtractForTreasury :: Integer
subtractForTreasury = nonDelegCoin `quot` 10
nonDelegCoin, delegCoin :: Integer
-- if --supply is not specified, non delegated supply comes from the template passed to this function:
nonDelegCoin = fromIntegral (maybe maximumLovelaceSupply unLovelace mAmountNonDeleg)
delegCoin = maybe 0 fromIntegral amountDeleg

Expand All @@ -617,7 +616,7 @@ updateCreateStakedOutputTemplate

mkStuffedUtxo :: [AddressInEra ShelleyEra] -> [(AddressInEra ShelleyEra, Lovelace)]
mkStuffedUtxo xs = (, Lovelace minUtxoVal) <$> xs
where Coin minUtxoVal = sgProtocolParams template ^. ppMinUTxOValueL
where Coin minUtxoVal = sgProtocolParams ^. ppMinUTxOValueL

shelleyDelKeys = Map.fromList
[ (gh, Ledger.GenDelegPair gdh h)
Expand Down

0 comments on commit 9a77245

Please sign in to comment.