From 14f3d3ca174d995612f70a933234fc1159c6f9ce Mon Sep 17 00:00:00 2001 From: Lucas Molas Date: Mon, 5 Mar 2018 12:00:34 -0300 Subject: [PATCH] dag: diff: check CIDs in base case when comparing nodes Fixes #4591. License: MIT Signed-off-by: Lucas Molas --- utils/diff.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/utils/diff.go b/utils/diff.go index 5af348d53940..4ba0f48c5df4 100644 --- a/utils/diff.go +++ b/utils/diff.go @@ -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,