-
Notifications
You must be signed in to change notification settings - Fork 5
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
packages/gossiplog
- implement isAncestor using branch index
#304
Conversation
…r clock or branch than the ancestor
…rjwebb/implement-is-ancestor-using-branch-table
so i tested the "branch merge" based implementation of isAncestor with the existing ancestor index. the samples aren't random - we just call isAncestor for a message with i and i + 1 or 10 or 100 etc, for i from 0 to 99 what we can see here is that the existing AncestorIndex implementation (which uses the clever logarithmic tree data structure that @joeltg thought of) is much much faster and has sub-linear time complexity. with branch merge based isAncestor implementation: with the existing AncestorIndex: |
We're going to keep the existing ancestor index as it is faster when dealing with large causal log trees. |
This PR replaces the existing implementation of
isAncestor
inAbstractGossipLog
with one that uses the new$branch_merges
table andbranch
field in the$messages
table. This lets us determine if a message is an ancestor of another message without looking at every single message in turn - it instead considers each branch. This should be faster for situations when we have long "chains" of messages.To do:
isAncestor
getAncestors
functionAncestorIndex
indexAncestors
constructor option fromAbstractGossipLog
ModelsInit
toModelSchema
indexHistory
settingHow has this been tested?
@canvas-js/test-network
: (optional)Does this contain any breaking changes to external interfaces?