Skip to content

Commit

Permalink
coreapi: implement Object.Diff
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Łukasz Magiera <magik6k@gmail.com>


This commit was moved from ipfs/interface-go-ipfs-core@00f6430
  • Loading branch information
magik6k committed Aug 1, 2018
1 parent 8fa8a1e commit 83c279f
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions coreiface/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,39 @@ type ObjectStat struct {
CumulativeSize int
}


const (
// DiffAdd is a Type of ObjectChange where a link was added to the graph
DiffAdd = iota

// DiffRemove is a Type of ObjectChange where a link was removed from the graph
DiffRemove

// DiffMod is a Type of ObjectChange where a link was changed in the graph
DiffMod
)

// ObjectChange represents a change ia a graph
// TODO: do we want this to be an interface?
type ObjectChange struct {
// Type of the change, either:
// * DiffAdd - Added a link
// * DiffRemove - Removed a link
// * DiffMod - Modified a link
Type int

// Path to the changed link
Path string

// Before holds the link path before the change. Note that when a link is
// added, this will be nil.
Before Path

// After holds the link path after the change. Note that when a link is
// removed, this will be nil.
After Path
}

// ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
// for manipulating MerkleDAG data structures.
type ObjectAPI interface {
Expand Down Expand Up @@ -65,4 +98,8 @@ type ObjectAPI interface {

// SetData sets the data contained in the node
SetData(context.Context, Path, io.Reader) (ResolvedPath, error)

// Diff returns a set of changes needed to transform the first object into the
// second.
Diff(context.Context, Path, Path) ([]ObjectChange, error)
}

0 comments on commit 83c279f

Please sign in to comment.