Skip to content

Commit 4d416ff

Browse files
authored
Merge pull request #4685 from input-output-hk/ch1bo/cardano-api-chain-point-ord-instance
[cardano-api] Add an Ord ChainPoint instance
2 parents fe5508a + b8460b1 commit 4d416ff

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Diff for: cardano-api/src/Cardano/Api/Block.hs

+5
Original file line numberDiff line numberDiff line change
@@ -341,6 +341,11 @@ data ChainPoint = ChainPointAtGenesis
341341
| ChainPoint !SlotNo !(Hash BlockHeader)
342342
deriving (Eq, Show)
343343

344+
instance Ord ChainPoint where
345+
compare ChainPointAtGenesis ChainPointAtGenesis = EQ
346+
compare ChainPointAtGenesis _ = LT
347+
compare _ ChainPointAtGenesis = GT
348+
compare (ChainPoint sn _) (ChainPoint sn' _) = compare sn sn'
344349

345350
toConsensusPointInMode :: ConsensusMode mode
346351
-> ChainPoint

0 commit comments

Comments
 (0)