module Ouroboros.Consensus.Committee.AcrossEpochs
( InterEpochVotingCommittee (..)
, mkInterEpochVotingCommittee
, newEpoch
, getVotingCommitteeForElection
) where
import Data.Maybe.Strict (StrictMaybe (..))
import Ouroboros.Consensus.Committee.Class (CryptoSupportsVotingCommittee (..))
import Ouroboros.Consensus.Committee.Crypto (ElectionId)
data InterEpochVotingCommittee crypto committee
= InterEpochVotingCommittee
{ forall crypto committee.
InterEpochVotingCommittee crypto committee
-> VotingCommittee crypto committee
currEpochVotingCommittee :: !(VotingCommittee crypto committee)
, forall crypto committee.
InterEpochVotingCommittee crypto committee
-> StrictMaybe (VotingCommittee crypto committee)
prevEpochVotingCommittee :: !(StrictMaybe (VotingCommittee crypto committee))
}
mkInterEpochVotingCommittee ::
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee ->
Either
(VotingCommitteeError crypto committee)
(InterEpochVotingCommittee crypto committee)
mkInterEpochVotingCommittee :: forall crypto committee.
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee
-> Either
(VotingCommitteeError crypto committee)
(InterEpochVotingCommittee crypto committee)
mkInterEpochVotingCommittee VotingCommitteeInput crypto committee
votingCommitteeInput = do
votingCommittee <-
VotingCommitteeInput crypto committee
-> Either
(VotingCommitteeError crypto committee)
(VotingCommittee crypto committee)
forall crypto committee.
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee
-> Either
(VotingCommitteeError crypto committee)
(VotingCommittee crypto committee)
mkVotingCommittee VotingCommitteeInput crypto committee
votingCommitteeInput
pure $
InterEpochVotingCommittee
{ currEpochVotingCommittee =
votingCommittee
, prevEpochVotingCommittee =
SNothing
}
newEpoch ::
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee ->
InterEpochVotingCommittee crypto committee ->
Either
(VotingCommitteeError crypto committee)
(InterEpochVotingCommittee crypto committee)
newEpoch :: forall crypto committee.
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee
-> InterEpochVotingCommittee crypto committee
-> Either
(VotingCommitteeError crypto committee)
(InterEpochVotingCommittee crypto committee)
newEpoch VotingCommitteeInput crypto committee
newEpochVotingCommitteeInput InterEpochVotingCommittee crypto committee
interEpochVotingCommittee = do
newEpochVotingCommittee <-
VotingCommitteeInput crypto committee
-> Either
(VotingCommitteeError crypto committee)
(VotingCommittee crypto committee)
forall crypto committee.
CryptoSupportsVotingCommittee crypto committee =>
VotingCommitteeInput crypto committee
-> Either
(VotingCommitteeError crypto committee)
(VotingCommittee crypto committee)
mkVotingCommittee VotingCommitteeInput crypto committee
newEpochVotingCommitteeInput
pure $
InterEpochVotingCommittee
{ currEpochVotingCommittee =
newEpochVotingCommittee
, prevEpochVotingCommittee =
SJust (currEpochVotingCommittee interEpochVotingCommittee)
}
getVotingCommitteeForElection ::
ElectionId crypto ->
InterEpochVotingCommittee crypto committee ->
Maybe (VotingCommittee crypto committee)
getVotingCommitteeForElection :: forall crypto committee.
ElectionId crypto
-> InterEpochVotingCommittee crypto committee
-> Maybe (VotingCommittee crypto committee)
getVotingCommitteeForElection ElectionId crypto
_electionId InterEpochVotingCommittee crypto committee
_interEpochVotingCommittee = do
[Char] -> Maybe (VotingCommittee crypto committee)
forall a. HasCallStack => [Char] -> a
error [Char]
"TODO: implement getVotingCommitteeForElection"