Advance usage features for general MerkleCRDT applications#337
Merged
Advance usage features for general MerkleCRDT applications#337
Conversation
hsanjuan
commented
Mar 4, 2026
hsanjuan
commented
Mar 4, 2026
hsanjuan
commented
Mar 4, 2026
hsanjuan
commented
Mar 4, 2026
hsanjuan
commented
Mar 4, 2026
hsanjuan
commented
Mar 4, 2026
Collaborator
Author
hsanjuan
left a comment
There was a problem hiding this comment.
Some smallish things I will be fixing now.
Comment on lines
+202
to
+206
| // sort.Slice(heads, func(i, j int) bool { | ||
| // ci := heads[i].Bytes() | ||
| // cj := heads[j].Bytes() | ||
| // return bytes.Compare(ci, cj) < 0 | ||
| // }) |
Contributor
There was a problem hiding this comment.
Any reasons to remove the sorting? If yes, remove fully.
This commit enables advanced usecases by opening access to previously internal operations and options. A MerkleCRDT-based Set is still the base but: * We can now use custom Deltas (interface added): this allows storing any custom information in the CRDT tree. * We can now manually create and submit deltas (to complement the above) * We can interact directly with the internal Set. This is possible via a new MerkleCRDT type, which wraps the Datastore type. The Datastore type and general library usage remains the same as before.
This introduces support for CRDT-DAG segmentation when using custom deltas. It works as follows: delta.GetDagName() returns a name for a dag segment. Each CRDT-head belongs to the DAG segment specified by its delta and any new head only references previous heads of the same DAG segment. The result is that we have separate dags, one per DagName, with all the nodes in them belonging to the same DagName. Deltas can still reference any keys etc. but this way we can create separate crdt-"histories" that run in parallel. Note that at any time, there will be at least as many heads as different DagNames, so having many DagNames will impact the size of broadcasts as they will include all the heads and new writes will not consolidate them into a single head.
MerkleCRDT.Publish() applies delta to DAG and returns the CID of the resulting root node. Additionally, IsProcessed(ctx, cid) is exported so that it is possible to check from the outside whether a cid has been traversed.
Set height to maxHeight + 1 of heads in that dag only.
This way the user also gets information about the height and DagName.
29e0247 to
1720fe9
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feat: allow advanced usage for general MerkleCRDT applicaions
This commit enables advanced usecases by opening access to previously internal operations and options. A MerkleCRDT-based Set is still the base but:
This is all is possible via a new MerkleCRDT type and custom deltas. The Datastore type and general library usage remains the same as before.