Skip to content

Commit

Permalink
fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
fraser-iohk committed Nov 28, 2024
1 parent e4b4f4b commit 3c31dfd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ module Ouroboros.Consensus.HardFork.Combinator.Embed.Nary (

import Data.Bifunctor (first)
import Data.Coerce (Coercible, coerce)
import Data.SOP (Compose)
import Data.SOP.BasicFunctors
import Data.SOP.Counting (Exactly (..))
import Data.SOP.Dict (Dict (..))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import Codec.CBOR.Encoding (Encoding)
import qualified Codec.CBOR.Encoding as Enc
import qualified Codec.Serialise as Serialise
import Control.Exception (throw)
import Data.ByteString.Short (ShortByteString)
import Data.Proxy
import Data.SOP.BasicFunctors
import Data.SOP.Constraint
Expand All @@ -39,15 +38,14 @@ import Ouroboros.Consensus.HardFork.Combinator.Mempool
import Ouroboros.Consensus.HardFork.Combinator.Serialisation.Common
import Ouroboros.Consensus.HardFork.Combinator.Serialisation.SerialiseDisk ()
import Ouroboros.Consensus.HardFork.History (EraParamsFormat (..))
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTxId,
toRawTxIdHash)
import Ouroboros.Consensus.Ledger.SupportsMempool (GenTxId)
import Ouroboros.Consensus.Node.NetworkProtocolVersion
import Ouroboros.Consensus.Node.Run
import Ouroboros.Consensus.Node.Serialisation
import Ouroboros.Consensus.TypeFamilyWrappers
import Ouroboros.Consensus.Util ((.:))
import Ouroboros.Network.Block (Serialised, unwrapCBORinCBOR,
wrapCBORinCBOR)
import Data.ByteString.Short (ShortByteString)

instance SerialiseHFC xs => SerialiseNodeToClientConstraints (HardForkBlock xs)

Expand Down Expand Up @@ -172,7 +170,7 @@ instance SerialiseHFC xs
-- need to handle the cases where 'ShortByteString's are serialised with
-- an era tag ('encodeNS').

encodeNodeToClient cc v (HardForkGenTxId (OneEraGenTxId txid)) =
encodeNodeToClient _cc v (HardForkGenTxId (OneEraGenTxId txid)) =
case v of
HardForkNodeToClientEnabled hfv _ | hfv >= HardForkSpecificNodeToClientVersion4 ->
Serialise.encode txid
Expand All @@ -182,31 +180,13 @@ instance SerialiseHFC xs
encodeNS (hpure $ Fn $ K . Serialise.encode . unK) blessedGenTxId
HardForkNodeToClientDisabled _ ->
Serialise.encode txid
decodeNodeToClient cc v =
decodeNodeToClient _cc v =
fmap (HardForkGenTxId . OneEraGenTxId) $
case v of
HardForkNodeToClientEnabled hfc vs
HardForkNodeToClientEnabled hfc _
| hfc >= HardForkSpecificNodeToClientVersion4 -> do
Serialise.decode
-- let aux :: forall s blk . SerialiseConstraintsHFC blk
-- => CodecConfig blk
-- -> EraNodeToClientVersion blk
-- -> K () blk
-- -> (Decoder s :.: WrapGenTxId) blk
-- aux ecc vv _ = Comp $ case vv of
-- EraNodeToClientEnabled bv -> do
-- decodeNodeToClient ecc bv
-- EraNodeToClientDisabled ->
-- -- Is this sensible? What should the behaviour be when the
-- -- blessed GenTxId era is disabled by EraNodeToClientDisabled?
-- fail $ show $ disabledEraException (Proxy @blk)
-- htraverse' unComp $
-- hcliftA3 pSHFC
-- aux
-- (getPerEraCodecConfig (hardForkCodecConfigPerEra cc))
-- vs
-- blessedGenTxIdEra
HardForkNodeToClientEnabled _ _ ->do
HardForkNodeToClientEnabled _ _ -> do
let eraDecoders :: NP (Decoder s :.: K ShortByteString) xs
eraDecoders = hpure $ Comp $ K <$> Serialise.decode
hcollapse <$> decodeNS eraDecoders
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,23 +147,20 @@ instance SerialiseHFC xs
-- need to handle the cases where 'ShortByteString's are serialised with
-- an era tag ('encodeNS').

encodeNodeToNode cc v (HardForkGenTxId (OneEraGenTxId txid)) = do
encodeNodeToNode _cc v (HardForkGenTxId (OneEraGenTxId txid)) = do
case v of
HardForkNodeToNodeEnabled hfv _ | hfv >= HardForkSpecificNodeToNodeVersion2 ->
Serialise.encode txid
HardForkNodeToNodeEnabled _ vs -> do

HardForkNodeToNodeEnabled _ _ -> do
let blessedGenTxId :: NS (K ShortByteString) xs
blessedGenTxId = hmap (pure $ K txid) blessedGenTxIdEra
case blessedGenTxId of
Z i -> Serialise.encode $ unK i
S x -> encodeNS (hpure $ Fn $ K . Serialise.encode . unK) blessedGenTxId
encodeNS (hpure $ Fn $ K . Serialise.encode . unK) blessedGenTxId
HardForkNodeToNodeDisabled _ ->
Serialise.encode txid
decodeNodeToNode cc v =
decodeNodeToNode _cc v =
fmap (HardForkGenTxId . OneEraGenTxId) $
case v of
HardForkNodeToNodeEnabled hfv vs | hfv >= HardForkSpecificNodeToNodeVersion2 ->
HardForkNodeToNodeEnabled hfv _ | hfv >= HardForkSpecificNodeToNodeVersion2 ->
Serialise.decode
HardForkNodeToNodeEnabled _ _ -> do
let eraDecoders :: NP (Decoder s :.: K ShortByteString) xs
Expand Down

0 comments on commit 3c31dfd

Please sign in to comment.