Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
dms3
interface-go-dms3-core
Commits
00f6430f
Commit
00f6430f
authored
Feb 02, 2018
by
Łukasz Magiera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
coreapi: implement Object.Diff
License: MIT Signed-off-by:
Łukasz Magiera
<
magik6k@gmail.com
>
parent
ca13e9b2
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
0 deletions
+37
-0
object.go
object.go
+37
-0
No files found.
object.go
View file @
00f6430f
...
...
@@ -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
{
...
...
@@ -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
)
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment