WIP work on document structure
This commit is contained in:
parent
102b33c3dc
commit
3395f35b59
58
data/document.go
Normal file
58
data/document.go
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb"
|
||||||
|
"github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels"
|
||||||
|
)
|
||||||
|
|
||||||
|
type AccountData struct {
|
||||||
|
Identity string
|
||||||
|
EncKey threadmodels.EncryptionPrivKey
|
||||||
|
}
|
||||||
|
|
||||||
|
type Document struct {
|
||||||
|
thread threadmodels.Thread
|
||||||
|
stateProvider InitialStateProvider
|
||||||
|
accountData AccountData
|
||||||
|
decoder threadmodels.SigningPubKeyDecoder
|
||||||
|
aclTree *Tree
|
||||||
|
fullTree *Tree
|
||||||
|
aclTreeBuilder *ACLTreeBuilder
|
||||||
|
aclStateBuilder *ACLStateBuilder
|
||||||
|
}
|
||||||
|
|
||||||
|
type UpdateResult int
|
||||||
|
|
||||||
|
const (
|
||||||
|
UpdateResultAppend = iota
|
||||||
|
UpdateResultRebuild
|
||||||
|
UpdateResultExists
|
||||||
|
UpdateResultNoAction
|
||||||
|
)
|
||||||
|
|
||||||
|
func NewDocument(
|
||||||
|
thread threadmodels.Thread,
|
||||||
|
stateProvider InitialStateProvider,
|
||||||
|
accountData AccountData) *Document {
|
||||||
|
return &Document{
|
||||||
|
thread: thread,
|
||||||
|
stateProvider: stateProvider,
|
||||||
|
accountData: accountData,
|
||||||
|
decoder: threadmodels.NewEd25519Decoder(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Document) Update(changes []*pb.ACLChange) (DocumentState, UpdateResult, error) {
|
||||||
|
return nil, 0, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Document) Build() (DocumentState, error) {
|
||||||
|
treeBuilder := NewTreeBuilder(d.thread, threadmodels.NewEd25519Decoder())
|
||||||
|
|
||||||
|
return treeBuilder.Build(fromStart)
|
||||||
|
return nil, nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func (d *Document) State() DocumentState {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
32
data/documentcontext.go
Normal file
32
data/documentcontext.go
Normal file
@ -0,0 +1,32 @@
|
|||||||
|
package data
|
||||||
|
|
||||||
|
import "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels"
|
||||||
|
|
||||||
|
type documentContext struct {
|
||||||
|
aclTree *Tree
|
||||||
|
fullTree *Tree
|
||||||
|
identity string
|
||||||
|
encryptionKey threadmodels.EncryptionPrivKey
|
||||||
|
decoder threadmodels.SigningPubKeyDecoder
|
||||||
|
aclState *ACLState
|
||||||
|
docState DocumentState
|
||||||
|
changeCache map[string]*Change
|
||||||
|
identityKeys map[string]threadmodels.SigningPubKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func newDocumentContext(
|
||||||
|
identity string,
|
||||||
|
encryptionKey threadmodels.EncryptionPrivKey,
|
||||||
|
decoder threadmodels.SigningPubKeyDecoder) *documentContext {
|
||||||
|
return &documentContext{
|
||||||
|
aclTree: &Tree{},
|
||||||
|
fullTree: &Tree{},
|
||||||
|
identity: identity,
|
||||||
|
encryptionKey: encryptionKey,
|
||||||
|
decoder: decoder,
|
||||||
|
aclState: nil,
|
||||||
|
docState: nil,
|
||||||
|
changeCache: make(map[string]*Change),
|
||||||
|
identityKeys: make(map[string]threadmodels.SigningPubKey),
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -2,6 +2,8 @@ syntax = "proto3";
|
|||||||
package anytype;
|
package anytype;
|
||||||
option go_package = "pb";
|
option go_package = "pb";
|
||||||
|
|
||||||
|
// TODO: move to separate package
|
||||||
|
|
||||||
message PlainTextChange {
|
message PlainTextChange {
|
||||||
message Content {
|
message Content {
|
||||||
oneof value {
|
oneof value {
|
||||||
|
|||||||
@ -8,8 +8,9 @@ import (
|
|||||||
type Thread interface {
|
type Thread interface {
|
||||||
ID() string
|
ID() string
|
||||||
Heads() []string
|
Heads() []string
|
||||||
// TODO: add ACL heads
|
|
||||||
GetChange(ctx context.Context, recordID string) (*RawChange, error)
|
GetChange(ctx context.Context, recordID string) (*RawChange, error)
|
||||||
|
//SetHeads(heads []string)
|
||||||
|
//AddChanges(*pb.ACLChange)
|
||||||
PushChange(payload proto.Marshaler) (id string, err error)
|
PushChange(payload proto.Marshaler) (id string, err error)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user