Skip to content

Commit

Permalink
dag: diff: check CIDs in base case when comparing nodes
Browse files Browse the repository at this point in the history
Fixes ipfs#4591.

License: MIT
Signed-off-by: Lucas Molas <[email protected]>
  • Loading branch information
schomatis committed Mar 5, 2018
1 parent 4e36c0d commit 14f3d3c
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 14f3d3c

Please sign in to comment.