-
Notifications
You must be signed in to change notification settings - Fork 175
Refactor getAllDescendants to use iterative worklist #5564
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -474,13 +474,15 @@ proposalsRemoveWithDescendants gais ps@(Proposals omap _roots graph) = | |
| getAllDescendants gai = | ||
| case OMap.lookup gai omap of | ||
| Nothing -> assert False mempty | ||
| Just gas -> withGovActionParent gas mempty $ \govRelationL _ -> | ||
| let go acc gpi = | ||
| case Map.lookup gpi $ graph ^. govRelationL . pGraphNodesL of | ||
| Nothing -> assert False acc | ||
| Just (PEdges _parent children) -> | ||
| F.foldl' go (Set.map unGovPurposeId children <> acc) children | ||
| in go mempty | ||
| Just gas -> withGovActionParent gas mempty $ \govRelationL _ selfId -> | ||
| let loop !acc [] = acc | ||
| loop !acc (curr : rest) = | ||
| case Map.lookup curr $ graph ^. govRelationL . pGraphNodesL of | ||
| Nothing -> loop acc rest | ||
| Just (PEdges _ children) -> | ||
| let newChildren = Set.map unGovPurposeId children | ||
| in loop (newChildren <> acc) (Set.toList children ++ rest) | ||
| in loop mempty [selfId] | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does adding the
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be nice to have a property test that tests that the new approach matches the semantics of the old one. It will serve as a good regression tests going into the future as well. |
||
|
|
||
| -- | For use in the @`EPOCH`@ rule. Apply the result of | ||
| -- @`extractDRepPulsingState`@ to the @`Proposals`@ forest, so that: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This diverges from the original implementation which does
assert False.