|
3 | 3 | {-# LANGUAGE DerivingVia #-} |
4 | 4 | {-# LANGUAGE FlexibleContexts #-} |
5 | 5 | {-# LANGUAGE FlexibleInstances #-} |
| 6 | +{-# LANGUAGE FunctionalDependencies #-} |
6 | 7 | {-# LANGUAGE GeneralizedNewtypeDeriving #-} |
7 | | -{-# LANGUAGE MultiParamTypeClasses #-} |
8 | 8 | {-# LANGUAGE NamedFieldPuns #-} |
9 | 9 | {-# LANGUAGE ScopedTypeVariables #-} |
10 | 10 | {-# LANGUAGE TypeApplications #-} |
@@ -38,6 +38,7 @@ import Data.Word (Word64) |
38 | 38 | import GHC.Generics (Generic) |
39 | 39 | import NoThunks.Class |
40 | 40 | import Ouroboros.Consensus.Block.Abstract |
| 41 | +import Ouroboros.Consensus.BlockchainTime.WallClock.Types (WithArrivalTime (..)) |
41 | 42 | import Ouroboros.Consensus.Util |
42 | 43 | import Ouroboros.Consensus.Util.Condense |
43 | 44 | import Quiet (Quiet (..)) |
@@ -166,20 +167,29 @@ makePerasCfg _ = |
166 | 167 | { perasCfgWeightBoost = boostPerCert |
167 | 168 | } |
168 | 169 |
|
169 | | -class StandardHash blk => HasPerasCert cert blk where |
170 | | - getPerasCert :: cert blk -> PerasCert blk |
| 170 | +class StandardHash blk => HasPerasCert cert blk | cert -> blk where |
| 171 | + getPerasCert :: cert -> PerasCert blk |
171 | 172 |
|
172 | | -instance StandardHash blk => HasPerasCert PerasCert blk where |
| 173 | +getPerasCertRound :: HasPerasCert cert blk => cert -> PerasRoundNo |
| 174 | +getPerasCertRound = pcCertRound . getPerasCert |
| 175 | + |
| 176 | +getPerasCertBoostedBlock :: HasPerasCert cert blk => cert -> Point blk |
| 177 | +getPerasCertBoostedBlock = pcCertBoostedBlock . getPerasCert |
| 178 | + |
| 179 | +instance StandardHash blk => HasPerasCert (PerasCert blk) blk where |
173 | 180 | getPerasCert = id |
174 | 181 |
|
175 | | -instance StandardHash blk => HasPerasCert ValidatedPerasCert blk where |
| 182 | +instance StandardHash blk => HasPerasCert (ValidatedPerasCert blk) blk where |
176 | 183 | getPerasCert = vpcCert |
177 | 184 |
|
178 | | -getPerasCertRound :: HasPerasCert cert blk => cert blk -> PerasRoundNo |
179 | | -getPerasCertRound = pcCertRound . getPerasCert |
| 185 | +instance HasPerasCert cert blk => HasPerasCert (WithArrivalTime cert) blk where |
| 186 | + getPerasCert = getPerasCert . forgetArrivalTime |
180 | 187 |
|
181 | | -getPerasCertBoostedBlock :: HasPerasCert cert blk => cert blk -> Point blk |
182 | | -getPerasCertBoostedBlock = pcCertBoostedBlock . getPerasCert |
| 188 | +class HasPerasCertBoost cert blk | cert -> blk where |
| 189 | + getPerasCertBoost :: cert -> PerasWeight |
| 190 | + |
| 191 | +instance HasPerasCertBoost (ValidatedPerasCert blk) blk where |
| 192 | + getPerasCertBoost = vpcCertBoost |
183 | 193 |
|
184 | | -getPerasCertBoost :: ValidatedPerasCert blk -> PerasWeight |
185 | | -getPerasCertBoost = vpcCertBoost |
| 194 | +instance HasPerasCertBoost cert blk => HasPerasCertBoost (WithArrivalTime cert) blk where |
| 195 | + getPerasCertBoost = getPerasCertBoost . forgetArrivalTime |
0 commit comments