From b8460b1a84eeed0cd3c06e2af408a9838a47ccc1 Mon Sep 17 00:00:00 2001 From: Sebastian Nagel Date: Wed, 30 Nov 2022 10:35:32 +0100 Subject: [PATCH] Add an Ord ChainPoint instance This is helpful to compare chain points by slot numbers. --- cardano-api/src/Cardano/Api/Block.hs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cardano-api/src/Cardano/Api/Block.hs b/cardano-api/src/Cardano/Api/Block.hs index 8f89304182a..29fec61bbba 100644 --- a/cardano-api/src/Cardano/Api/Block.hs +++ b/cardano-api/src/Cardano/Api/Block.hs @@ -341,6 +341,11 @@ data ChainPoint = ChainPointAtGenesis | ChainPoint !SlotNo !(Hash BlockHeader) deriving (Eq, Show) +instance Ord ChainPoint where + compare ChainPointAtGenesis ChainPointAtGenesis = EQ + compare ChainPointAtGenesis _ = LT + compare _ ChainPointAtGenesis = GT + compare (ChainPoint sn _) (ChainPoint sn' _) = compare sn sn' toConsensusPointInMode :: ConsensusMode mode -> ChainPoint