Commit 0ffc5834 authored by Whyrusleeping's avatar Whyrusleeping Committed by GitHub

Merge pull request #4767 from schomatis/fix/dag/diff

dag: diff: check CIDs in base case when comparing nodes
parents c22b905e 14f3d3ca
...@@ -95,7 +95,12 @@ func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs ...@@ -95,7 +95,12 @@ func ApplyChange(ctx context.Context, ds ipld.DAGService, nd *dag.ProtoNode, cs
// Diff returns a set of changes that transform node 'a' into node 'b' // Diff returns a set of changes that transform node 'a' into node 'b'
func Diff(ctx context.Context, ds ipld.DAGService, a, b ipld.Node) ([]*Change, error) { func Diff(ctx context.Context, ds ipld.DAGService, a, b ipld.Node) ([]*Change, error) {
// Base case where both nodes are leaves, just compare
// their CIDs.
if len(a.Links()) == 0 && len(b.Links()) == 0 { if len(a.Links()) == 0 && len(b.Links()) == 0 {
if a.Cid().Equals(b.Cid()) {
return []*Change{}, nil
}
return []*Change{ return []*Change{
&Change{ &Change{
Type: Mod, Type: Mod,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment