Skip to content

Commit 6f9c71b

Browse files
committed
Generalize compareAnchoredFragments.
1 parent 931ce06 commit 6f9c71b

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

ouroboros-consensus/src/ouroboros-consensus/Ouroboros/Consensus/Util/AnchoredFragment.hs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,15 +80,18 @@ forksAtMostKBlocks k ours theirs = case ours `AF.intersect` theirs of
8080
-- these fragments intersect with our current chain, they must by transitivity
8181
-- also intersect each other.
8282
compareAnchoredFragments ::
83-
forall blk t.
83+
forall blk t t'.
8484
( BlockSupportsProtocol blk
8585
, HasCallStack
8686
, GetHeader (t blk) blk
8787
, HasHeader (t blk)
88+
, GetHeader (t' blk) blk
89+
, HasHeader (t' blk)
90+
, HeaderHash (t blk) ~ HeaderHash (t' blk)
8891
)
8992
=> BlockConfig blk
9093
-> AnchoredFragment (t blk)
91-
-> AnchoredFragment (t blk)
94+
-> AnchoredFragment (t' blk)
9295
-> Ordering
9396
compareAnchoredFragments cfg frag1 frag2 =
9497
assertWithMsg (precondition frag1 frag2) $
@@ -104,12 +107,12 @@ compareAnchoredFragments cfg frag1 frag2 =
104107
-- fragments represent the same chain and are equally preferable. If
105108
-- not, the second chain is a strict extension of the first and is
106109
-- therefore strictly preferable.
107-
if blockPoint tip' == AF.anchorToPoint anchor
110+
if blockPoint tip' == AF.castPoint (AF.anchorToPoint anchor)
108111
then EQ
109112
else LT
110113
(_ :> tip, Empty anchor') ->
111114
-- This case is symmetric to the previous
112-
if blockPoint tip == AF.anchorToPoint anchor'
115+
if blockPoint tip == AF.castPoint (AF.anchorToPoint anchor')
113116
then EQ
114117
else GT
115118
(_ :> tip, _ :> tip') ->

0 commit comments

Comments
 (0)