{-# LANGUAGE DataKinds #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DerivingVia #-}
{-# LANGUAGE FlexibleContexts #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE UndecidableInstances #-}
module Ouroboros.Consensus.Block.SupportsPeras
( PerasRoundNo (..)
, onPerasRoundNo
, PerasVoteId (..)
, PerasVoteTarget (..)
, PerasVoterId (..)
, PerasVoteStake (..)
, stakeAboveThreshold
, PerasVoteStakeDistr (..)
, lookupPerasVoteStake
, BlockSupportsPeras (..)
, PerasCert (..)
, PerasVote (..)
, ValidatedPerasCert (..)
, ValidatedPerasVote (..)
, ValidatedPerasVotesWithQuorum
( vpvqTarget
, vpvqVotes
, vpvqPerasCfg
)
, votesReachQuorum
, HasPerasCertRound (..)
, HasPerasCertBoostedBlock (..)
, HasPerasCertBoost (..)
, HasPerasVoteRound (..)
, HasPerasVoteBlock (..)
, HasPerasVoteVoterId (..)
, HasPerasVoteStake (..)
, HasPerasVoteTarget (..)
, HasPerasVoteId (..)
, module Ouroboros.Consensus.Peras.Params
) where
import qualified Cardano.Binary as KeyHash
import Cardano.Ledger.Hashes (KeyHash, KeyRole (..))
import Codec.Serialise (Serialise (..))
import Codec.Serialise.Decoding (decodeListLenOf)
import Codec.Serialise.Encoding (encodeListLen)
import Data.Coerce (coerce)
import Data.List.NonEmpty (NonEmpty (..))
import qualified Data.Map as Map
import Data.Map.Strict (Map)
import Data.Monoid (Sum (..))
import Data.Proxy (Proxy (..))
import Data.Word (Word64)
import GHC.Generics (Generic)
import NoThunks.Class
import Ouroboros.Consensus.Block.Abstract
import Ouroboros.Consensus.BlockchainTime.WallClock.Types (WithArrivalTime (..))
import Ouroboros.Consensus.Peras.Params
import Ouroboros.Consensus.Util
import Ouroboros.Consensus.Util.Condense
import Quiet (Quiet (..))
newtype PerasRoundNo = PerasRoundNo {PerasRoundNo -> Word64
unPerasRoundNo :: Word64}
deriving Int -> PerasRoundNo -> ShowS
[PerasRoundNo] -> ShowS
PerasRoundNo -> String
(Int -> PerasRoundNo -> ShowS)
-> (PerasRoundNo -> String)
-> ([PerasRoundNo] -> ShowS)
-> Show PerasRoundNo
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasRoundNo -> ShowS
showsPrec :: Int -> PerasRoundNo -> ShowS
$cshow :: PerasRoundNo -> String
show :: PerasRoundNo -> String
$cshowList :: [PerasRoundNo] -> ShowS
showList :: [PerasRoundNo] -> ShowS
Show via Quiet PerasRoundNo
deriving stock (forall x. PerasRoundNo -> Rep PerasRoundNo x)
-> (forall x. Rep PerasRoundNo x -> PerasRoundNo)
-> Generic PerasRoundNo
forall x. Rep PerasRoundNo x -> PerasRoundNo
forall x. PerasRoundNo -> Rep PerasRoundNo x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasRoundNo -> Rep PerasRoundNo x
from :: forall x. PerasRoundNo -> Rep PerasRoundNo x
$cto :: forall x. Rep PerasRoundNo x -> PerasRoundNo
to :: forall x. Rep PerasRoundNo x -> PerasRoundNo
Generic
deriving newtype (Int -> PerasRoundNo
PerasRoundNo -> Int
PerasRoundNo -> [PerasRoundNo]
PerasRoundNo -> PerasRoundNo
PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
(PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo)
-> (Int -> PerasRoundNo)
-> (PerasRoundNo -> Int)
-> (PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo])
-> Enum PerasRoundNo
forall a.
(a -> a)
-> (a -> a)
-> (Int -> a)
-> (a -> Int)
-> (a -> [a])
-> (a -> a -> [a])
-> (a -> a -> [a])
-> (a -> a -> a -> [a])
-> Enum a
$csucc :: PerasRoundNo -> PerasRoundNo
succ :: PerasRoundNo -> PerasRoundNo
$cpred :: PerasRoundNo -> PerasRoundNo
pred :: PerasRoundNo -> PerasRoundNo
$ctoEnum :: Int -> PerasRoundNo
toEnum :: Int -> PerasRoundNo
$cfromEnum :: PerasRoundNo -> Int
fromEnum :: PerasRoundNo -> Int
$cenumFrom :: PerasRoundNo -> [PerasRoundNo]
enumFrom :: PerasRoundNo -> [PerasRoundNo]
$cenumFromThen :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromThen :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
$cenumFromTo :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromTo :: PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
$cenumFromThenTo :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
enumFromThenTo :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo -> [PerasRoundNo]
Enum, PerasRoundNo -> PerasRoundNo -> Bool
(PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool) -> Eq PerasRoundNo
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasRoundNo -> PerasRoundNo -> Bool
== :: PerasRoundNo -> PerasRoundNo -> Bool
$c/= :: PerasRoundNo -> PerasRoundNo -> Bool
/= :: PerasRoundNo -> PerasRoundNo -> Bool
Eq, Eq PerasRoundNo
Eq PerasRoundNo =>
(PerasRoundNo -> PerasRoundNo -> Ordering)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> Bool)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> Ord PerasRoundNo
PerasRoundNo -> PerasRoundNo -> Bool
PerasRoundNo -> PerasRoundNo -> Ordering
PerasRoundNo -> PerasRoundNo -> PerasRoundNo
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PerasRoundNo -> PerasRoundNo -> Ordering
compare :: PerasRoundNo -> PerasRoundNo -> Ordering
$c< :: PerasRoundNo -> PerasRoundNo -> Bool
< :: PerasRoundNo -> PerasRoundNo -> Bool
$c<= :: PerasRoundNo -> PerasRoundNo -> Bool
<= :: PerasRoundNo -> PerasRoundNo -> Bool
$c> :: PerasRoundNo -> PerasRoundNo -> Bool
> :: PerasRoundNo -> PerasRoundNo -> Bool
$c>= :: PerasRoundNo -> PerasRoundNo -> Bool
>= :: PerasRoundNo -> PerasRoundNo -> Bool
$cmax :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
max :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
$cmin :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
min :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
Ord, Integer -> PerasRoundNo
PerasRoundNo -> PerasRoundNo
PerasRoundNo -> PerasRoundNo -> PerasRoundNo
(PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo)
-> (PerasRoundNo -> PerasRoundNo)
-> (Integer -> PerasRoundNo)
-> Num PerasRoundNo
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
+ :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
$c- :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
- :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
$c* :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
* :: PerasRoundNo -> PerasRoundNo -> PerasRoundNo
$cnegate :: PerasRoundNo -> PerasRoundNo
negate :: PerasRoundNo -> PerasRoundNo
$cabs :: PerasRoundNo -> PerasRoundNo
abs :: PerasRoundNo -> PerasRoundNo
$csignum :: PerasRoundNo -> PerasRoundNo
signum :: PerasRoundNo -> PerasRoundNo
$cfromInteger :: Integer -> PerasRoundNo
fromInteger :: Integer -> PerasRoundNo
Num, PerasRoundNo
PerasRoundNo -> PerasRoundNo -> Bounded PerasRoundNo
forall a. a -> a -> Bounded a
$cminBound :: PerasRoundNo
minBound :: PerasRoundNo
$cmaxBound :: PerasRoundNo
maxBound :: PerasRoundNo
Bounded, Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
Proxy PerasRoundNo -> String
(Context -> PerasRoundNo -> IO (Maybe ThunkInfo))
-> (Context -> PerasRoundNo -> IO (Maybe ThunkInfo))
-> (Proxy PerasRoundNo -> String)
-> NoThunks PerasRoundNo
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasRoundNo -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasRoundNo -> String
showTypeOf :: Proxy PerasRoundNo -> String
NoThunks, [PerasRoundNo] -> Encoding
PerasRoundNo -> Encoding
(PerasRoundNo -> Encoding)
-> (forall s. Decoder s PerasRoundNo)
-> ([PerasRoundNo] -> Encoding)
-> (forall s. Decoder s [PerasRoundNo])
-> Serialise PerasRoundNo
forall s. Decoder s [PerasRoundNo]
forall s. Decoder s PerasRoundNo
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: PerasRoundNo -> Encoding
encode :: PerasRoundNo -> Encoding
$cdecode :: forall s. Decoder s PerasRoundNo
decode :: forall s. Decoder s PerasRoundNo
$cencodeList :: [PerasRoundNo] -> Encoding
encodeList :: [PerasRoundNo] -> Encoding
$cdecodeList :: forall s. Decoder s [PerasRoundNo]
decodeList :: forall s. Decoder s [PerasRoundNo]
Serialise)
instance Condense PerasRoundNo where
condense :: PerasRoundNo -> String
condense = Word64 -> String
forall a. Show a => a -> String
show (Word64 -> String)
-> (PerasRoundNo -> Word64) -> PerasRoundNo -> String
forall b c a. (b -> c) -> (a -> b) -> a -> c
. PerasRoundNo -> Word64
unPerasRoundNo
instance ShowProxy PerasRoundNo where
showProxy :: Proxy PerasRoundNo -> String
showProxy Proxy PerasRoundNo
_ = String
"PerasRoundNo"
onPerasRoundNo ::
(Word64 -> Word64 -> Word64) ->
(PerasRoundNo -> PerasRoundNo -> PerasRoundNo)
onPerasRoundNo :: (Word64 -> Word64 -> Word64)
-> PerasRoundNo -> PerasRoundNo -> PerasRoundNo
onPerasRoundNo = (Word64 -> Word64 -> Word64)
-> PerasRoundNo -> PerasRoundNo -> PerasRoundNo
forall a b. Coercible a b => a -> b
coerce
newtype PerasVoterId = PerasVoterId
{ PerasVoterId -> KeyHash StakePool
unPerasVoterId :: KeyHash StakePool
}
deriving newtype Context -> PerasVoterId -> IO (Maybe ThunkInfo)
Proxy PerasVoterId -> String
(Context -> PerasVoterId -> IO (Maybe ThunkInfo))
-> (Context -> PerasVoterId -> IO (Maybe ThunkInfo))
-> (Proxy PerasVoterId -> String)
-> NoThunks PerasVoterId
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasVoterId -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVoterId -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasVoterId -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVoterId -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasVoterId -> String
showTypeOf :: Proxy PerasVoterId -> String
NoThunks
deriving stock (PerasVoterId -> PerasVoterId -> Bool
(PerasVoterId -> PerasVoterId -> Bool)
-> (PerasVoterId -> PerasVoterId -> Bool) -> Eq PerasVoterId
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasVoterId -> PerasVoterId -> Bool
== :: PerasVoterId -> PerasVoterId -> Bool
$c/= :: PerasVoterId -> PerasVoterId -> Bool
/= :: PerasVoterId -> PerasVoterId -> Bool
Eq, Eq PerasVoterId
Eq PerasVoterId =>
(PerasVoterId -> PerasVoterId -> Ordering)
-> (PerasVoterId -> PerasVoterId -> Bool)
-> (PerasVoterId -> PerasVoterId -> Bool)
-> (PerasVoterId -> PerasVoterId -> Bool)
-> (PerasVoterId -> PerasVoterId -> Bool)
-> (PerasVoterId -> PerasVoterId -> PerasVoterId)
-> (PerasVoterId -> PerasVoterId -> PerasVoterId)
-> Ord PerasVoterId
PerasVoterId -> PerasVoterId -> Bool
PerasVoterId -> PerasVoterId -> Ordering
PerasVoterId -> PerasVoterId -> PerasVoterId
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PerasVoterId -> PerasVoterId -> Ordering
compare :: PerasVoterId -> PerasVoterId -> Ordering
$c< :: PerasVoterId -> PerasVoterId -> Bool
< :: PerasVoterId -> PerasVoterId -> Bool
$c<= :: PerasVoterId -> PerasVoterId -> Bool
<= :: PerasVoterId -> PerasVoterId -> Bool
$c> :: PerasVoterId -> PerasVoterId -> Bool
> :: PerasVoterId -> PerasVoterId -> Bool
$c>= :: PerasVoterId -> PerasVoterId -> Bool
>= :: PerasVoterId -> PerasVoterId -> Bool
$cmax :: PerasVoterId -> PerasVoterId -> PerasVoterId
max :: PerasVoterId -> PerasVoterId -> PerasVoterId
$cmin :: PerasVoterId -> PerasVoterId -> PerasVoterId
min :: PerasVoterId -> PerasVoterId -> PerasVoterId
Ord, (forall x. PerasVoterId -> Rep PerasVoterId x)
-> (forall x. Rep PerasVoterId x -> PerasVoterId)
-> Generic PerasVoterId
forall x. Rep PerasVoterId x -> PerasVoterId
forall x. PerasVoterId -> Rep PerasVoterId x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasVoterId -> Rep PerasVoterId x
from :: forall x. PerasVoterId -> Rep PerasVoterId x
$cto :: forall x. Rep PerasVoterId x -> PerasVoterId
to :: forall x. Rep PerasVoterId x -> PerasVoterId
Generic)
deriving Int -> PerasVoterId -> ShowS
[PerasVoterId] -> ShowS
PerasVoterId -> String
(Int -> PerasVoterId -> ShowS)
-> (PerasVoterId -> String)
-> ([PerasVoterId] -> ShowS)
-> Show PerasVoterId
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasVoterId -> ShowS
showsPrec :: Int -> PerasVoterId -> ShowS
$cshow :: PerasVoterId -> String
show :: PerasVoterId -> String
$cshowList :: [PerasVoterId] -> ShowS
showList :: [PerasVoterId] -> ShowS
Show via Quiet PerasVoterId
newtype PerasVoteStake = PerasVoteStake
{ PerasVoteStake -> Rational
unPerasVoteStake :: Rational
}
deriving newtype (PerasVoteStake -> PerasVoteStake -> Bool
(PerasVoteStake -> PerasVoteStake -> Bool)
-> (PerasVoteStake -> PerasVoteStake -> Bool) -> Eq PerasVoteStake
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasVoteStake -> PerasVoteStake -> Bool
== :: PerasVoteStake -> PerasVoteStake -> Bool
$c/= :: PerasVoteStake -> PerasVoteStake -> Bool
/= :: PerasVoteStake -> PerasVoteStake -> Bool
Eq, Eq PerasVoteStake
Eq PerasVoteStake =>
(PerasVoteStake -> PerasVoteStake -> Ordering)
-> (PerasVoteStake -> PerasVoteStake -> Bool)
-> (PerasVoteStake -> PerasVoteStake -> Bool)
-> (PerasVoteStake -> PerasVoteStake -> Bool)
-> (PerasVoteStake -> PerasVoteStake -> Bool)
-> (PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> Ord PerasVoteStake
PerasVoteStake -> PerasVoteStake -> Bool
PerasVoteStake -> PerasVoteStake -> Ordering
PerasVoteStake -> PerasVoteStake -> PerasVoteStake
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: PerasVoteStake -> PerasVoteStake -> Ordering
compare :: PerasVoteStake -> PerasVoteStake -> Ordering
$c< :: PerasVoteStake -> PerasVoteStake -> Bool
< :: PerasVoteStake -> PerasVoteStake -> Bool
$c<= :: PerasVoteStake -> PerasVoteStake -> Bool
<= :: PerasVoteStake -> PerasVoteStake -> Bool
$c> :: PerasVoteStake -> PerasVoteStake -> Bool
> :: PerasVoteStake -> PerasVoteStake -> Bool
$c>= :: PerasVoteStake -> PerasVoteStake -> Bool
>= :: PerasVoteStake -> PerasVoteStake -> Bool
$cmax :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
max :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$cmin :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
min :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
Ord, Integer -> PerasVoteStake
PerasVoteStake -> PerasVoteStake
PerasVoteStake -> PerasVoteStake -> PerasVoteStake
(PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake)
-> (Integer -> PerasVoteStake)
-> Num PerasVoteStake
forall a.
(a -> a -> a)
-> (a -> a -> a)
-> (a -> a -> a)
-> (a -> a)
-> (a -> a)
-> (a -> a)
-> (Integer -> a)
-> Num a
$c+ :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
+ :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$c- :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
- :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$c* :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
* :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$cnegate :: PerasVoteStake -> PerasVoteStake
negate :: PerasVoteStake -> PerasVoteStake
$cabs :: PerasVoteStake -> PerasVoteStake
abs :: PerasVoteStake -> PerasVoteStake
$csignum :: PerasVoteStake -> PerasVoteStake
signum :: PerasVoteStake -> PerasVoteStake
$cfromInteger :: Integer -> PerasVoteStake
fromInteger :: Integer -> PerasVoteStake
Num, Num PerasVoteStake
Num PerasVoteStake =>
(PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (PerasVoteStake -> PerasVoteStake)
-> (Rational -> PerasVoteStake)
-> Fractional PerasVoteStake
Rational -> PerasVoteStake
PerasVoteStake -> PerasVoteStake
PerasVoteStake -> PerasVoteStake -> PerasVoteStake
forall a.
Num a =>
(a -> a -> a) -> (a -> a) -> (Rational -> a) -> Fractional a
$c/ :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
/ :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$crecip :: PerasVoteStake -> PerasVoteStake
recip :: PerasVoteStake -> PerasVoteStake
$cfromRational :: Rational -> PerasVoteStake
fromRational :: Rational -> PerasVoteStake
Fractional, Context -> PerasVoteStake -> IO (Maybe ThunkInfo)
Proxy PerasVoteStake -> String
(Context -> PerasVoteStake -> IO (Maybe ThunkInfo))
-> (Context -> PerasVoteStake -> IO (Maybe ThunkInfo))
-> (Proxy PerasVoteStake -> String)
-> NoThunks PerasVoteStake
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasVoteStake -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVoteStake -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasVoteStake -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVoteStake -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasVoteStake -> String
showTypeOf :: Proxy PerasVoteStake -> String
NoThunks, [PerasVoteStake] -> Encoding
PerasVoteStake -> Encoding
(PerasVoteStake -> Encoding)
-> (forall s. Decoder s PerasVoteStake)
-> ([PerasVoteStake] -> Encoding)
-> (forall s. Decoder s [PerasVoteStake])
-> Serialise PerasVoteStake
forall s. Decoder s [PerasVoteStake]
forall s. Decoder s PerasVoteStake
forall a.
(a -> Encoding)
-> (forall s. Decoder s a)
-> ([a] -> Encoding)
-> (forall s. Decoder s [a])
-> Serialise a
$cencode :: PerasVoteStake -> Encoding
encode :: PerasVoteStake -> Encoding
$cdecode :: forall s. Decoder s PerasVoteStake
decode :: forall s. Decoder s PerasVoteStake
$cencodeList :: [PerasVoteStake] -> Encoding
encodeList :: [PerasVoteStake] -> Encoding
$cdecodeList :: forall s. Decoder s [PerasVoteStake]
decodeList :: forall s. Decoder s [PerasVoteStake]
Serialise)
deriving stock (forall x. PerasVoteStake -> Rep PerasVoteStake x)
-> (forall x. Rep PerasVoteStake x -> PerasVoteStake)
-> Generic PerasVoteStake
forall x. Rep PerasVoteStake x -> PerasVoteStake
forall x. PerasVoteStake -> Rep PerasVoteStake x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasVoteStake -> Rep PerasVoteStake x
from :: forall x. PerasVoteStake -> Rep PerasVoteStake x
$cto :: forall x. Rep PerasVoteStake x -> PerasVoteStake
to :: forall x. Rep PerasVoteStake x -> PerasVoteStake
Generic
deriving Int -> PerasVoteStake -> ShowS
[PerasVoteStake] -> ShowS
PerasVoteStake -> String
(Int -> PerasVoteStake -> ShowS)
-> (PerasVoteStake -> String)
-> ([PerasVoteStake] -> ShowS)
-> Show PerasVoteStake
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasVoteStake -> ShowS
showsPrec :: Int -> PerasVoteStake -> ShowS
$cshow :: PerasVoteStake -> String
show :: PerasVoteStake -> String
$cshowList :: [PerasVoteStake] -> ShowS
showList :: [PerasVoteStake] -> ShowS
Show via Quiet PerasVoteStake
deriving NonEmpty PerasVoteStake -> PerasVoteStake
PerasVoteStake -> PerasVoteStake -> PerasVoteStake
(PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> (NonEmpty PerasVoteStake -> PerasVoteStake)
-> (forall b. Integral b => b -> PerasVoteStake -> PerasVoteStake)
-> Semigroup PerasVoteStake
forall b. Integral b => b -> PerasVoteStake -> PerasVoteStake
forall a.
(a -> a -> a)
-> (NonEmpty a -> a)
-> (forall b. Integral b => b -> a -> a)
-> Semigroup a
$c<> :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
<> :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$csconcat :: NonEmpty PerasVoteStake -> PerasVoteStake
sconcat :: NonEmpty PerasVoteStake -> PerasVoteStake
$cstimes :: forall b. Integral b => b -> PerasVoteStake -> PerasVoteStake
stimes :: forall b. Integral b => b -> PerasVoteStake -> PerasVoteStake
Semigroup via Sum Rational
deriving Semigroup PerasVoteStake
PerasVoteStake
Semigroup PerasVoteStake =>
PerasVoteStake
-> (PerasVoteStake -> PerasVoteStake -> PerasVoteStake)
-> ([PerasVoteStake] -> PerasVoteStake)
-> Monoid PerasVoteStake
[PerasVoteStake] -> PerasVoteStake
PerasVoteStake -> PerasVoteStake -> PerasVoteStake
forall a.
Semigroup a =>
a -> (a -> a -> a) -> ([a] -> a) -> Monoid a
$cmempty :: PerasVoteStake
mempty :: PerasVoteStake
$cmappend :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
mappend :: PerasVoteStake -> PerasVoteStake -> PerasVoteStake
$cmconcat :: [PerasVoteStake] -> PerasVoteStake
mconcat :: [PerasVoteStake] -> PerasVoteStake
Monoid via Sum Rational
stakeAboveThreshold :: PerasParams -> PerasVoteStake -> Bool
stakeAboveThreshold :: PerasParams -> PerasVoteStake -> Bool
stakeAboveThreshold PerasParams
params PerasVoteStake
voteStake =
Rational
stake Rational -> Rational -> Bool
forall a. Ord a => a -> a -> Bool
>= Rational
quorumThreshold Rational -> Rational -> Rational
forall a. Num a => a -> a -> a
+ Rational
safetyMargin
where
stake :: Rational
stake =
PerasVoteStake -> Rational
unPerasVoteStake PerasVoteStake
voteStake
quorumThreshold :: Rational
quorumThreshold =
PerasQuorumStakeThreshold -> Rational
unPerasQuorumStakeThreshold
(PerasParams -> PerasQuorumStakeThreshold
perasQuorumStakeThreshold PerasParams
params)
safetyMargin :: Rational
safetyMargin =
PerasQuorumStakeThresholdSafetyMargin -> Rational
unPerasQuorumStakeThresholdSafetyMargin
(PerasParams -> PerasQuorumStakeThresholdSafetyMargin
perasQuorumStakeThresholdSafetyMargin PerasParams
params)
newtype PerasVoteStakeDistr = PerasVoteStakeDistr
{ PerasVoteStakeDistr -> Map PerasVoterId PerasVoteStake
unPerasVoteStakeDistr :: Map PerasVoterId PerasVoteStake
}
deriving newtype Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo)
Proxy PerasVoteStakeDistr -> String
(Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo))
-> (Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo))
-> (Proxy PerasVoteStakeDistr -> String)
-> NoThunks PerasVoteStakeDistr
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo)
$cwNoThunks :: Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVoteStakeDistr -> IO (Maybe ThunkInfo)
$cshowTypeOf :: Proxy PerasVoteStakeDistr -> String
showTypeOf :: Proxy PerasVoteStakeDistr -> String
NoThunks
deriving stock (Int -> PerasVoteStakeDistr -> ShowS
[PerasVoteStakeDistr] -> ShowS
PerasVoteStakeDistr -> String
(Int -> PerasVoteStakeDistr -> ShowS)
-> (PerasVoteStakeDistr -> String)
-> ([PerasVoteStakeDistr] -> ShowS)
-> Show PerasVoteStakeDistr
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> PerasVoteStakeDistr -> ShowS
showsPrec :: Int -> PerasVoteStakeDistr -> ShowS
$cshow :: PerasVoteStakeDistr -> String
show :: PerasVoteStakeDistr -> String
$cshowList :: [PerasVoteStakeDistr] -> ShowS
showList :: [PerasVoteStakeDistr] -> ShowS
Show, PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool
(PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool)
-> (PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool)
-> Eq PerasVoteStakeDistr
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool
== :: PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool
$c/= :: PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool
/= :: PerasVoteStakeDistr -> PerasVoteStakeDistr -> Bool
Eq, (forall x. PerasVoteStakeDistr -> Rep PerasVoteStakeDistr x)
-> (forall x. Rep PerasVoteStakeDistr x -> PerasVoteStakeDistr)
-> Generic PerasVoteStakeDistr
forall x. Rep PerasVoteStakeDistr x -> PerasVoteStakeDistr
forall x. PerasVoteStakeDistr -> Rep PerasVoteStakeDistr x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cfrom :: forall x. PerasVoteStakeDistr -> Rep PerasVoteStakeDistr x
from :: forall x. PerasVoteStakeDistr -> Rep PerasVoteStakeDistr x
$cto :: forall x. Rep PerasVoteStakeDistr x -> PerasVoteStakeDistr
to :: forall x. Rep PerasVoteStakeDistr x -> PerasVoteStakeDistr
Generic)
data PerasVoteTarget blk = PerasVoteTarget
{ forall blk. PerasVoteTarget blk -> PerasRoundNo
pvtRoundNo :: !PerasRoundNo
, forall blk. PerasVoteTarget blk -> Point blk
pvtBlock :: !(Point blk)
}
deriving stock (Int -> PerasVoteTarget blk -> ShowS
[PerasVoteTarget blk] -> ShowS
PerasVoteTarget blk -> String
(Int -> PerasVoteTarget blk -> ShowS)
-> (PerasVoteTarget blk -> String)
-> ([PerasVoteTarget blk] -> ShowS)
-> Show (PerasVoteTarget blk)
forall blk. StandardHash blk => Int -> PerasVoteTarget blk -> ShowS
forall blk. StandardHash blk => [PerasVoteTarget blk] -> ShowS
forall blk. StandardHash blk => PerasVoteTarget blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> PerasVoteTarget blk -> ShowS
showsPrec :: Int -> PerasVoteTarget blk -> ShowS
$cshow :: forall blk. StandardHash blk => PerasVoteTarget blk -> String
show :: PerasVoteTarget blk -> String
$cshowList :: forall blk. StandardHash blk => [PerasVoteTarget blk] -> ShowS
showList :: [PerasVoteTarget blk] -> ShowS
Show, PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
(PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> (PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> Eq (PerasVoteTarget blk)
forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
== :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
/= :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
Eq, Eq (PerasVoteTarget blk)
Eq (PerasVoteTarget blk) =>
(PerasVoteTarget blk -> PerasVoteTarget blk -> Ordering)
-> (PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> (PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> (PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> (PerasVoteTarget blk -> PerasVoteTarget blk -> Bool)
-> (PerasVoteTarget blk
-> PerasVoteTarget blk -> PerasVoteTarget blk)
-> (PerasVoteTarget blk
-> PerasVoteTarget blk -> PerasVoteTarget blk)
-> Ord (PerasVoteTarget blk)
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
PerasVoteTarget blk -> PerasVoteTarget blk -> Ordering
PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. StandardHash blk => Eq (PerasVoteTarget blk)
forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Ordering
forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
$ccompare :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Ordering
compare :: PerasVoteTarget blk -> PerasVoteTarget blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
< :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
<= :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
$c> :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
> :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
>= :: PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
max :: PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
$cmin :: forall blk.
StandardHash blk =>
PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
min :: PerasVoteTarget blk -> PerasVoteTarget blk -> PerasVoteTarget blk
Ord, (forall x. PerasVoteTarget blk -> Rep (PerasVoteTarget blk) x)
-> (forall x. Rep (PerasVoteTarget blk) x -> PerasVoteTarget blk)
-> Generic (PerasVoteTarget blk)
forall x. Rep (PerasVoteTarget blk) x -> PerasVoteTarget blk
forall x. PerasVoteTarget blk -> Rep (PerasVoteTarget blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasVoteTarget blk) x -> PerasVoteTarget blk
forall blk x. PerasVoteTarget blk -> Rep (PerasVoteTarget blk) x
$cfrom :: forall blk x. PerasVoteTarget blk -> Rep (PerasVoteTarget blk) x
from :: forall x. PerasVoteTarget blk -> Rep (PerasVoteTarget blk) x
$cto :: forall blk x. Rep (PerasVoteTarget blk) x -> PerasVoteTarget blk
to :: forall x. Rep (PerasVoteTarget blk) x -> PerasVoteTarget blk
Generic)
deriving anyclass Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
Proxy (PerasVoteTarget blk) -> String
(Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasVoteTarget blk) -> String)
-> NoThunks (PerasVoteTarget blk)
forall blk.
StandardHash blk =>
Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
forall blk.
StandardHash blk =>
Proxy (PerasVoteTarget blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVoteTarget blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk.
StandardHash blk =>
Proxy (PerasVoteTarget blk) -> String
showTypeOf :: Proxy (PerasVoteTarget blk) -> String
NoThunks
data PerasVoteId blk = PerasVoteId
{ forall blk. PerasVoteId blk -> PerasRoundNo
pviRoundNo :: !PerasRoundNo
, forall blk. PerasVoteId blk -> PerasVoterId
pviVoterId :: !PerasVoterId
}
deriving stock (Int -> PerasVoteId blk -> ShowS
[PerasVoteId blk] -> ShowS
PerasVoteId blk -> String
(Int -> PerasVoteId blk -> ShowS)
-> (PerasVoteId blk -> String)
-> ([PerasVoteId blk] -> ShowS)
-> Show (PerasVoteId blk)
forall blk. Int -> PerasVoteId blk -> ShowS
forall blk. [PerasVoteId blk] -> ShowS
forall blk. PerasVoteId blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasVoteId blk -> ShowS
showsPrec :: Int -> PerasVoteId blk -> ShowS
$cshow :: forall blk. PerasVoteId blk -> String
show :: PerasVoteId blk -> String
$cshowList :: forall blk. [PerasVoteId blk] -> ShowS
showList :: [PerasVoteId blk] -> ShowS
Show, PerasVoteId blk -> PerasVoteId blk -> Bool
(PerasVoteId blk -> PerasVoteId blk -> Bool)
-> (PerasVoteId blk -> PerasVoteId blk -> Bool)
-> Eq (PerasVoteId blk)
forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
== :: PerasVoteId blk -> PerasVoteId blk -> Bool
$c/= :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
/= :: PerasVoteId blk -> PerasVoteId blk -> Bool
Eq, Eq (PerasVoteId blk)
Eq (PerasVoteId blk) =>
(PerasVoteId blk -> PerasVoteId blk -> Ordering)
-> (PerasVoteId blk -> PerasVoteId blk -> Bool)
-> (PerasVoteId blk -> PerasVoteId blk -> Bool)
-> (PerasVoteId blk -> PerasVoteId blk -> Bool)
-> (PerasVoteId blk -> PerasVoteId blk -> Bool)
-> (PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk)
-> (PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk)
-> Ord (PerasVoteId blk)
PerasVoteId blk -> PerasVoteId blk -> Bool
PerasVoteId blk -> PerasVoteId blk -> Ordering
PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
forall blk. Eq (PerasVoteId blk)
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
forall blk. PerasVoteId blk -> PerasVoteId blk -> Ordering
forall blk. PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
$ccompare :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Ordering
compare :: PerasVoteId blk -> PerasVoteId blk -> Ordering
$c< :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
< :: PerasVoteId blk -> PerasVoteId blk -> Bool
$c<= :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
<= :: PerasVoteId blk -> PerasVoteId blk -> Bool
$c> :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
> :: PerasVoteId blk -> PerasVoteId blk -> Bool
$c>= :: forall blk. PerasVoteId blk -> PerasVoteId blk -> Bool
>= :: PerasVoteId blk -> PerasVoteId blk -> Bool
$cmax :: forall blk. PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
max :: PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
$cmin :: forall blk. PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
min :: PerasVoteId blk -> PerasVoteId blk -> PerasVoteId blk
Ord, (forall x. PerasVoteId blk -> Rep (PerasVoteId blk) x)
-> (forall x. Rep (PerasVoteId blk) x -> PerasVoteId blk)
-> Generic (PerasVoteId blk)
forall x. Rep (PerasVoteId blk) x -> PerasVoteId blk
forall x. PerasVoteId blk -> Rep (PerasVoteId blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasVoteId blk) x -> PerasVoteId blk
forall blk x. PerasVoteId blk -> Rep (PerasVoteId blk) x
$cfrom :: forall blk x. PerasVoteId blk -> Rep (PerasVoteId blk) x
from :: forall x. PerasVoteId blk -> Rep (PerasVoteId blk) x
$cto :: forall blk x. Rep (PerasVoteId blk) x -> PerasVoteId blk
to :: forall x. Rep (PerasVoteId blk) x -> PerasVoteId blk
Generic)
deriving anyclass Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
Proxy (PerasVoteId blk) -> String
(Context -> PerasVoteId blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasVoteId blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasVoteId blk) -> String)
-> NoThunks (PerasVoteId blk)
forall blk. Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
forall blk. Proxy (PerasVoteId blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk. Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk. Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVoteId blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. Proxy (PerasVoteId blk) -> String
showTypeOf :: Proxy (PerasVoteId blk) -> String
NoThunks
lookupPerasVoteStake ::
PerasVote blk ->
PerasVoteStakeDistr ->
Maybe PerasVoteStake
lookupPerasVoteStake :: forall blk.
PerasVote blk -> PerasVoteStakeDistr -> Maybe PerasVoteStake
lookupPerasVoteStake PerasVote blk
vote PerasVoteStakeDistr
distr =
PerasVoterId
-> Map PerasVoterId PerasVoteStake -> Maybe PerasVoteStake
forall k a. Ord k => k -> Map k a -> Maybe a
Map.lookup
(PerasVote blk -> PerasVoterId
forall blk. PerasVote blk -> PerasVoterId
pvVoteVoterId PerasVote blk
vote)
(PerasVoteStakeDistr -> Map PerasVoterId PerasVoteStake
unPerasVoteStakeDistr PerasVoteStakeDistr
distr)
data ValidatedPerasCert blk = ValidatedPerasCert
{ forall blk. ValidatedPerasCert blk -> PerasCert blk
vpcCert :: !(PerasCert blk)
, forall blk. ValidatedPerasCert blk -> PerasWeight
vpcCertBoost :: !PerasWeight
}
deriving stock (Int -> ValidatedPerasCert blk -> ShowS
[ValidatedPerasCert blk] -> ShowS
ValidatedPerasCert blk -> String
(Int -> ValidatedPerasCert blk -> ShowS)
-> (ValidatedPerasCert blk -> String)
-> ([ValidatedPerasCert blk] -> ShowS)
-> Show (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
Int -> ValidatedPerasCert blk -> ShowS
forall blk. StandardHash blk => [ValidatedPerasCert blk] -> ShowS
forall blk. StandardHash blk => ValidatedPerasCert blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk.
StandardHash blk =>
Int -> ValidatedPerasCert blk -> ShowS
showsPrec :: Int -> ValidatedPerasCert blk -> ShowS
$cshow :: forall blk. StandardHash blk => ValidatedPerasCert blk -> String
show :: ValidatedPerasCert blk -> String
$cshowList :: forall blk. StandardHash blk => [ValidatedPerasCert blk] -> ShowS
showList :: [ValidatedPerasCert blk] -> ShowS
Show, ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
(ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> Eq (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
== :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
/= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
Eq, Eq (ValidatedPerasCert blk)
Eq (ValidatedPerasCert blk) =>
(ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool)
-> (ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk)
-> (ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk)
-> Ord (ValidatedPerasCert blk)
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. StandardHash blk => Eq (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
$ccompare :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
compare :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
< :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
<= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c> :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
> :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
>= :: ValidatedPerasCert blk -> ValidatedPerasCert blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
max :: ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
$cmin :: forall blk.
StandardHash blk =>
ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
min :: ValidatedPerasCert blk
-> ValidatedPerasCert blk -> ValidatedPerasCert blk
Ord, (forall x.
ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x)
-> (forall x.
Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk)
-> Generic (ValidatedPerasCert blk)
forall x. Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
forall x. ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x.
Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
forall blk x.
ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
$cfrom :: forall blk x.
ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
from :: forall x. ValidatedPerasCert blk -> Rep (ValidatedPerasCert blk) x
$cto :: forall blk x.
Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
to :: forall x. Rep (ValidatedPerasCert blk) x -> ValidatedPerasCert blk
Generic)
deriving anyclass Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
Proxy (ValidatedPerasCert blk) -> String
(Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo))
-> (Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo))
-> (Proxy (ValidatedPerasCert blk) -> String)
-> NoThunks (ValidatedPerasCert blk)
forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
forall blk.
StandardHash blk =>
Proxy (ValidatedPerasCert blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> ValidatedPerasCert blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk.
StandardHash blk =>
Proxy (ValidatedPerasCert blk) -> String
showTypeOf :: Proxy (ValidatedPerasCert blk) -> String
NoThunks
data ValidatedPerasVote blk = ValidatedPerasVote
{ forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote :: !(PerasVote blk)
, forall blk. ValidatedPerasVote blk -> PerasVoteStake
vpvVoteStake :: !PerasVoteStake
}
deriving stock (Int -> ValidatedPerasVote blk -> ShowS
[ValidatedPerasVote blk] -> ShowS
ValidatedPerasVote blk -> String
(Int -> ValidatedPerasVote blk -> ShowS)
-> (ValidatedPerasVote blk -> String)
-> ([ValidatedPerasVote blk] -> ShowS)
-> Show (ValidatedPerasVote blk)
forall blk.
StandardHash blk =>
Int -> ValidatedPerasVote blk -> ShowS
forall blk. StandardHash blk => [ValidatedPerasVote blk] -> ShowS
forall blk. StandardHash blk => ValidatedPerasVote blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk.
StandardHash blk =>
Int -> ValidatedPerasVote blk -> ShowS
showsPrec :: Int -> ValidatedPerasVote blk -> ShowS
$cshow :: forall blk. StandardHash blk => ValidatedPerasVote blk -> String
show :: ValidatedPerasVote blk -> String
$cshowList :: forall blk. StandardHash blk => [ValidatedPerasVote blk] -> ShowS
showList :: [ValidatedPerasVote blk] -> ShowS
Show, ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
(ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> (ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> Eq (ValidatedPerasVote blk)
forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
== :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
/= :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
Eq, Eq (ValidatedPerasVote blk)
Eq (ValidatedPerasVote blk) =>
(ValidatedPerasVote blk -> ValidatedPerasVote blk -> Ordering)
-> (ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> (ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> (ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> (ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool)
-> (ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk)
-> (ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk)
-> Ord (ValidatedPerasVote blk)
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Ordering
ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. StandardHash blk => Eq (ValidatedPerasVote blk)
forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Ordering
forall blk.
StandardHash blk =>
ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
$ccompare :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Ordering
compare :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
< :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
<= :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
$c> :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
> :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
>= :: ValidatedPerasVote blk -> ValidatedPerasVote blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
max :: ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
$cmin :: forall blk.
StandardHash blk =>
ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
min :: ValidatedPerasVote blk
-> ValidatedPerasVote blk -> ValidatedPerasVote blk
Ord, (forall x.
ValidatedPerasVote blk -> Rep (ValidatedPerasVote blk) x)
-> (forall x.
Rep (ValidatedPerasVote blk) x -> ValidatedPerasVote blk)
-> Generic (ValidatedPerasVote blk)
forall x. Rep (ValidatedPerasVote blk) x -> ValidatedPerasVote blk
forall x. ValidatedPerasVote blk -> Rep (ValidatedPerasVote blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x.
Rep (ValidatedPerasVote blk) x -> ValidatedPerasVote blk
forall blk x.
ValidatedPerasVote blk -> Rep (ValidatedPerasVote blk) x
$cfrom :: forall blk x.
ValidatedPerasVote blk -> Rep (ValidatedPerasVote blk) x
from :: forall x. ValidatedPerasVote blk -> Rep (ValidatedPerasVote blk) x
$cto :: forall blk x.
Rep (ValidatedPerasVote blk) x -> ValidatedPerasVote blk
to :: forall x. Rep (ValidatedPerasVote blk) x -> ValidatedPerasVote blk
Generic)
deriving anyclass Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
Proxy (ValidatedPerasVote blk) -> String
(Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo))
-> (Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo))
-> (Proxy (ValidatedPerasVote blk) -> String)
-> NoThunks (ValidatedPerasVote blk)
forall blk.
StandardHash blk =>
Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
forall blk.
StandardHash blk =>
Proxy (ValidatedPerasVote blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> ValidatedPerasVote blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk.
StandardHash blk =>
Proxy (ValidatedPerasVote blk) -> String
showTypeOf :: Proxy (ValidatedPerasVote blk) -> String
NoThunks
data ValidatedPerasVotesWithQuorum blk = ValidatedPerasVotesWithQuorum
{ forall blk.
ValidatedPerasVotesWithQuorum blk -> PerasVoteTarget blk
vpvqTarget :: !(PerasVoteTarget blk)
, forall blk.
ValidatedPerasVotesWithQuorum blk
-> NonEmpty (ValidatedPerasVote blk)
vpvqVotes :: !(NonEmpty (ValidatedPerasVote blk))
, forall blk. ValidatedPerasVotesWithQuorum blk -> PerasCfg blk
vpvqPerasCfg :: !(PerasCfg blk)
}
deriving stock (Int -> ValidatedPerasVotesWithQuorum blk -> ShowS
[ValidatedPerasVotesWithQuorum blk] -> ShowS
ValidatedPerasVotesWithQuorum blk -> String
(Int -> ValidatedPerasVotesWithQuorum blk -> ShowS)
-> (ValidatedPerasVotesWithQuorum blk -> String)
-> ([ValidatedPerasVotesWithQuorum blk] -> ShowS)
-> Show (ValidatedPerasVotesWithQuorum blk)
forall blk.
StandardHash blk =>
Int -> ValidatedPerasVotesWithQuorum blk -> ShowS
forall blk.
StandardHash blk =>
[ValidatedPerasVotesWithQuorum blk] -> ShowS
forall blk.
StandardHash blk =>
ValidatedPerasVotesWithQuorum blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk.
StandardHash blk =>
Int -> ValidatedPerasVotesWithQuorum blk -> ShowS
showsPrec :: Int -> ValidatedPerasVotesWithQuorum blk -> ShowS
$cshow :: forall blk.
StandardHash blk =>
ValidatedPerasVotesWithQuorum blk -> String
show :: ValidatedPerasVotesWithQuorum blk -> String
$cshowList :: forall blk.
StandardHash blk =>
[ValidatedPerasVotesWithQuorum blk] -> ShowS
showList :: [ValidatedPerasVotesWithQuorum blk] -> ShowS
Show, ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
(ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool)
-> (ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool)
-> Eq (ValidatedPerasVotesWithQuorum blk)
forall blk.
StandardHash blk =>
ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
== :: ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
/= :: ValidatedPerasVotesWithQuorum blk
-> ValidatedPerasVotesWithQuorum blk -> Bool
Eq, (forall x.
ValidatedPerasVotesWithQuorum blk
-> Rep (ValidatedPerasVotesWithQuorum blk) x)
-> (forall x.
Rep (ValidatedPerasVotesWithQuorum blk) x
-> ValidatedPerasVotesWithQuorum blk)
-> Generic (ValidatedPerasVotesWithQuorum blk)
forall x.
Rep (ValidatedPerasVotesWithQuorum blk) x
-> ValidatedPerasVotesWithQuorum blk
forall x.
ValidatedPerasVotesWithQuorum blk
-> Rep (ValidatedPerasVotesWithQuorum blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x.
Rep (ValidatedPerasVotesWithQuorum blk) x
-> ValidatedPerasVotesWithQuorum blk
forall blk x.
ValidatedPerasVotesWithQuorum blk
-> Rep (ValidatedPerasVotesWithQuorum blk) x
$cfrom :: forall blk x.
ValidatedPerasVotesWithQuorum blk
-> Rep (ValidatedPerasVotesWithQuorum blk) x
from :: forall x.
ValidatedPerasVotesWithQuorum blk
-> Rep (ValidatedPerasVotesWithQuorum blk) x
$cto :: forall blk x.
Rep (ValidatedPerasVotesWithQuorum blk) x
-> ValidatedPerasVotesWithQuorum blk
to :: forall x.
Rep (ValidatedPerasVotesWithQuorum blk) x
-> ValidatedPerasVotesWithQuorum blk
Generic)
deriving anyclass Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
Proxy (ValidatedPerasVotesWithQuorum blk) -> String
(Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo))
-> (Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo))
-> (Proxy (ValidatedPerasVotesWithQuorum blk) -> String)
-> NoThunks (ValidatedPerasVotesWithQuorum blk)
forall blk.
StandardHash blk =>
Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
forall blk.
StandardHash blk =>
Proxy (ValidatedPerasVotesWithQuorum blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
noThunks :: Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context
-> ValidatedPerasVotesWithQuorum blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk.
StandardHash blk =>
Proxy (ValidatedPerasVotesWithQuorum blk) -> String
showTypeOf :: Proxy (ValidatedPerasVotesWithQuorum blk) -> String
NoThunks
votesReachQuorum ::
StandardHash blk =>
PerasCfg blk ->
[ValidatedPerasVote blk] ->
Maybe (ValidatedPerasVotesWithQuorum blk)
votesReachQuorum :: forall blk.
StandardHash blk =>
PerasCfg blk
-> [ValidatedPerasVote blk]
-> Maybe (ValidatedPerasVotesWithQuorum blk)
votesReachQuorum PerasCfg blk
cfg [ValidatedPerasVote blk]
votes =
case [ValidatedPerasVote blk]
votes of
[] -> Maybe (ValidatedPerasVotesWithQuorum blk)
forall a. Maybe a
Nothing
(ValidatedPerasVote blk
v0 : [ValidatedPerasVote blk]
vs)
| Bool -> Bool
not (ValidatedPerasVote blk -> [ValidatedPerasVote blk] -> Bool
forall {t :: * -> *} {blk} {vote} {a}.
(Foldable t, StandardHash blk, HasPerasVoteTarget vote blk,
HasPerasVoteTarget a blk) =>
vote -> t a -> Bool
allVotesMatchTarget ValidatedPerasVote blk
v0 [ValidatedPerasVote blk]
vs) ->
Maybe (ValidatedPerasVotesWithQuorum blk)
forall a. Maybe a
Nothing
| Bool -> Bool
not Bool
votesHaveEnoughStake ->
Maybe (ValidatedPerasVotesWithQuorum blk)
forall a. Maybe a
Nothing
| Bool
otherwise ->
ValidatedPerasVotesWithQuorum blk
-> Maybe (ValidatedPerasVotesWithQuorum blk)
forall a. a -> Maybe a
Just
ValidatedPerasVotesWithQuorum
{ vpvqTarget :: PerasVoteTarget blk
vpvqTarget = ValidatedPerasVote blk -> PerasVoteTarget blk
forall vote blk.
HasPerasVoteTarget vote blk =>
vote -> PerasVoteTarget blk
getPerasVoteTarget ValidatedPerasVote blk
v0
, vpvqVotes :: NonEmpty (ValidatedPerasVote blk)
vpvqVotes = ValidatedPerasVote blk
v0 ValidatedPerasVote blk
-> [ValidatedPerasVote blk] -> NonEmpty (ValidatedPerasVote blk)
forall a. a -> [a] -> NonEmpty a
:| [ValidatedPerasVote blk]
vs
, vpvqPerasCfg :: PerasCfg blk
vpvqPerasCfg = PerasCfg blk
cfg
}
where
totalVoteStake :: PerasVoteStake
totalVoteStake =
[PerasVoteStake] -> PerasVoteStake
forall a. Monoid a => [a] -> a
mconcat (ValidatedPerasVote blk -> PerasVoteStake
forall blk. ValidatedPerasVote blk -> PerasVoteStake
vpvVoteStake (ValidatedPerasVote blk -> PerasVoteStake)
-> [ValidatedPerasVote blk] -> [PerasVoteStake]
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
<$> [ValidatedPerasVote blk]
votes)
votesHaveEnoughStake :: Bool
votesHaveEnoughStake =
PerasParams -> PerasVoteStake -> Bool
stakeAboveThreshold PerasParams
PerasCfg blk
cfg PerasVoteStake
totalVoteStake
allVotesMatchTarget :: vote -> t a -> Bool
allVotesMatchTarget vote
target =
(a -> Bool) -> t a -> Bool
forall (t :: * -> *) a. Foldable t => (a -> Bool) -> t a -> Bool
all ((PerasVoteTarget blk -> PerasVoteTarget blk -> Bool
forall a. Eq a => a -> a -> Bool
== (vote -> PerasVoteTarget blk
forall vote blk.
HasPerasVoteTarget vote blk =>
vote -> PerasVoteTarget blk
getPerasVoteTarget vote
target)) (PerasVoteTarget blk -> Bool)
-> (a -> PerasVoteTarget blk) -> a -> Bool
forall b c a. (b -> c) -> (a -> b) -> a -> c
. a -> PerasVoteTarget blk
forall vote blk.
HasPerasVoteTarget vote blk =>
vote -> PerasVoteTarget blk
getPerasVoteTarget)
class
( Show (PerasCfg blk)
, NoThunks (PerasCert blk)
) =>
BlockSupportsPeras blk
where
type PerasCfg blk
data PerasCert blk
data PerasVote blk
data PerasValidationErr blk
data PerasForgeErr blk
validatePerasCert ::
PerasCfg blk ->
PerasCert blk ->
Either (PerasValidationErr blk) (ValidatedPerasCert blk)
validatePerasVote ::
PerasCfg blk ->
PerasVoteStakeDistr ->
PerasVote blk ->
Either (PerasValidationErr blk) (ValidatedPerasVote blk)
forgePerasCert ::
PerasCfg blk ->
ValidatedPerasVotesWithQuorum blk ->
Either (PerasForgeErr blk) (ValidatedPerasCert blk)
instance StandardHash blk => BlockSupportsPeras blk where
type PerasCfg blk = PerasParams
data PerasCert blk = PerasCert
{ forall blk. PerasCert blk -> PerasRoundNo
pcCertRound :: PerasRoundNo
, forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock :: Point blk
}
deriving stock ((forall x. PerasCert blk -> Rep (PerasCert blk) x)
-> (forall x. Rep (PerasCert blk) x -> PerasCert blk)
-> Generic (PerasCert blk)
forall x. Rep (PerasCert blk) x -> PerasCert blk
forall x. PerasCert blk -> Rep (PerasCert blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasCert blk) x -> PerasCert blk
forall blk x. PerasCert blk -> Rep (PerasCert blk) x
$cfrom :: forall blk x. PerasCert blk -> Rep (PerasCert blk) x
from :: forall x. PerasCert blk -> Rep (PerasCert blk) x
$cto :: forall blk x. Rep (PerasCert blk) x -> PerasCert blk
to :: forall x. Rep (PerasCert blk) x -> PerasCert blk
Generic, PerasCert blk -> PerasCert blk -> Bool
(PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool) -> Eq (PerasCert blk)
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
== :: PerasCert blk -> PerasCert blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
/= :: PerasCert blk -> PerasCert blk -> Bool
Eq, Eq (PerasCert blk)
Eq (PerasCert blk) =>
(PerasCert blk -> PerasCert blk -> Ordering)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> Bool)
-> (PerasCert blk -> PerasCert blk -> PerasCert blk)
-> (PerasCert blk -> PerasCert blk -> PerasCert blk)
-> Ord (PerasCert blk)
PerasCert blk -> PerasCert blk -> Bool
PerasCert blk -> PerasCert blk -> Ordering
PerasCert blk -> PerasCert blk -> PerasCert blk
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. StandardHash blk => Eq (PerasCert blk)
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Ordering
forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
$ccompare :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Ordering
compare :: PerasCert blk -> PerasCert blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
< :: PerasCert blk -> PerasCert blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
<= :: PerasCert blk -> PerasCert blk -> Bool
$c> :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
> :: PerasCert blk -> PerasCert blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> Bool
>= :: PerasCert blk -> PerasCert blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
max :: PerasCert blk -> PerasCert blk -> PerasCert blk
$cmin :: forall blk.
StandardHash blk =>
PerasCert blk -> PerasCert blk -> PerasCert blk
min :: PerasCert blk -> PerasCert blk -> PerasCert blk
Ord, Int -> PerasCert blk -> ShowS
[PerasCert blk] -> ShowS
PerasCert blk -> String
(Int -> PerasCert blk -> ShowS)
-> (PerasCert blk -> String)
-> ([PerasCert blk] -> ShowS)
-> Show (PerasCert blk)
forall blk. StandardHash blk => Int -> PerasCert blk -> ShowS
forall blk. StandardHash blk => [PerasCert blk] -> ShowS
forall blk. StandardHash blk => PerasCert blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> PerasCert blk -> ShowS
showsPrec :: Int -> PerasCert blk -> ShowS
$cshow :: forall blk. StandardHash blk => PerasCert blk -> String
show :: PerasCert blk -> String
$cshowList :: forall blk. StandardHash blk => [PerasCert blk] -> ShowS
showList :: [PerasCert blk] -> ShowS
Show)
deriving anyclass Context -> PerasCert blk -> IO (Maybe ThunkInfo)
Proxy (PerasCert blk) -> String
(Context -> PerasCert blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasCert blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasCert blk) -> String)
-> NoThunks (PerasCert blk)
forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
forall blk. StandardHash blk => Proxy (PerasCert blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasCert blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> PerasCert blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasCert blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. StandardHash blk => Proxy (PerasCert blk) -> String
showTypeOf :: Proxy (PerasCert blk) -> String
NoThunks
data PerasVote blk = PerasVote
{ forall blk. PerasVote blk -> PerasRoundNo
pvVoteRound :: PerasRoundNo
, forall blk. PerasVote blk -> Point blk
pvVoteBlock :: Point blk
, forall blk. PerasVote blk -> PerasVoterId
pvVoteVoterId :: PerasVoterId
}
deriving stock ((forall x. PerasVote blk -> Rep (PerasVote blk) x)
-> (forall x. Rep (PerasVote blk) x -> PerasVote blk)
-> Generic (PerasVote blk)
forall x. Rep (PerasVote blk) x -> PerasVote blk
forall x. PerasVote blk -> Rep (PerasVote blk) x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
forall blk x. Rep (PerasVote blk) x -> PerasVote blk
forall blk x. PerasVote blk -> Rep (PerasVote blk) x
$cfrom :: forall blk x. PerasVote blk -> Rep (PerasVote blk) x
from :: forall x. PerasVote blk -> Rep (PerasVote blk) x
$cto :: forall blk x. Rep (PerasVote blk) x -> PerasVote blk
to :: forall x. Rep (PerasVote blk) x -> PerasVote blk
Generic, PerasVote blk -> PerasVote blk -> Bool
(PerasVote blk -> PerasVote blk -> Bool)
-> (PerasVote blk -> PerasVote blk -> Bool) -> Eq (PerasVote blk)
forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
== :: PerasVote blk -> PerasVote blk -> Bool
$c/= :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
/= :: PerasVote blk -> PerasVote blk -> Bool
Eq, Eq (PerasVote blk)
Eq (PerasVote blk) =>
(PerasVote blk -> PerasVote blk -> Ordering)
-> (PerasVote blk -> PerasVote blk -> Bool)
-> (PerasVote blk -> PerasVote blk -> Bool)
-> (PerasVote blk -> PerasVote blk -> Bool)
-> (PerasVote blk -> PerasVote blk -> Bool)
-> (PerasVote blk -> PerasVote blk -> PerasVote blk)
-> (PerasVote blk -> PerasVote blk -> PerasVote blk)
-> Ord (PerasVote blk)
PerasVote blk -> PerasVote blk -> Bool
PerasVote blk -> PerasVote blk -> Ordering
PerasVote blk -> PerasVote blk -> PerasVote blk
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
forall blk. StandardHash blk => Eq (PerasVote blk)
forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Ordering
forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> PerasVote blk
$ccompare :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Ordering
compare :: PerasVote blk -> PerasVote blk -> Ordering
$c< :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
< :: PerasVote blk -> PerasVote blk -> Bool
$c<= :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
<= :: PerasVote blk -> PerasVote blk -> Bool
$c> :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
> :: PerasVote blk -> PerasVote blk -> Bool
$c>= :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> Bool
>= :: PerasVote blk -> PerasVote blk -> Bool
$cmax :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> PerasVote blk
max :: PerasVote blk -> PerasVote blk -> PerasVote blk
$cmin :: forall blk.
StandardHash blk =>
PerasVote blk -> PerasVote blk -> PerasVote blk
min :: PerasVote blk -> PerasVote blk -> PerasVote blk
Ord, Int -> PerasVote blk -> ShowS
[PerasVote blk] -> ShowS
PerasVote blk -> String
(Int -> PerasVote blk -> ShowS)
-> (PerasVote blk -> String)
-> ([PerasVote blk] -> ShowS)
-> Show (PerasVote blk)
forall blk. StandardHash blk => Int -> PerasVote blk -> ShowS
forall blk. StandardHash blk => [PerasVote blk] -> ShowS
forall blk. StandardHash blk => PerasVote blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. StandardHash blk => Int -> PerasVote blk -> ShowS
showsPrec :: Int -> PerasVote blk -> ShowS
$cshow :: forall blk. StandardHash blk => PerasVote blk -> String
show :: PerasVote blk -> String
$cshowList :: forall blk. StandardHash blk => [PerasVote blk] -> ShowS
showList :: [PerasVote blk] -> ShowS
Show)
deriving anyclass Context -> PerasVote blk -> IO (Maybe ThunkInfo)
Proxy (PerasVote blk) -> String
(Context -> PerasVote blk -> IO (Maybe ThunkInfo))
-> (Context -> PerasVote blk -> IO (Maybe ThunkInfo))
-> (Proxy (PerasVote blk) -> String)
-> NoThunks (PerasVote blk)
forall blk.
StandardHash blk =>
Context -> PerasVote blk -> IO (Maybe ThunkInfo)
forall blk. StandardHash blk => Proxy (PerasVote blk) -> String
forall a.
(Context -> a -> IO (Maybe ThunkInfo))
-> (Context -> a -> IO (Maybe ThunkInfo))
-> (Proxy a -> String)
-> NoThunks a
$cnoThunks :: forall blk.
StandardHash blk =>
Context -> PerasVote blk -> IO (Maybe ThunkInfo)
noThunks :: Context -> PerasVote blk -> IO (Maybe ThunkInfo)
$cwNoThunks :: forall blk.
StandardHash blk =>
Context -> PerasVote blk -> IO (Maybe ThunkInfo)
wNoThunks :: Context -> PerasVote blk -> IO (Maybe ThunkInfo)
$cshowTypeOf :: forall blk. StandardHash blk => Proxy (PerasVote blk) -> String
showTypeOf :: Proxy (PerasVote blk) -> String
NoThunks
data PerasValidationErr blk
= PerasValidationErr
deriving stock (Int -> PerasValidationErr blk -> ShowS
[PerasValidationErr blk] -> ShowS
PerasValidationErr blk -> String
(Int -> PerasValidationErr blk -> ShowS)
-> (PerasValidationErr blk -> String)
-> ([PerasValidationErr blk] -> ShowS)
-> Show (PerasValidationErr blk)
forall blk. Int -> PerasValidationErr blk -> ShowS
forall blk. [PerasValidationErr blk] -> ShowS
forall blk. PerasValidationErr blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasValidationErr blk -> ShowS
showsPrec :: Int -> PerasValidationErr blk -> ShowS
$cshow :: forall blk. PerasValidationErr blk -> String
show :: PerasValidationErr blk -> String
$cshowList :: forall blk. [PerasValidationErr blk] -> ShowS
showList :: [PerasValidationErr blk] -> ShowS
Show, PerasValidationErr blk -> PerasValidationErr blk -> Bool
(PerasValidationErr blk -> PerasValidationErr blk -> Bool)
-> (PerasValidationErr blk -> PerasValidationErr blk -> Bool)
-> Eq (PerasValidationErr blk)
forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
== :: PerasValidationErr blk -> PerasValidationErr blk -> Bool
$c/= :: forall blk.
PerasValidationErr blk -> PerasValidationErr blk -> Bool
/= :: PerasValidationErr blk -> PerasValidationErr blk -> Bool
Eq)
data PerasForgeErr blk
= PerasForgeErr
deriving stock (Int -> PerasForgeErr blk -> ShowS
[PerasForgeErr blk] -> ShowS
PerasForgeErr blk -> String
(Int -> PerasForgeErr blk -> ShowS)
-> (PerasForgeErr blk -> String)
-> ([PerasForgeErr blk] -> ShowS)
-> Show (PerasForgeErr blk)
forall blk. Int -> PerasForgeErr blk -> ShowS
forall blk. [PerasForgeErr blk] -> ShowS
forall blk. PerasForgeErr blk -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: forall blk. Int -> PerasForgeErr blk -> ShowS
showsPrec :: Int -> PerasForgeErr blk -> ShowS
$cshow :: forall blk. PerasForgeErr blk -> String
show :: PerasForgeErr blk -> String
$cshowList :: forall blk. [PerasForgeErr blk] -> ShowS
showList :: [PerasForgeErr blk] -> ShowS
Show, PerasForgeErr blk -> PerasForgeErr blk -> Bool
(PerasForgeErr blk -> PerasForgeErr blk -> Bool)
-> (PerasForgeErr blk -> PerasForgeErr blk -> Bool)
-> Eq (PerasForgeErr blk)
forall blk. PerasForgeErr blk -> PerasForgeErr blk -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: forall blk. PerasForgeErr blk -> PerasForgeErr blk -> Bool
== :: PerasForgeErr blk -> PerasForgeErr blk -> Bool
$c/= :: forall blk. PerasForgeErr blk -> PerasForgeErr blk -> Bool
/= :: PerasForgeErr blk -> PerasForgeErr blk -> Bool
Eq)
validatePerasCert :: PerasCfg blk
-> PerasCert blk
-> Either (PerasValidationErr blk) (ValidatedPerasCert blk)
validatePerasCert PerasCfg blk
params PerasCert blk
cert =
ValidatedPerasCert blk
-> Either (PerasValidationErr blk) (ValidatedPerasCert blk)
forall a b. b -> Either a b
Right
ValidatedPerasCert
{ vpcCert :: PerasCert blk
vpcCert = PerasCert blk
cert
, vpcCertBoost :: PerasWeight
vpcCertBoost = PerasParams -> PerasWeight
perasWeight PerasParams
PerasCfg blk
params
}
validatePerasVote :: PerasCfg blk
-> PerasVoteStakeDistr
-> PerasVote blk
-> Either (PerasValidationErr blk) (ValidatedPerasVote blk)
validatePerasVote PerasCfg blk
_params PerasVoteStakeDistr
stakeDistr PerasVote blk
vote
| Just PerasVoteStake
stake <- PerasVote blk -> PerasVoteStakeDistr -> Maybe PerasVoteStake
forall blk.
PerasVote blk -> PerasVoteStakeDistr -> Maybe PerasVoteStake
lookupPerasVoteStake PerasVote blk
vote PerasVoteStakeDistr
stakeDistr =
ValidatedPerasVote blk
-> Either (PerasValidationErr blk) (ValidatedPerasVote blk)
forall a b. b -> Either a b
Right
ValidatedPerasVote
{ vpvVote :: PerasVote blk
vpvVote = PerasVote blk
vote
, vpvVoteStake :: PerasVoteStake
vpvVoteStake = PerasVoteStake
stake
}
| Bool
otherwise =
PerasValidationErr blk
-> Either (PerasValidationErr blk) (ValidatedPerasVote blk)
forall a b. a -> Either a b
Left PerasValidationErr blk
forall blk. PerasValidationErr blk
PerasValidationErr
forgePerasCert :: PerasCfg blk
-> ValidatedPerasVotesWithQuorum blk
-> Either (PerasForgeErr blk) (ValidatedPerasCert blk)
forgePerasCert PerasCfg blk
params ValidatedPerasVotesWithQuorum blk
votes =
ValidatedPerasCert blk
-> Either (PerasForgeErr blk) (ValidatedPerasCert blk)
forall a. a -> Either (PerasForgeErr blk) a
forall (m :: * -> *) a. Monad m => a -> m a
return (ValidatedPerasCert blk
-> Either (PerasForgeErr blk) (ValidatedPerasCert blk))
-> ValidatedPerasCert blk
-> Either (PerasForgeErr blk) (ValidatedPerasCert blk)
forall a b. (a -> b) -> a -> b
$
ValidatedPerasCert
{ vpcCert :: PerasCert blk
vpcCert =
PerasCert
{ pcCertRound :: PerasRoundNo
pcCertRound = PerasVoteTarget blk -> PerasRoundNo
forall blk. PerasVoteTarget blk -> PerasRoundNo
pvtRoundNo (ValidatedPerasVotesWithQuorum blk -> PerasVoteTarget blk
forall blk.
ValidatedPerasVotesWithQuorum blk -> PerasVoteTarget blk
vpvqTarget ValidatedPerasVotesWithQuorum blk
votes)
, pcCertBoostedBlock :: Point blk
pcCertBoostedBlock = PerasVoteTarget blk -> Point blk
forall blk. PerasVoteTarget blk -> Point blk
pvtBlock (ValidatedPerasVotesWithQuorum blk -> PerasVoteTarget blk
forall blk.
ValidatedPerasVotesWithQuorum blk -> PerasVoteTarget blk
vpvqTarget ValidatedPerasVotesWithQuorum blk
votes)
}
, vpcCertBoost :: PerasWeight
vpcCertBoost = PerasParams -> PerasWeight
perasWeight PerasParams
PerasCfg blk
params
}
instance ShowProxy blk => ShowProxy (PerasCert blk) where
showProxy :: Proxy (PerasCert blk) -> String
showProxy Proxy (PerasCert blk)
_ = String
"PerasCert " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy blk -> String
forall {k} (p :: k). ShowProxy p => Proxy p -> String
showProxy (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @blk)
instance ShowProxy blk => ShowProxy (PerasVote blk) where
showProxy :: Proxy (PerasVote blk) -> String
showProxy Proxy (PerasVote blk)
_ = String
"PerasVote " String -> ShowS
forall a. Semigroup a => a -> a -> a
<> Proxy blk -> String
forall {k} (p :: k). ShowProxy p => Proxy p -> String
showProxy (forall t. Proxy t
forall {k} (t :: k). Proxy t
Proxy @blk)
instance Serialise (HeaderHash blk) => Serialise (PerasCert blk) where
encode :: PerasCert blk -> Encoding
encode PerasCert{PerasRoundNo
pcCertRound :: forall blk. PerasCert blk -> PerasRoundNo
pcCertRound :: PerasRoundNo
pcCertRound, Point blk
pcCertBoostedBlock :: forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock :: Point blk
pcCertBoostedBlock} =
Word -> Encoding
encodeListLen Word
2
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasRoundNo -> Encoding
forall a. Serialise a => a -> Encoding
encode PerasRoundNo
pcCertRound
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Point blk -> Encoding
forall a. Serialise a => a -> Encoding
encode Point blk
pcCertBoostedBlock
decode :: forall s. Decoder s (PerasCert blk)
decode = do
Int -> Decoder s ()
forall s. Int -> Decoder s ()
decodeListLenOf Int
2
pcCertRound <- Decoder s PerasRoundNo
forall s. Decoder s PerasRoundNo
forall a s. Serialise a => Decoder s a
decode
pcCertBoostedBlock <- decode
pure $ PerasCert{pcCertRound, pcCertBoostedBlock}
instance Serialise (HeaderHash blk) => Serialise (PerasVote blk) where
encode :: PerasVote blk -> Encoding
encode PerasVote{PerasRoundNo
pvVoteRound :: forall blk. PerasVote blk -> PerasRoundNo
pvVoteRound :: PerasRoundNo
pvVoteRound, Point blk
pvVoteBlock :: forall blk. PerasVote blk -> Point blk
pvVoteBlock :: Point blk
pvVoteBlock, PerasVoterId
pvVoteVoterId :: forall blk. PerasVote blk -> PerasVoterId
pvVoteVoterId :: PerasVoterId
pvVoteVoterId} =
Word -> Encoding
encodeListLen Word
3
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> PerasRoundNo -> Encoding
forall a. Serialise a => a -> Encoding
encode PerasRoundNo
pvVoteRound
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> Point blk -> Encoding
forall a. Serialise a => a -> Encoding
encode Point blk
pvVoteBlock
Encoding -> Encoding -> Encoding
forall a. Semigroup a => a -> a -> a
<> KeyHash StakePool -> Encoding
forall a. ToCBOR a => a -> Encoding
KeyHash.toCBOR (PerasVoterId -> KeyHash StakePool
unPerasVoterId PerasVoterId
pvVoteVoterId)
decode :: forall s. Decoder s (PerasVote blk)
decode = do
Int -> Decoder s ()
forall s. Int -> Decoder s ()
decodeListLenOf Int
3
pvVoteRound <- Decoder s PerasRoundNo
forall s. Decoder s PerasRoundNo
forall a s. Serialise a => Decoder s a
decode
pvVoteBlock <- decode
pvVoteVoterId <- PerasVoterId <$> KeyHash.fromCBOR
pure $ PerasVote{pvVoteRound, pvVoteBlock, pvVoteVoterId}
class HasPerasCertRound cert where
getPerasCertRound :: cert -> PerasRoundNo
instance HasPerasCertRound (PerasCert blk) where
getPerasCertRound :: PerasCert blk -> PerasRoundNo
getPerasCertRound = PerasCert blk -> PerasRoundNo
forall blk. PerasCert blk -> PerasRoundNo
pcCertRound
instance HasPerasCertRound (ValidatedPerasCert blk) where
getPerasCertRound :: ValidatedPerasCert blk -> PerasRoundNo
getPerasCertRound = PerasCert blk -> PerasRoundNo
forall cert. HasPerasCertRound cert => cert -> PerasRoundNo
getPerasCertRound (PerasCert blk -> PerasRoundNo)
-> (ValidatedPerasCert blk -> PerasCert blk)
-> ValidatedPerasCert blk
-> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasCert blk -> PerasCert blk
forall blk. ValidatedPerasCert blk -> PerasCert blk
vpcCert
instance
HasPerasCertRound cert =>
HasPerasCertRound (WithArrivalTime cert)
where
getPerasCertRound :: WithArrivalTime cert -> PerasRoundNo
getPerasCertRound = cert -> PerasRoundNo
forall cert. HasPerasCertRound cert => cert -> PerasRoundNo
getPerasCertRound (cert -> PerasRoundNo)
-> (WithArrivalTime cert -> cert)
-> WithArrivalTime cert
-> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime cert -> cert
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasCertBoostedBlock cert blk | cert -> blk where
getPerasCertBoostedBlock :: cert -> Point blk
instance HasPerasCertBoostedBlock (PerasCert blk) blk where
getPerasCertBoostedBlock :: PerasCert blk -> Point blk
getPerasCertBoostedBlock = PerasCert blk -> Point blk
forall blk. PerasCert blk -> Point blk
pcCertBoostedBlock
instance HasPerasCertBoostedBlock (ValidatedPerasCert blk) blk where
getPerasCertBoostedBlock :: ValidatedPerasCert blk -> Point blk
getPerasCertBoostedBlock = PerasCert blk -> Point blk
forall cert blk.
HasPerasCertBoostedBlock cert blk =>
cert -> Point blk
getPerasCertBoostedBlock (PerasCert blk -> Point blk)
-> (ValidatedPerasCert blk -> PerasCert blk)
-> ValidatedPerasCert blk
-> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasCert blk -> PerasCert blk
forall blk. ValidatedPerasCert blk -> PerasCert blk
vpcCert
instance
HasPerasCertBoostedBlock cert blk =>
HasPerasCertBoostedBlock (WithArrivalTime cert) blk
where
getPerasCertBoostedBlock :: WithArrivalTime cert -> Point blk
getPerasCertBoostedBlock = cert -> Point blk
forall cert blk.
HasPerasCertBoostedBlock cert blk =>
cert -> Point blk
getPerasCertBoostedBlock (cert -> Point blk)
-> (WithArrivalTime cert -> cert)
-> WithArrivalTime cert
-> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime cert -> cert
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasCertBoost cert where
getPerasCertBoost :: cert -> PerasWeight
instance HasPerasCertBoost (ValidatedPerasCert blk) where
getPerasCertBoost :: ValidatedPerasCert blk -> PerasWeight
getPerasCertBoost = ValidatedPerasCert blk -> PerasWeight
forall blk. ValidatedPerasCert blk -> PerasWeight
vpcCertBoost
instance
HasPerasCertBoost cert =>
HasPerasCertBoost (WithArrivalTime cert)
where
getPerasCertBoost :: WithArrivalTime cert -> PerasWeight
getPerasCertBoost = cert -> PerasWeight
forall cert. HasPerasCertBoost cert => cert -> PerasWeight
getPerasCertBoost (cert -> PerasWeight)
-> (WithArrivalTime cert -> cert)
-> WithArrivalTime cert
-> PerasWeight
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime cert -> cert
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteRound vote where
getPerasVoteRound :: vote -> PerasRoundNo
instance HasPerasVoteRound (PerasVote blk) where
getPerasVoteRound :: PerasVote blk -> PerasRoundNo
getPerasVoteRound = PerasVote blk -> PerasRoundNo
forall blk. PerasVote blk -> PerasRoundNo
pvVoteRound
instance HasPerasVoteRound (ValidatedPerasVote blk) where
getPerasVoteRound :: ValidatedPerasVote blk -> PerasRoundNo
getPerasVoteRound = PerasVote blk -> PerasRoundNo
forall vote. HasPerasVoteRound vote => vote -> PerasRoundNo
getPerasVoteRound (PerasVote blk -> PerasRoundNo)
-> (ValidatedPerasVote blk -> PerasVote blk)
-> ValidatedPerasVote blk
-> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasVote blk -> PerasVote blk
forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote
instance
HasPerasVoteRound vote =>
HasPerasVoteRound (WithArrivalTime vote)
where
getPerasVoteRound :: WithArrivalTime vote -> PerasRoundNo
getPerasVoteRound = vote -> PerasRoundNo
forall vote. HasPerasVoteRound vote => vote -> PerasRoundNo
getPerasVoteRound (vote -> PerasRoundNo)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> PerasRoundNo
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteBlock vote blk | vote -> blk where
getPerasVoteBlock :: vote -> Point blk
instance HasPerasVoteBlock (PerasVote blk) blk where
getPerasVoteBlock :: PerasVote blk -> Point blk
getPerasVoteBlock = PerasVote blk -> Point blk
forall blk. PerasVote blk -> Point blk
pvVoteBlock
instance HasPerasVoteBlock (ValidatedPerasVote blk) blk where
getPerasVoteBlock :: ValidatedPerasVote blk -> Point blk
getPerasVoteBlock = PerasVote blk -> Point blk
forall vote blk. HasPerasVoteBlock vote blk => vote -> Point blk
getPerasVoteBlock (PerasVote blk -> Point blk)
-> (ValidatedPerasVote blk -> PerasVote blk)
-> ValidatedPerasVote blk
-> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasVote blk -> PerasVote blk
forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote
instance
HasPerasVoteBlock vote blk =>
HasPerasVoteBlock (WithArrivalTime vote) blk
where
getPerasVoteBlock :: WithArrivalTime vote -> Point blk
getPerasVoteBlock = vote -> Point blk
forall vote blk. HasPerasVoteBlock vote blk => vote -> Point blk
getPerasVoteBlock (vote -> Point blk)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> Point blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteVoterId vote where
getPerasVoteVoterId :: vote -> PerasVoterId
instance HasPerasVoteVoterId (PerasVote blk) where
getPerasVoteVoterId :: PerasVote blk -> PerasVoterId
getPerasVoteVoterId = PerasVote blk -> PerasVoterId
forall blk. PerasVote blk -> PerasVoterId
pvVoteVoterId
instance HasPerasVoteVoterId (ValidatedPerasVote blk) where
getPerasVoteVoterId :: ValidatedPerasVote blk -> PerasVoterId
getPerasVoteVoterId = PerasVote blk -> PerasVoterId
forall vote. HasPerasVoteVoterId vote => vote -> PerasVoterId
getPerasVoteVoterId (PerasVote blk -> PerasVoterId)
-> (ValidatedPerasVote blk -> PerasVote blk)
-> ValidatedPerasVote blk
-> PerasVoterId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasVote blk -> PerasVote blk
forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote
instance
HasPerasVoteVoterId vote =>
HasPerasVoteVoterId (WithArrivalTime vote)
where
getPerasVoteVoterId :: WithArrivalTime vote -> PerasVoterId
getPerasVoteVoterId = vote -> PerasVoterId
forall vote. HasPerasVoteVoterId vote => vote -> PerasVoterId
getPerasVoteVoterId (vote -> PerasVoterId)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> PerasVoterId
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteStake vote where
getPerasVoteStake :: vote -> PerasVoteStake
instance HasPerasVoteStake (ValidatedPerasVote blk) where
getPerasVoteStake :: ValidatedPerasVote blk -> PerasVoteStake
getPerasVoteStake = ValidatedPerasVote blk -> PerasVoteStake
forall blk. ValidatedPerasVote blk -> PerasVoteStake
vpvVoteStake
instance
HasPerasVoteStake vote =>
HasPerasVoteStake (WithArrivalTime vote)
where
getPerasVoteStake :: WithArrivalTime vote -> PerasVoteStake
getPerasVoteStake = vote -> PerasVoteStake
forall vote. HasPerasVoteStake vote => vote -> PerasVoteStake
getPerasVoteStake (vote -> PerasVoteStake)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> PerasVoteStake
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteTarget vote blk | vote -> blk where
getPerasVoteTarget :: vote -> PerasVoteTarget blk
instance HasPerasVoteTarget (PerasVote blk) blk where
getPerasVoteTarget :: PerasVote blk -> PerasVoteTarget blk
getPerasVoteTarget PerasVote blk
vote =
PerasVoteTarget
{ pvtRoundNo :: PerasRoundNo
pvtRoundNo = PerasVote blk -> PerasRoundNo
forall blk. PerasVote blk -> PerasRoundNo
pvVoteRound PerasVote blk
vote
, pvtBlock :: Point blk
pvtBlock = PerasVote blk -> Point blk
forall blk. PerasVote blk -> Point blk
pvVoteBlock PerasVote blk
vote
}
instance HasPerasVoteTarget (ValidatedPerasVote blk) blk where
getPerasVoteTarget :: ValidatedPerasVote blk -> PerasVoteTarget blk
getPerasVoteTarget = PerasVote blk -> PerasVoteTarget blk
forall vote blk.
HasPerasVoteTarget vote blk =>
vote -> PerasVoteTarget blk
getPerasVoteTarget (PerasVote blk -> PerasVoteTarget blk)
-> (ValidatedPerasVote blk -> PerasVote blk)
-> ValidatedPerasVote blk
-> PerasVoteTarget blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasVote blk -> PerasVote blk
forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote
instance
HasPerasVoteTarget vote blk =>
HasPerasVoteTarget (WithArrivalTime vote) blk
where
getPerasVoteTarget :: WithArrivalTime vote -> PerasVoteTarget blk
getPerasVoteTarget = vote -> PerasVoteTarget blk
forall vote blk.
HasPerasVoteTarget vote blk =>
vote -> PerasVoteTarget blk
getPerasVoteTarget (vote -> PerasVoteTarget blk)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> PerasVoteTarget blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime
class HasPerasVoteId vote blk | vote -> blk where
getPerasVoteId :: vote -> PerasVoteId blk
instance HasPerasVoteId (PerasVote blk) blk where
getPerasVoteId :: PerasVote blk -> PerasVoteId blk
getPerasVoteId PerasVote blk
vote =
PerasVoteId
{ pviRoundNo :: PerasRoundNo
pviRoundNo = PerasVote blk -> PerasRoundNo
forall blk. PerasVote blk -> PerasRoundNo
pvVoteRound PerasVote blk
vote
, pviVoterId :: PerasVoterId
pviVoterId = PerasVote blk -> PerasVoterId
forall blk. PerasVote blk -> PerasVoterId
pvVoteVoterId PerasVote blk
vote
}
instance HasPerasVoteId (ValidatedPerasVote blk) blk where
getPerasVoteId :: ValidatedPerasVote blk -> PerasVoteId blk
getPerasVoteId = PerasVote blk -> PerasVoteId blk
forall vote blk. HasPerasVoteId vote blk => vote -> PerasVoteId blk
getPerasVoteId (PerasVote blk -> PerasVoteId blk)
-> (ValidatedPerasVote blk -> PerasVote blk)
-> ValidatedPerasVote blk
-> PerasVoteId blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. ValidatedPerasVote blk -> PerasVote blk
forall blk. ValidatedPerasVote blk -> PerasVote blk
vpvVote
instance
HasPerasVoteId vote blk =>
HasPerasVoteId (WithArrivalTime vote) blk
where
getPerasVoteId :: WithArrivalTime vote -> PerasVoteId blk
getPerasVoteId = vote -> PerasVoteId blk
forall vote blk. HasPerasVoteId vote blk => vote -> PerasVoteId blk
getPerasVoteId (vote -> PerasVoteId blk)
-> (WithArrivalTime vote -> vote)
-> WithArrivalTime vote
-> PerasVoteId blk
forall b c a. (b -> c) -> (a -> b) -> a -> c
. WithArrivalTime vote -> vote
forall a. WithArrivalTime a -> a
forgetArrivalTime