mirror of
https://github.com/anyproto/any-sync.git
synced 2025-06-08 05:57:03 +09:00
Create space with settings
This commit is contained in:
parent
5d3e79e506
commit
bd3aff19e7
14 changed files with 621 additions and 256 deletions
|
@ -99,10 +99,5 @@ func (c *treeCache) GetDocument(ctx context.Context, spaceId, id string) (doc te
|
|||
}
|
||||
|
||||
func (c *treeCache) GetTree(ctx context.Context, spaceId, id string) (tr tree.ObjectTree, err error) {
|
||||
doc, err := c.GetDocument(ctx, spaceId, id)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
tr = doc.Tree()
|
||||
return
|
||||
return c.GetDocument(ctx, spaceId, id)
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ import (
|
|||
)
|
||||
|
||||
type TextDocument interface {
|
||||
Tree() tree.ObjectTree
|
||||
tree.ObjectTree
|
||||
AddText(text string) error
|
||||
Text() (string, error)
|
||||
TreeDump() string
|
||||
|
@ -19,7 +19,7 @@ type TextDocument interface {
|
|||
}
|
||||
|
||||
type textDocument struct {
|
||||
objTree tree.ObjectTree
|
||||
tree.ObjectTree
|
||||
account account.Service
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ func CreateTextDocument(
|
|||
}
|
||||
|
||||
return &textDocument{
|
||||
objTree: t,
|
||||
ObjectTree: t,
|
||||
account: account,
|
||||
}, nil
|
||||
}
|
||||
|
@ -50,15 +50,11 @@ func NewTextDocument(ctx context.Context, space commonspace.Space, id string, li
|
|||
return
|
||||
}
|
||||
return &textDocument{
|
||||
objTree: t,
|
||||
ObjectTree: t,
|
||||
account: account,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (t *textDocument) Tree() tree.ObjectTree {
|
||||
return t.objTree
|
||||
}
|
||||
|
||||
func (t *textDocument) AddText(text string) (err error) {
|
||||
content := &testchanges.TextContent_TextAppend{
|
||||
TextAppend: &testchanges.TextAppend{Text: text},
|
||||
|
@ -73,9 +69,9 @@ func (t *textDocument) AddText(text string) (err error) {
|
|||
if err != nil {
|
||||
return
|
||||
}
|
||||
t.objTree.Lock()
|
||||
defer t.objTree.Unlock()
|
||||
_, err = t.objTree.AddContent(context.Background(), tree.SignableChangeContent{
|
||||
t.Lock()
|
||||
defer t.Unlock()
|
||||
_, err = t.AddContent(context.Background(), tree.SignableChangeContent{
|
||||
Data: res,
|
||||
Key: t.account.Account().SignKey,
|
||||
Identity: t.account.Account().Identity,
|
||||
|
@ -85,10 +81,10 @@ func (t *textDocument) AddText(text string) (err error) {
|
|||
}
|
||||
|
||||
func (t *textDocument) Text() (text string, err error) {
|
||||
t.objTree.RLock()
|
||||
defer t.objTree.RUnlock()
|
||||
t.RLock()
|
||||
defer t.RUnlock()
|
||||
|
||||
err = t.objTree.Iterate(
|
||||
err = t.Iterate(
|
||||
func(decrypted []byte) (any, error) {
|
||||
textChange := &testchanges.TextData{}
|
||||
err = proto.Unmarshal(decrypted, textChange)
|
||||
|
|
|
@ -61,12 +61,14 @@ func (t treeKeys) RawChangeKey(id string) []byte {
|
|||
type spaceKeys struct {
|
||||
headerKey []byte
|
||||
treePrefixKey []byte
|
||||
spaceSettingsIdKey []byte
|
||||
}
|
||||
|
||||
func newSpaceKeys(spaceId string) spaceKeys {
|
||||
return spaceKeys{
|
||||
headerKey: storage.JoinStringsToBytes("space", "header", spaceId),
|
||||
treePrefixKey: storage.JoinStringsToBytes("space", spaceId, "t", "rootId"),
|
||||
spaceSettingsIdKey: storage.JoinStringsToBytes("space", spaceId, "spaceSettingsId"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +80,10 @@ func (s spaceKeys) TreeRootPrefix() []byte {
|
|||
return s.treePrefixKey
|
||||
}
|
||||
|
||||
func (s spaceKeys) SpaceSettingsId() []byte {
|
||||
return s.spaceSettingsIdKey
|
||||
}
|
||||
|
||||
type storageServiceKeys struct {
|
||||
spacePrefix []byte
|
||||
}
|
||||
|
|
|
@ -4,12 +4,14 @@ import (
|
|||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
spacestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
|
||||
storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
|
||||
"github.com/dgraph-io/badger/v3"
|
||||
"sync"
|
||||
)
|
||||
|
||||
type spaceStorage struct {
|
||||
spaceId string
|
||||
spaceSettingsId string
|
||||
objDb *badger.DB
|
||||
keys spaceKeys
|
||||
aclStorage storage.ListStorage
|
||||
|
@ -17,6 +19,8 @@ type spaceStorage struct {
|
|||
mx sync.Mutex
|
||||
}
|
||||
|
||||
var spaceValidationFunc = spacestorage.ValidateSpaceStorageCreatePayload
|
||||
|
||||
func newSpaceStorage(objDb *badger.DB, spaceId string) (store spacestorage.SpaceStorage, err error) {
|
||||
keys := newSpaceKeys(spaceId)
|
||||
err = objDb.View(func(txn *badger.Txn) error {
|
||||
|
@ -30,8 +34,13 @@ func newSpaceStorage(objDb *badger.DB, spaceId string) (store spacestorage.Space
|
|||
return err
|
||||
}
|
||||
|
||||
spaceSettingsId, err := getTxn(txn, keys.SpaceSettingsId())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
store = &spaceStorage{
|
||||
spaceId: spaceId,
|
||||
spaceSettingsId: string(spaceSettingsId),
|
||||
objDb: objDb,
|
||||
keys: keys,
|
||||
header: &spacesyncproto.RawSpaceHeaderWithId{
|
||||
|
@ -54,8 +63,32 @@ func createSpaceStorage(db *badger.DB, payload spacestorage.SpaceStorageCreatePa
|
|||
err = spacesyncproto.ErrSpaceExists
|
||||
return
|
||||
}
|
||||
err = spaceValidationFunc(payload)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
spaceStore := &spaceStorage{
|
||||
spaceId: payload.SpaceHeaderWithId.Id,
|
||||
objDb: db,
|
||||
keys: keys,
|
||||
spaceSettingsId: payload.SpaceSettingsWithId.Id,
|
||||
header: payload.SpaceHeaderWithId,
|
||||
}
|
||||
_, err = spaceStore.CreateTreeStorage(storage.TreeStorageCreatePayload{
|
||||
RootRawChange: payload.SpaceSettingsWithId,
|
||||
Changes: []*treechangeproto.RawTreeChangeWithId{payload.SpaceSettingsWithId},
|
||||
Heads: []string{payload.SpaceHeaderWithId.Id},
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
err = db.Update(func(txn *badger.Txn) error {
|
||||
aclStorage, err := createListStorage(payload.SpaceHeaderWithId.Id, db, txn, payload.RecWithId)
|
||||
err = txn.Set(keys.SpaceSettingsId(), []byte(payload.SpaceSettingsWithId.Id))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
aclStorage, err := createListStorage(payload.SpaceHeaderWithId.Id, db, txn, payload.AclWithId)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -65,15 +98,10 @@ func createSpaceStorage(db *badger.DB, payload spacestorage.SpaceStorageCreatePa
|
|||
return err
|
||||
}
|
||||
|
||||
store = &spaceStorage{
|
||||
spaceId: payload.SpaceHeaderWithId.Id,
|
||||
objDb: db,
|
||||
keys: keys,
|
||||
aclStorage: aclStorage,
|
||||
header: payload.SpaceHeaderWithId,
|
||||
}
|
||||
spaceStore.aclStorage = aclStorage
|
||||
return nil
|
||||
})
|
||||
store = spaceStore
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -81,6 +109,10 @@ func (s *spaceStorage) Id() string {
|
|||
return s.spaceId
|
||||
}
|
||||
|
||||
func (s *spaceStorage) SpaceSettingsId() string {
|
||||
return s.spaceSettingsId
|
||||
}
|
||||
|
||||
func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) {
|
||||
return newTreeStorage(s.objDb, s.spaceId, id)
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ func spaceTestPayload() spacestorage.SpaceStorageCreatePayload {
|
|||
Id: "aclRootId",
|
||||
}
|
||||
return spacestorage.SpaceStorageCreatePayload{
|
||||
RecWithId: aclRoot,
|
||||
AclWithId: aclRoot,
|
||||
SpaceHeaderWithId: header,
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,7 @@ func testSpace(t *testing.T, store spacestorage.SpaceStorage, payload spacestora
|
|||
|
||||
aclStorage, err := store.ACLStorage()
|
||||
require.NoError(t, err)
|
||||
testList(t, aclStorage, payload.RecWithId, payload.RecWithId.Id)
|
||||
testList(t, aclStorage, payload.AclWithId, payload.AclWithId.Id)
|
||||
}
|
||||
|
||||
func TestSpaceStorage_Create(t *testing.T) {
|
||||
|
|
28
common/commonspace/deletionservice/service.go
Normal file
28
common/commonspace/deletionservice/service.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package deletionservice
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/account"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/tree"
|
||||
)
|
||||
|
||||
type Service interface {
|
||||
}
|
||||
|
||||
const deletionChangeType = "space.deletionlist"
|
||||
|
||||
type service struct {
|
||||
account account.Service
|
||||
}
|
||||
|
||||
func New() Service {
|
||||
return nil
|
||||
}
|
||||
|
||||
func deriveDeletionTreePayload(account account.Service, spaceId string) tree.ObjectTreeCreatePayload {
|
||||
return tree.ObjectTreeCreatePayload{
|
||||
SignKey: account.Account().SignKey,
|
||||
ChangeType: deletionChangeType,
|
||||
SpaceId: spaceId,
|
||||
Identity: account.Account().Identity,
|
||||
}
|
||||
}
|
|
@ -84,7 +84,7 @@ func storagePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload st
|
|||
|
||||
// creating storage
|
||||
storagePayload = storage.SpaceStorageCreatePayload{
|
||||
RecWithId: rawWithId,
|
||||
AclWithId: rawWithId,
|
||||
SpaceHeaderWithId: rawHeaderWithId,
|
||||
}
|
||||
return
|
||||
|
@ -176,7 +176,7 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
|
|||
|
||||
// creating storage
|
||||
storagePayload = storage.SpaceStorageCreatePayload{
|
||||
RecWithId: rawWithId,
|
||||
AclWithId: rawWithId,
|
||||
SpaceHeaderWithId: rawHeaderWithId,
|
||||
}
|
||||
return
|
||||
|
|
|
@ -6,12 +6,15 @@ import (
|
|||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/treegetter"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/config"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
|
||||
)
|
||||
|
||||
const CName = "common.commonspace"
|
||||
|
@ -26,6 +29,7 @@ type Service interface {
|
|||
DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (string, error)
|
||||
CreateSpace(ctx context.Context, payload SpaceCreatePayload) (string, error)
|
||||
NewSpace(ctx context.Context, id string) (sp Space, err error)
|
||||
AddSpace(ctx context.Context, spaceDescription SpaceDescription) (err error)
|
||||
app.Component
|
||||
}
|
||||
|
||||
|
@ -78,12 +82,50 @@ func (s *service) DeriveSpace(ctx context.Context, payload SpaceDerivePayload) (
|
|||
return store.Id(), nil
|
||||
}
|
||||
|
||||
func (s *service) AddSpace(ctx context.Context, spaceDescription SpaceDescription) (err error) {
|
||||
_, err = s.storageProvider.SpaceStorage(spaceDescription.SpaceHeader.Id)
|
||||
if err == nil {
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
return
|
||||
}
|
||||
if err != storage.ErrSpaceStorageMissing {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
return
|
||||
}
|
||||
|
||||
payload := storage.SpaceStorageCreatePayload{
|
||||
AclWithId: &aclrecordproto.RawACLRecordWithId{
|
||||
Payload: spaceDescription.AclPayload,
|
||||
Id: spaceDescription.AclId,
|
||||
},
|
||||
SpaceHeaderWithId: spaceDescription.SpaceHeader,
|
||||
}
|
||||
st, err := s.storageProvider.CreateSpaceStorage(payload)
|
||||
if err != nil {
|
||||
err = spacesyncproto.ErrUnexpected
|
||||
if err == storage.ErrSpaceStorageExists {
|
||||
err = spacesyncproto.ErrSpaceExists
|
||||
}
|
||||
return
|
||||
}
|
||||
err = st.Close()
|
||||
return
|
||||
}
|
||||
|
||||
func (s *service) NewSpace(ctx context.Context, id string) (Space, error) {
|
||||
st, err := s.storageProvider.SpaceStorage(id)
|
||||
if err != nil {
|
||||
if err != spacesyncproto.ErrSpaceMissing {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
st, err = s.getSpaceStorageFromRemote(ctx, id)
|
||||
if err != nil {
|
||||
err = storage.ErrSpaceStorageMissing
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
|
||||
lastConfiguration := s.configurationService.GetLast()
|
||||
confConnector := nodeconf.NewConfConnector(lastConfiguration, s.pool)
|
||||
diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, confConnector, s.treeGetter, log)
|
||||
|
@ -99,3 +141,32 @@ func (s *service) NewSpace(ctx context.Context, id string) (Space, error) {
|
|||
}
|
||||
return sp, nil
|
||||
}
|
||||
|
||||
func (s *service) getSpaceStorageFromRemote(ctx context.Context, id string) (st storage.SpaceStorage, err error) {
|
||||
var p peer.Peer
|
||||
lastConfiguration := s.configurationService.GetLast()
|
||||
// for nodes we always get remote space only if we have id in the context
|
||||
if lastConfiguration.IsResponsible(id) {
|
||||
err = spacesyncproto.ErrSpaceMissing
|
||||
return
|
||||
}
|
||||
|
||||
p, err = s.pool.DialOneOf(ctx, lastConfiguration.NodeIds(id))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
cl := spacesyncproto.NewDRPCSpaceClient(p)
|
||||
res, err := cl.PullSpace(ctx, &spacesyncproto.PullSpaceRequest{Id: id})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
st, err = s.storageProvider.CreateSpaceStorage(storage.SpaceStorageCreatePayload{
|
||||
AclWithId: &aclrecordproto.RawACLRecordWithId{
|
||||
Payload: res.AclPayload,
|
||||
Id: res.AclPayloadId,
|
||||
},
|
||||
SpaceHeaderWithId: res.SpaceHeader,
|
||||
})
|
||||
return
|
||||
}
|
||||
|
|
|
@ -64,9 +64,7 @@ message ObjectSyncMessage {
|
|||
|
||||
// PushSpaceRequest is a request to add space on a node containing only one acl record
|
||||
message PushSpaceRequest {
|
||||
RawSpaceHeaderWithId spaceHeader = 1;
|
||||
bytes aclPayload = 2;
|
||||
string aclPayloadId = 3;
|
||||
SpacePayload payload = 1;
|
||||
}
|
||||
|
||||
// PushSpaceResponse is an empty response
|
||||
|
@ -79,9 +77,15 @@ message PullSpaceRequest {
|
|||
|
||||
// PullSpaceResponse is a response with header and acl root
|
||||
message PullSpaceResponse {
|
||||
SpacePayload payload = 1;
|
||||
}
|
||||
|
||||
message SpacePayload {
|
||||
RawSpaceHeaderWithId spaceHeader = 1;
|
||||
bytes aclPayload = 2;
|
||||
string aclPayloadId = 3;
|
||||
bytes spaceSettingsPayload = 4;
|
||||
string spaceSettingsPayloadId = 5;
|
||||
}
|
||||
|
||||
// SpaceHeader is a header for a space
|
||||
|
|
|
@ -397,9 +397,7 @@ func (m *ObjectSyncMessage) GetObjectId() string {
|
|||
|
||||
// PushSpaceRequest is a request to add space on a node containing only one acl record
|
||||
type PushSpaceRequest struct {
|
||||
SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,1,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
|
||||
AclPayload []byte `protobuf:"bytes,2,opt,name=aclPayload,proto3" json:"aclPayload,omitempty"`
|
||||
AclPayloadId string `protobuf:"bytes,3,opt,name=aclPayloadId,proto3" json:"aclPayloadId,omitempty"`
|
||||
Payload *SpacePayload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PushSpaceRequest) Reset() { *m = PushSpaceRequest{} }
|
||||
|
@ -435,27 +433,13 @@ func (m *PushSpaceRequest) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_PushSpaceRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *PushSpaceRequest) GetSpaceHeader() *RawSpaceHeaderWithId {
|
||||
func (m *PushSpaceRequest) GetPayload() *SpacePayload {
|
||||
if m != nil {
|
||||
return m.SpaceHeader
|
||||
return m.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PushSpaceRequest) GetAclPayload() []byte {
|
||||
if m != nil {
|
||||
return m.AclPayload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PushSpaceRequest) GetAclPayloadId() string {
|
||||
if m != nil {
|
||||
return m.AclPayloadId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// PushSpaceResponse is an empty response
|
||||
type PushSpaceResponse struct {
|
||||
}
|
||||
|
@ -540,9 +524,7 @@ func (m *PullSpaceRequest) GetId() string {
|
|||
|
||||
// PullSpaceResponse is a response with header and acl root
|
||||
type PullSpaceResponse struct {
|
||||
SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,1,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
|
||||
AclPayload []byte `protobuf:"bytes,2,opt,name=aclPayload,proto3" json:"aclPayload,omitempty"`
|
||||
AclPayloadId string `protobuf:"bytes,3,opt,name=aclPayloadId,proto3" json:"aclPayloadId,omitempty"`
|
||||
Payload *SpacePayload `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"`
|
||||
}
|
||||
|
||||
func (m *PullSpaceResponse) Reset() { *m = PullSpaceResponse{} }
|
||||
|
@ -578,27 +560,89 @@ func (m *PullSpaceResponse) XXX_DiscardUnknown() {
|
|||
|
||||
var xxx_messageInfo_PullSpaceResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *PullSpaceResponse) GetSpaceHeader() *RawSpaceHeaderWithId {
|
||||
func (m *PullSpaceResponse) GetPayload() *SpacePayload {
|
||||
if m != nil {
|
||||
return m.Payload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SpacePayload struct {
|
||||
SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,1,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
|
||||
AclPayload []byte `protobuf:"bytes,2,opt,name=aclPayload,proto3" json:"aclPayload,omitempty"`
|
||||
AclPayloadId string `protobuf:"bytes,3,opt,name=aclPayloadId,proto3" json:"aclPayloadId,omitempty"`
|
||||
SpaceSettingsPayload []byte `protobuf:"bytes,4,opt,name=spaceSettingsPayload,proto3" json:"spaceSettingsPayload,omitempty"`
|
||||
SpaceSettingsPayloadId string `protobuf:"bytes,5,opt,name=spaceSettingsPayloadId,proto3" json:"spaceSettingsPayloadId,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SpacePayload) Reset() { *m = SpacePayload{} }
|
||||
func (m *SpacePayload) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpacePayload) ProtoMessage() {}
|
||||
func (*SpacePayload) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{10}
|
||||
}
|
||||
func (m *SpacePayload) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SpacePayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SpacePayload.Marshal(b, m, deterministic)
|
||||
} else {
|
||||
b = b[:cap(b)]
|
||||
n, err := m.MarshalToSizedBuffer(b)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return b[:n], nil
|
||||
}
|
||||
}
|
||||
func (m *SpacePayload) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SpacePayload.Merge(m, src)
|
||||
}
|
||||
func (m *SpacePayload) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SpacePayload) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SpacePayload.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SpacePayload proto.InternalMessageInfo
|
||||
|
||||
func (m *SpacePayload) GetSpaceHeader() *RawSpaceHeaderWithId {
|
||||
if m != nil {
|
||||
return m.SpaceHeader
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PullSpaceResponse) GetAclPayload() []byte {
|
||||
func (m *SpacePayload) GetAclPayload() []byte {
|
||||
if m != nil {
|
||||
return m.AclPayload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *PullSpaceResponse) GetAclPayloadId() string {
|
||||
func (m *SpacePayload) GetAclPayloadId() string {
|
||||
if m != nil {
|
||||
return m.AclPayloadId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SpacePayload) GetSpaceSettingsPayload() []byte {
|
||||
if m != nil {
|
||||
return m.SpaceSettingsPayload
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (m *SpacePayload) GetSpaceSettingsPayloadId() string {
|
||||
if m != nil {
|
||||
return m.SpaceSettingsPayloadId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
// SpaceHeader is a header for a space
|
||||
type SpaceHeader struct {
|
||||
Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"`
|
||||
|
@ -612,7 +656,7 @@ func (m *SpaceHeader) Reset() { *m = SpaceHeader{} }
|
|||
func (m *SpaceHeader) String() string { return proto.CompactTextString(m) }
|
||||
func (*SpaceHeader) ProtoMessage() {}
|
||||
func (*SpaceHeader) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{10}
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{11}
|
||||
}
|
||||
func (m *SpaceHeader) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -685,7 +729,7 @@ func (m *RawSpaceHeader) Reset() { *m = RawSpaceHeader{} }
|
|||
func (m *RawSpaceHeader) String() string { return proto.CompactTextString(m) }
|
||||
func (*RawSpaceHeader) ProtoMessage() {}
|
||||
func (*RawSpaceHeader) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{11}
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{12}
|
||||
}
|
||||
func (m *RawSpaceHeader) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -737,7 +781,7 @@ func (m *RawSpaceHeaderWithId) Reset() { *m = RawSpaceHeaderWithId{} }
|
|||
func (m *RawSpaceHeaderWithId) String() string { return proto.CompactTextString(m) }
|
||||
func (*RawSpaceHeaderWithId) ProtoMessage() {}
|
||||
func (*RawSpaceHeaderWithId) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{12}
|
||||
return fileDescriptor_80e49f1f4ac27799, []int{13}
|
||||
}
|
||||
func (m *RawSpaceHeaderWithId) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
|
@ -792,6 +836,7 @@ func init() {
|
|||
proto.RegisterType((*PushSpaceResponse)(nil), "anySpace.PushSpaceResponse")
|
||||
proto.RegisterType((*PullSpaceRequest)(nil), "anySpace.PullSpaceRequest")
|
||||
proto.RegisterType((*PullSpaceResponse)(nil), "anySpace.PullSpaceResponse")
|
||||
proto.RegisterType((*SpacePayload)(nil), "anySpace.SpacePayload")
|
||||
proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader")
|
||||
proto.RegisterType((*RawSpaceHeader)(nil), "anySpace.RawSpaceHeader")
|
||||
proto.RegisterType((*RawSpaceHeaderWithId)(nil), "anySpace.RawSpaceHeaderWithId")
|
||||
|
@ -802,53 +847,56 @@ func init() {
|
|||
}
|
||||
|
||||
var fileDescriptor_80e49f1f4ac27799 = []byte{
|
||||
// 721 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xcc, 0x55, 0xcd, 0x6e, 0xd3, 0x4a,
|
||||
0x14, 0x8e, 0xdd, 0xb4, 0x4d, 0x4e, 0xd2, 0x34, 0x9d, 0xdb, 0xab, 0xeb, 0x1b, 0x90, 0x89, 0xbc,
|
||||
0x40, 0x11, 0x8b, 0x16, 0x02, 0xbb, 0x6e, 0xf8, 0x69, 0x2a, 0x22, 0x54, 0x5a, 0x4d, 0x40, 0x48,
|
||||
0x88, 0xcd, 0xd4, 0x9e, 0x26, 0x46, 0xfe, 0xc3, 0x33, 0x51, 0xeb, 0x05, 0xef, 0xc0, 0x12, 0x36,
|
||||
0x48, 0xbc, 0x0d, 0xcb, 0x2e, 0x59, 0xa2, 0xf6, 0x45, 0xd0, 0x9c, 0xd8, 0xb1, 0x9d, 0xa6, 0x5d,
|
||||
0xb3, 0x71, 0xe7, 0x7c, 0xe7, 0xef, 0x9b, 0x6f, 0xce, 0x69, 0xe0, 0x91, 0x1d, 0xfa, 0x7e, 0x18,
|
||||
0x88, 0x88, 0xd9, 0x7c, 0x17, 0xbf, 0x22, 0x09, 0xec, 0x28, 0x0e, 0x65, 0xb8, 0x8b, 0x5f, 0x91,
|
||||
0xa3, 0x3b, 0x08, 0x90, 0x1a, 0x0b, 0x92, 0x91, 0xc2, 0xac, 0x21, 0x6c, 0xbc, 0xe4, 0xcc, 0x19,
|
||||
0x25, 0x81, 0x4d, 0x59, 0x30, 0xe6, 0x84, 0x40, 0xf5, 0x34, 0x0e, 0x7d, 0x43, 0xeb, 0x6a, 0xbd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d3, 0x50,
|
||||
0x2d, 0x22, 0x2f, 0x19, 0x66, 0x77, 0xcd, 0x4c, 0xe5, 0x89, 0x58, 0xe2, 0x85, 0xcc, 0x41, 0x0d,
|
||||
0x9b, 0x34, 0x33, 0x49, 0x07, 0x6a, 0x21, 0xb6, 0x18, 0x3a, 0x46, 0x15, 0x93, 0xe6, 0xb6, 0xf5,
|
||||
0x55, 0x83, 0xf6, 0xf1, 0x54, 0x4c, 0x90, 0x64, 0x26, 0xd3, 0x53, 0x68, 0x60, 0x3f, 0xc5, 0x99,
|
||||
0xc7, 0x48, 0xa1, 0xd1, 0x37, 0xf3, 0xbb, 0x50, 0x76, 0x36, 0xca, 0xfd, 0xef, 0x5c, 0x39, 0x19,
|
||||
0x3a, 0xb4, 0x98, 0x42, 0x4c, 0x00, 0x66, 0x7b, 0xc7, 0x29, 0x1f, 0x1d, 0xf9, 0x14, 0x10, 0x62,
|
||||
0x41, 0x33, 0xb7, 0x86, 0x33, 0xc6, 0x75, 0x5a, 0xc2, 0xac, 0x7f, 0x60, 0xab, 0xc0, 0x6c, 0x26,
|
||||
0xb1, 0x65, 0x29, 0xba, 0x9e, 0x57, 0xa2, 0xbb, 0x30, 0x0c, 0xd6, 0x37, 0x4d, 0x65, 0xce, 0x83,
|
||||
0xd2, 0xc7, 0xf9, 0x3b, 0x2e, 0xf5, 0x43, 0x83, 0x46, 0xa1, 0x8d, 0x7a, 0x1b, 0xd7, 0xe1, 0x81,
|
||||
0x74, 0x65, 0x92, 0x2e, 0xd3, 0xdc, 0x26, 0x77, 0xa1, 0x2e, 0x5d, 0x9f, 0x0b, 0xc9, 0xfc, 0x08,
|
||||
0xdb, 0xad, 0xd0, 0x1c, 0x50, 0x5e, 0x24, 0xf7, 0x26, 0x89, 0x78, 0xda, 0x2a, 0x07, 0xc8, 0x7d,
|
||||
0x68, 0xa9, 0xc1, 0x70, 0x6d, 0x26, 0xdd, 0x30, 0x78, 0xc5, 0x13, 0x7c, 0xf9, 0x2a, 0x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0xb3, 0xa7, 0x3d,
|
||||
0xd4, 0x9e, 0x3f, 0xf9, 0x79, 0x69, 0x6a, 0x17, 0x97, 0xa6, 0xf6, 0xfb, 0xd2, 0xd4, 0xbe, 0x5c,
|
||||
0x99, 0x95, 0x8b, 0x2b, 0xb3, 0xf2, 0xeb, 0xca, 0xac, 0xbc, 0xef, 0xdc, 0xfc, 0xcb, 0x74, 0xb2,
|
||||
0x86, 0x7f, 0x1e, 0xff, 0x09, 0x00, 0x00, 0xff, 0xff, 0xf7, 0x95, 0x5b, 0xbc, 0xbe, 0x06, 0x00,
|
||||
0x00,
|
||||
// 770 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x55, 0xcd, 0x4e, 0x23, 0x47,
|
||||
0x10, 0xf6, 0x0c, 0x06, 0xec, 0xb2, 0x31, 0xa6, 0x43, 0xc8, 0xc4, 0x89, 0x26, 0xd6, 0x1c, 0x22,
|
||||
0x2b, 0x07, 0x20, 0x4e, 0x94, 0x0b, 0x97, 0xfc, 0x60, 0x14, 0x2b, 0x22, 0xa0, 0x76, 0xa2, 0x48,
|
||||
0x51, 0x2e, 0xcd, 0x4c, 0x63, 0x4f, 0x34, 0x7f, 0x3b, 0xdd, 0x16, 0xcc, 0x61, 0xa5, 0x7d, 0x84,
|
||||
0x7d, 0x82, 0x95, 0xf6, 0x6d, 0xf6, 0xc8, 0x71, 0x8f, 0x2b, 0x78, 0x91, 0x55, 0x97, 0xe7, 0xd7,
|
||||
0x0c, 0x48, 0x7b, 0x19, 0x4f, 0x7d, 0x55, 0xf5, 0x55, 0xd5, 0xd7, 0x5d, 0x63, 0xf8, 0xde, 0x0e,
|
||||
0x7d, 0x3f, 0x0c, 0x44, 0xc4, 0x6c, 0x7e, 0x84, 0x4f, 0x91, 0x04, 0x76, 0x14, 0x87, 0x32, 0x3c,
|
||||
0xc2, 0xa7, 0x28, 0xd0, 0x43, 0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
0x2b, 0x60, 0x12, 0xc7, 0x61, 0x7c, 0x71, 0x7d, 0x2d, 0xb8, 0xec, 0x3b, 0xe3, 0x37, 0x3a, 0x6c,
|
||||
0x62, 0x08, 0xf9, 0x05, 0x5a, 0xd9, 0xe2, 0x93, 0x2f, 0xeb, 0x3e, 0x06, 0xb8, 0x16, 0x83, 0x41,
|
||||
0xed, 0x77, 0x62, 0xb5, 0x0d, 0xa7, 0xd0, 0xce, 0x77, 0x8b, 0x94, 0x02, 0xd7, 0xd7, 0x76, 0xf0,
|
||||
0x55, 0xad, 0xaf, 0xcc, 0x92, 0x2e, 0x5a, 0x95, 0xa5, 0xba, 0xa1, 0x55, 0x96, 0xf5, 0xcd, 0x3c,
|
||||
0x83, 0xad, 0x99, 0x8c, 0x39, 0xf3, 0x49, 0x29, 0xec, 0xd1, 0xe7, 0x6b, 0xf0, 0x9c, 0x73, 0xa4,
|
||||
0x1d, 0x6b, 0xbf, 0xfe, 0xf8, 0xee, 0xde, 0xd4, 0xee, 0xee, 0x4d, 0xed, 0xc3, 0xbd, 0xa9, 0xbd,
|
||||
0x7e, 0x30, 0x1b, 0x77, 0x0f, 0x66, 0xe3, 0xfd, 0x83, 0xd9, 0xf8, 0x77, 0xf0, 0xf4, 0x5f, 0xde,
|
||||
0xd5, 0x16, 0xfe, 0xfc, 0xf0, 0x31, 0x00, 0x00, 0xff, 0xff, 0xaa, 0x60, 0x9b, 0x89, 0x17, 0x07,
|
||||
0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
|
||||
|
@ -1127,23 +1175,9 @@ func (m *PushSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.AclPayloadId) > 0 {
|
||||
i -= len(m.AclPayloadId)
|
||||
copy(dAtA[i:], m.AclPayloadId)
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.AclPayloadId)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.AclPayload) > 0 {
|
||||
i -= len(m.AclPayload)
|
||||
copy(dAtA[i:], m.AclPayload)
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.AclPayload)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if m.SpaceHeader != nil {
|
||||
if m.Payload != nil {
|
||||
{
|
||||
size, err := m.SpaceHeader.MarshalToSizedBuffer(dAtA[:i])
|
||||
size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
@ -1229,6 +1263,55 @@ func (m *PullSpaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
|||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if m.Payload != nil {
|
||||
{
|
||||
size, err := m.Payload.MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(size))
|
||||
}
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SpacePayload) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
n, err := m.MarshalToSizedBuffer(dAtA[:size])
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return dAtA[:n], nil
|
||||
}
|
||||
|
||||
func (m *SpacePayload) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SpacePayload) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SpaceSettingsPayloadId) > 0 {
|
||||
i -= len(m.SpaceSettingsPayloadId)
|
||||
copy(dAtA[i:], m.SpaceSettingsPayloadId)
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceSettingsPayloadId)))
|
||||
i--
|
||||
dAtA[i] = 0x2a
|
||||
}
|
||||
if len(m.SpaceSettingsPayload) > 0 {
|
||||
i -= len(m.SpaceSettingsPayload)
|
||||
copy(dAtA[i:], m.SpaceSettingsPayload)
|
||||
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceSettingsPayload)))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
if len(m.AclPayloadId) > 0 {
|
||||
i -= len(m.AclPayloadId)
|
||||
copy(dAtA[i:], m.AclPayloadId)
|
||||
|
@ -1519,16 +1602,8 @@ func (m *PushSpaceRequest) Size() (n int) {
|
|||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.SpaceHeader != nil {
|
||||
l = m.SpaceHeader.Size()
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
l = len(m.AclPayload)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
l = len(m.AclPayloadId)
|
||||
if l > 0 {
|
||||
if m.Payload != nil {
|
||||
l = m.Payload.Size()
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
return n
|
||||
|
@ -1557,6 +1632,19 @@ func (m *PullSpaceRequest) Size() (n int) {
|
|||
}
|
||||
|
||||
func (m *PullSpaceResponse) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
if m.Payload != nil {
|
||||
l = m.Payload.Size()
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SpacePayload) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
|
@ -1574,6 +1662,14 @@ func (m *PullSpaceResponse) Size() (n int) {
|
|||
if l > 0 {
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
l = len(m.SpaceSettingsPayload)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
l = len(m.SpaceSettingsPayloadId)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSpacesync(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
|
@ -2413,7 +2509,7 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
|
|||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", wireType)
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
|
@ -2440,79 +2536,13 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
|
|||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.SpaceHeader == nil {
|
||||
m.SpaceHeader = &RawSpaceHeaderWithId{}
|
||||
if m.Payload == nil {
|
||||
m.Payload = &SpacePayload{}
|
||||
}
|
||||
if err := m.SpaceHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AclPayload", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.AclPayload = append(m.AclPayload[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.AclPayload == nil {
|
||||
m.AclPayload = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field AclPayloadId", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.AclPayloadId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
||||
|
@ -2695,6 +2725,92 @@ func (m *PullSpaceResponse) Unmarshal(dAtA []byte) error {
|
|||
return fmt.Errorf("proto: PullSpaceResponse: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType)
|
||||
}
|
||||
var msglen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
if m.Payload == nil {
|
||||
m.Payload = &SpacePayload{}
|
||||
}
|
||||
if err := m.Payload.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SpacePayload) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: SpacePayload: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: SpacePayload: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", wireType)
|
||||
|
@ -2797,6 +2913,72 @@ func (m *PullSpaceResponse) Unmarshal(dAtA []byte) error {
|
|||
}
|
||||
m.AclPayloadId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SpaceSettingsPayload", wireType)
|
||||
}
|
||||
var byteLen int
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
byteLen |= int(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if byteLen < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
postIndex := iNdEx + byteLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.SpaceSettingsPayload = append(m.SpaceSettingsPayload[:0], dAtA[iNdEx:postIndex]...)
|
||||
if m.SpaceSettingsPayload == nil {
|
||||
m.SpaceSettingsPayload = []byte{}
|
||||
}
|
||||
iNdEx = postIndex
|
||||
case 5:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SpaceSettingsPayloadId", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSpacesync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSpacesync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.SpaceSettingsPayloadId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSpacesync(dAtA[iNdEx:])
|
||||
|
|
|
@ -7,6 +7,7 @@ import (
|
|||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/aclrecordproto"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
|
||||
)
|
||||
|
||||
const CName = "commonspace.storage"
|
||||
|
@ -17,6 +18,7 @@ var ErrSpaceStorageMissing = errors.New("space storage missing")
|
|||
type SpaceStorage interface {
|
||||
storage.Provider
|
||||
Id() string
|
||||
SpaceSettingsId() string
|
||||
ACLStorage() (storage.ListStorage, error)
|
||||
SpaceHeader() (*spacesyncproto.RawSpaceHeaderWithId, error)
|
||||
StoredIds() ([]string, error)
|
||||
|
@ -24,8 +26,9 @@ type SpaceStorage interface {
|
|||
}
|
||||
|
||||
type SpaceStorageCreatePayload struct {
|
||||
RecWithId *aclrecordproto.RawACLRecordWithId
|
||||
AclWithId *aclrecordproto.RawACLRecordWithId
|
||||
SpaceHeaderWithId *spacesyncproto.RawSpaceHeaderWithId
|
||||
SpaceSettingsWithId *treechangeproto.RawTreeChangeWithId
|
||||
}
|
||||
|
||||
type SpaceStorageProvider interface {
|
||||
|
@ -33,3 +36,8 @@ type SpaceStorageProvider interface {
|
|||
SpaceStorage(id string) (SpaceStorage, error)
|
||||
CreateSpaceStorage(payload SpaceStorageCreatePayload) (SpaceStorage, error)
|
||||
}
|
||||
|
||||
func ValidateSpaceStorageCreatePayload(payload SpaceStorageCreatePayload) (err error) {
|
||||
// TODO: add proper validation
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -51,7 +51,10 @@ func newSpaceKeys(spaceId string) spaceKeys {
|
|||
return spaceKeys{headerKey: storage.JoinStringsToBytes("s", spaceId)}
|
||||
}
|
||||
|
||||
var spaceIdKey = []byte("spaceId")
|
||||
var (
|
||||
spaceIdKey = []byte("spaceId")
|
||||
spaceSettingsIdKey = []byte("spaceSettingsId")
|
||||
)
|
||||
|
||||
func (s spaceKeys) SpaceIdKey() []byte {
|
||||
return spaceIdKey
|
||||
|
@ -61,7 +64,11 @@ func (s spaceKeys) HeaderKey() []byte {
|
|||
return s.headerKey
|
||||
}
|
||||
|
||||
func isRootIdKey(key string) bool {
|
||||
func (s spaceKeys) SpaceSettingsIdKey() []byte {
|
||||
return spaceSettingsIdKey
|
||||
}
|
||||
|
||||
func isTreeHeadsKey(key string) bool {
|
||||
return strings.HasPrefix(key, "t/") && strings.HasSuffix(key, "/heads")
|
||||
}
|
||||
|
||||
|
|
|
@ -5,21 +5,23 @@ import (
|
|||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/app/logger"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto"
|
||||
spacestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage"
|
||||
storage "github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/storage"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/common/pkg/acl/treechangeproto"
|
||||
"go.uber.org/zap"
|
||||
"path"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
var defPogrebOptions = &pogreb.Options{
|
||||
BackgroundCompactionInterval: time.Minute * 5,
|
||||
}
|
||||
|
||||
var log = logger.NewNamed("storage.spacestorage")
|
||||
var (
|
||||
defPogrebOptions = &pogreb.Options{BackgroundCompactionInterval: time.Minute * 5}
|
||||
log = logger.NewNamed("storage.spacestorage")
|
||||
spaceValidationFunc = spacestorage.ValidateSpaceStorageCreatePayload
|
||||
)
|
||||
|
||||
type spaceStorage struct {
|
||||
spaceId string
|
||||
spaceSettingsId string
|
||||
objDb *pogreb.DB
|
||||
keys spaceKeys
|
||||
aclStorage storage.ListStorage
|
||||
|
@ -61,6 +63,15 @@ func newSpaceStorage(rootPath string, spaceId string) (store spacestorage.SpaceS
|
|||
return
|
||||
}
|
||||
|
||||
spaceSettingsId, err := objDb.Get(keys.SpaceSettingsIdKey())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
if spaceSettingsId == nil {
|
||||
err = spacestorage.ErrSpaceStorageMissing
|
||||
return
|
||||
}
|
||||
|
||||
aclStorage, err := newListStorage(objDb)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -68,6 +79,7 @@ func newSpaceStorage(rootPath string, spaceId string) (store spacestorage.SpaceS
|
|||
|
||||
store = &spaceStorage{
|
||||
spaceId: spaceId,
|
||||
spaceSettingsId: string(spaceSettingsId),
|
||||
objDb: objDb,
|
||||
keys: keys,
|
||||
header: &spacesyncproto.RawSpaceHeaderWithId{
|
||||
|
@ -88,8 +100,8 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate
|
|||
}
|
||||
|
||||
defer func() {
|
||||
log.With(zap.String("id", payload.SpaceHeaderWithId.Id), zap.Error(err)).Warn("failed to create storage")
|
||||
if err != nil {
|
||||
log.With(zap.String("id", payload.SpaceHeaderWithId.Id), zap.Error(err)).Warn("failed to create storage")
|
||||
db.Close()
|
||||
}
|
||||
}()
|
||||
|
@ -103,8 +115,35 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate
|
|||
err = spacesyncproto.ErrSpaceExists
|
||||
return
|
||||
}
|
||||
err = spaceValidationFunc(payload)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
aclStorage, err := createListStorage(db, payload.RecWithId)
|
||||
aclStorage, err := createListStorage(db, payload.AclWithId)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
store = &spaceStorage{
|
||||
spaceId: payload.SpaceHeaderWithId.Id,
|
||||
objDb: db,
|
||||
keys: keys,
|
||||
aclStorage: aclStorage,
|
||||
spaceSettingsId: payload.SpaceSettingsWithId.Id,
|
||||
header: payload.SpaceHeaderWithId,
|
||||
}
|
||||
|
||||
_, err = store.CreateTreeStorage(storage.TreeStorageCreatePayload{
|
||||
RootRawChange: payload.SpaceSettingsWithId,
|
||||
Changes: []*treechangeproto.RawTreeChangeWithId{payload.SpaceSettingsWithId},
|
||||
Heads: []string{payload.SpaceHeaderWithId.Id},
|
||||
})
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
err = db.Put(keys.SpaceSettingsIdKey(), []byte(payload.SpaceSettingsWithId.Id))
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
@ -119,13 +158,6 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate
|
|||
return
|
||||
}
|
||||
|
||||
store = &spaceStorage{
|
||||
spaceId: payload.SpaceHeaderWithId.Id,
|
||||
objDb: db,
|
||||
keys: keys,
|
||||
aclStorage: aclStorage,
|
||||
header: payload.SpaceHeaderWithId,
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -133,6 +165,10 @@ func (s *spaceStorage) Id() string {
|
|||
return s.spaceId
|
||||
}
|
||||
|
||||
func (s *spaceStorage) SpaceSettingsId() string {
|
||||
return s.spaceSettingsId
|
||||
}
|
||||
|
||||
func (s *spaceStorage) TreeStorage(id string) (storage.TreeStorage, error) {
|
||||
return newTreeStorage(s.objDb, id)
|
||||
}
|
||||
|
@ -156,13 +192,13 @@ func (s *spaceStorage) SpaceHeader() (header *spacesyncproto.RawSpaceHeaderWithI
|
|||
func (s *spaceStorage) StoredIds() (ids []string, err error) {
|
||||
index := s.objDb.Items()
|
||||
|
||||
key, val, err := index.Next()
|
||||
key, _, err := index.Next()
|
||||
for err == nil {
|
||||
strKey := string(key)
|
||||
if isRootIdKey(strKey) {
|
||||
ids = append(ids, string(val))
|
||||
if isTreeHeadsKey(strKey) {
|
||||
ids = append(ids, getRootId(strKey))
|
||||
}
|
||||
key, val, err = index.Next()
|
||||
key, _, err = index.Next()
|
||||
}
|
||||
|
||||
if err != pogreb.ErrIterationDone {
|
||||
|
|
|
@ -20,7 +20,7 @@ func spaceTestPayload() spacestorage.SpaceStorageCreatePayload {
|
|||
Id: "aclRootId",
|
||||
}
|
||||
return spacestorage.SpaceStorageCreatePayload{
|
||||
RecWithId: aclRoot,
|
||||
AclWithId: aclRoot,
|
||||
SpaceHeaderWithId: header,
|
||||
}
|
||||
}
|
||||
|
@ -32,7 +32,7 @@ func testSpace(t *testing.T, store spacestorage.SpaceStorage, payload spacestora
|
|||
|
||||
aclStorage, err := store.ACLStorage()
|
||||
require.NoError(t, err)
|
||||
testList(t, aclStorage, payload.RecWithId, payload.RecWithId.Id)
|
||||
testList(t, aclStorage, payload.AclWithId, payload.AclWithId.Id)
|
||||
}
|
||||
|
||||
func TestSpaceStorage_Create(t *testing.T) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue