Commit 00f6430f authored by Łukasz Magiera's avatar Łukasz Magiera

coreapi: implement Object.Diff

License: MIT
Signed-off-by: default avatarŁukasz Magiera <magik6k@gmail.com>
parent ca13e9b2
...@@ -31,6 +31,39 @@ type ObjectStat struct { ...@@ -31,6 +31,39 @@ type ObjectStat struct {
CumulativeSize int 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 // ObjectAPI specifies the interface to MerkleDAG and contains useful utilities
// for manipulating MerkleDAG data structures. // for manipulating MerkleDAG data structures.
type ObjectAPI interface { type ObjectAPI interface {
...@@ -65,4 +98,8 @@ type ObjectAPI interface { ...@@ -65,4 +98,8 @@ type ObjectAPI interface {
// SetData sets the data contained in the node // SetData sets the data contained in the node
SetData(context.Context, Path, io.Reader) (ResolvedPath, error) 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)
} }
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