Skip to content

Commit

Permalink
WIp
Browse files Browse the repository at this point in the history
  • Loading branch information
sevanspowell committed Jan 13, 2021
1 parent 8907b6f commit 5ff588c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
17 changes: 11 additions & 6 deletions src/Cardano/CLI/Query.hs
Expand Up @@ -122,8 +122,9 @@ queryVoteRegistrationInfo
, AsMetadataRetrievalError e
)
=> Maybe SlotNo
-> Threshold
-> m (Contributions VotingKeyPublic (Api.Hash Api.StakeKey) Integer)
queryVoteRegistrationInfo mSlotNo = do
queryVoteRegistrationInfo mSlotNo (Api.Lovelace threshold) = do
regos <- queryVoteRegistration mSlotNo

let
Expand All @@ -140,8 +141,11 @@ queryVoteRegistrationInfo mSlotNo = do

fmap mconcat $ forM (M.toList xs) (\(verKeyHash, votepub) -> do
(Api.Lovelace stake) <- queryStake mSlotNo verKeyHash
-- To each votepub, a verKeyHash may contribute once
pure $ (contribute votepub verKeyHash stake mempty)

pure $
if stake > threshold
then contribute votepub verKeyHash stake mempty
else mempty
)

queryVotingProportion
Expand All @@ -157,7 +161,7 @@ queryVotingProportion
-> Threshold
-> m (Map (Api.Hash Api.StakeKey) Double)
queryVotingProportion nw mSlotNo threshold = do
info <- queryVoteRegistrationInfo mSlotNo
info <- queryVoteRegistrationInfo mSlotNo threshold

let
proportions :: [((Api.Hash Api.StakeKey), Double)]
Expand All @@ -181,9 +185,10 @@ queryVotingFunds
)
=> Api.NetworkId
-> Maybe SlotNo
-> Threshold
-> m VotingFunds
queryVotingFunds nw mSlotNo = do
info <- queryVoteRegistrationInfo mSlotNo
queryVotingFunds nw mSlotNo threshold = do
info <- queryVoteRegistrationInfo mSlotNo threshold

pure
$ VotingFunds
Expand Down
2 changes: 1 addition & 1 deletion src/Contribution/Efficient.hs
Expand Up @@ -148,7 +148,7 @@ causeSumAmounts =
let
sumAmts = getSum . foldMap (Sum . toRational . snd)
in
foldMap (\(c, cs) -> (:[]) $ (c,) $ sumAmts cs) . contributions
fmap (fmap sumAmts) . contributions

-- -- | Lift the contribution amounts into some monoid, and monoidally
-- -- combine each contribution amount.
Expand Down

0 comments on commit 5ff588c

Please sign in to comment.