Skip to content

Commit

Permalink
Round results to nearest integer
Browse files Browse the repository at this point in the history
  • Loading branch information
sevanspowell committed Jan 18, 2021
1 parent f682f0a commit d828d5f
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/Main.hs
Expand Up @@ -60,13 +60,13 @@ main = do
raw :: [(Hash StakeKey, Double)]
raw = M.toList votingProportions

ofRewards :: Double -> Double
ofRewards = ((fromIntegral totalRewards) *)
ofRewards :: Double -> Integer
ofRewards = round . ((fromIntegral totalRewards) *)

toBech32Addr :: Hash StakeKey -> Text
toBech32Addr = serialiseToBech32 . makeStakeAddress networkId . StakeCredentialByKey

toRewards :: [(Hash StakeKey, Double)] -> Map Text Double
toRewards :: [(Hash StakeKey, Double)] -> Map Text Integer
toRewards = M.fromList . fmap (\(hash, proportion) -> (toBech32Addr hash, ofRewards proportion))

BLC.writeFile outfile . toJSON Aeson.Decimal . toRewards $ raw
Expand Down

0 comments on commit d828d5f

Please sign in to comment.