Skip to content

Commit

Permalink
Merge pull request ipfs#4767 from schomatis/fix/dag/diff
Browse files Browse the repository at this point in the history
dag: diff: check CIDs in base case when comparing nodes
  • Loading branch information
whyrusleeping authored Mar 23, 2018
2 parents c22b905 + 14f3d3c commit 0ffc583
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions utils/diff.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 0ffc583

Please sign in to comment.