Optimize interfaces

This commit is contained in:
mcrakhman 2023-01-18 08:36:54 +01:00 committed by Mikhail Iudin
parent e12edef524
commit 4f27e8e48d
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
2 changed files with 6 additions and 11 deletions

View File

@ -2,21 +2,12 @@ package objecttree
import (
"errors"
"github.com/anytypeio/any-sync/commonspace/object/tree/treechangeproto"
)
var ErrLoadBeforeRoot = errors.New("can't load before root")
type HistoryTree interface {
RWLocker
Id() string
Root() *Change
Heads() []string
IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error
GetChange(string) (*Change, error)
Header() *treechangeproto.RawTreeChangeWithId
UnmarshalledHeader() *Change
ReadableObjectTree
}
type historyTree struct {

View File

@ -44,7 +44,7 @@ type RawChangesPayload struct {
type ChangeIterateFunc = func(change *Change) bool
type ChangeConvertFunc = func(decrypted []byte) (any, error)
type ObjectTree interface {
type ReadableObjectTree interface {
RWLocker
Id() string
@ -59,6 +59,10 @@ type ObjectTree interface {
DebugDump(parser DescriptionParser) (string, error)
IterateRoot(convert ChangeConvertFunc, iterate ChangeIterateFunc) error
IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error
}
type ObjectTree interface {
ReadableObjectTree
SnapshotPath() []string
ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*treechangeproto.RawTreeChangeWithId, error)