Skip to content

Commit

Permalink
create-testnet-data/create-staked: don't stay close to a division by …
Browse files Browse the repository at this point in the history
…zero
  • Loading branch information
smelc committed Jan 25, 2024
1 parent e8fe394 commit e83e4ec
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
8 changes: 6 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/CreateTestnetData.hs
Original file line number Diff line number Diff line change
Expand Up @@ -260,8 +260,12 @@ runGenesisCreateTestNetDataCmd Cmd.GenesisCreateTestNetDataCmdArgs
createStakeDelegatorCredentials (stakeDelegatorsDir </> "delegator" <> show index)
Transient _ -> pure ()

let (delegsPerPool, delegsRemaining) = numStakeDelegators `divMod` numPools
delegsForPool poolIx = if delegsRemaining /= 0 && poolIx == numPools
let (delegsPerPool, delegsRemaining) =
if numPools == 0
then (0, 0)
else numStakeDelegators `divMod` numPools
delegsForPool poolIx =
if delegsRemaining /= 0 && poolIx == numPools
then delegsPerPool
else delegsPerPool + delegsRemaining
distribution = [pool | (pool, poolIx) <- zip poolParams [1 ..], _ <- [1 .. delegsForPool poolIx]]
Expand Down
8 changes: 6 additions & 2 deletions cardano-cli/src/Cardano/CLI/EraBased/Run/Genesis.hs
Original file line number Diff line number Diff line change
Expand Up @@ -596,8 +596,12 @@ runGenesisCreateStakedCmd
forM_ (zip [ 1 .. numBulkPoolCredFiles ] bulkSlices) $
uncurry (writeBulkPoolCredentials pooldir)

let (delegsPerPool, delegsRemaining) = divMod numStakeDelegators numPools
delegsForPool poolIx = if delegsRemaining /= 0 && poolIx == numPools
let (delegsPerPool, delegsRemaining) =
if numPools == 0
then (0, 0)
else numStakeDelegators `divMod` numPools
delegsForPool poolIx =
if delegsRemaining /= 0 && poolIx == numPools
then delegsPerPool
else delegsPerPool + delegsRemaining
distribution = [pool | (pool, poolIx) <- zip poolParams [1 ..], _ <- [1 .. delegsForPool poolIx]]
Expand Down

0 comments on commit e83e4ec

Please sign in to comment.