1
0
Fork 0
mirror of https://github.com/anyproto/any-sync.git synced 2025-06-08 14:07:02 +09:00

Expose header in history

This commit is contained in:
mcrakhman 2023-01-18 08:24:33 +01:00 committed by Mikhail Iudin
parent d15a02571f
commit e12edef524
No known key found for this signature in database
GPG key ID: FAAAA8BAABDFF1C0
3 changed files with 13 additions and 1 deletions

View file

@ -55,6 +55,7 @@ func NewChangeFromRoot(id string, ch *treechangeproto.RootChange, signature []by
IsSnapshot: true,
Identity: string(ch.Identity),
Signature: signature,
Data: []byte(ch.ChangeType),
}
}

View file

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

View file

@ -187,5 +187,11 @@ func buildHistoryTree(deps objectTreeDeps, params HistoryTreeParams) (ht History
if err != nil {
return nil, err
}
header, err := objTree.changeBuilder.ConvertFromRaw(objTree.rawRoot, false)
if err != nil {
return nil, err
}
objTree.root = header
return hTree, nil
}