Commit 14f3d3ca authored by Lucas Molas's avatar Lucas Molas

dag: diff: check CIDs in base case when comparing nodes

Fixes #4591.

License: MIT
Signed-off-by: default avatarLucas Molas <schomatis@gmail.com>
parent 4e36c0d5
......@@ -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'
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 a.Cid().Equals(b.Cid()) {
return []*Change{}, nil
}
return []*Change{
&Change{
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