Skip to content

Commit 27c8abe

Browse files
committed
TOSQUASH tidy up the queue maintenance
1 parent c529698 commit 27c8abe

File tree

3 files changed

+9
-17
lines changed

3 files changed

+9
-17
lines changed

ouroboros-consensus/src/unstable-consensus-testlib/Test/CsjModel.hs

+5-15
Original file line numberDiff line numberDiff line change
@@ -435,19 +435,7 @@ csjReactions env imm x pid = fmap fixup . \case
435435
Dynamo pid' clss y _mbQ <- toLazy $ dynamo x
436436
guard $ pid' == pid
437437
pure $ case f y of
438-
L.Nothing -> (
439-
CsjState {
440-
dynamo = Nothing
441-
,
442-
latestJump = latestJump x
443-
,
444-
nonDynamos = nonDynamos x
445-
,
446-
queue = queue x
447-
}
448-
,
449-
[(pid, Disengage)]
450-
)
438+
L.Nothing -> disengage
451439
L.Just y' -> (
452440
CsjState {
453441
dynamo = Just $ Dynamo pid clss y' Nothing
@@ -605,7 +593,7 @@ csjReactions env imm x pid = fmap fixup . \case
605593
(Jumped clss (truncCandidate y))
606594
(nonDynamos x)
607595
,
608-
queue = snocPerm pid (queue x)
596+
queue = queue x
609597
}
610598
,
611599
[(pid, Stop)]
@@ -731,7 +719,9 @@ backfillDynamo (x, msgs) =
731719
,
732720
nonDynamos = Map.delete pid (nonDynamos x)
733721
,
734-
queue = deletePerm pid (queue x)
722+
queue =
723+
-- This peer just got picked, so send them to the end.
724+
snocPerm pid $ deletePerm pid $ queue x
735725
}
736726
,
737727
maybe id (:) ((,) pid <$> mbMsg) msgs

ouroboros-consensus/src/unstable-consensus-testlib/Test/CsjModel/NonEmptySeq.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -93,4 +93,5 @@ leftmostInAscSeq f xs =
9393
LastFalseFirstTrue i _j -> L.Just i
9494
Uniformly False -> L.Just $ neLength ne - 1
9595
Uniformly True -> L.Nothing
96-
i <$ guard (q == f (neIndex ne i))
96+
guard $ q == f (neIndex ne i)
97+
pure i

ouroboros-consensus/src/unstable-consensus-testlib/Test/CsjModel/StateTypes.hs

+2-1
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,8 @@ data CsjState pid p a = CsjState {
173173
-- this set of peers as a last resort.
174174
latestJump :: !(Either (Map pid (CsjClientState p a)) (JumpRequest p a))
175175
,
176-
-- | The queue for becoming Dynamo
176+
-- | The queue for becoming Dynamo; it contains the @pid@ of every peer
177+
-- that is not disengaged
177178
--
178179
-- It would be safe for an implementation to break ties randomly instead of
179180
-- via this queue, but it's nice to not need randomness in the

0 commit comments

Comments
 (0)