WIP storage

This commit is contained in:
mcrakhman 2022-10-10 23:08:44 +02:00 committed by Mikhail Iudin
parent 8ba457bd12
commit 25260793c6
No known key found for this signature in database
GPG Key ID: FAAAA8BAABDFF1C0
15 changed files with 614 additions and 160 deletions

View File

@ -107,7 +107,6 @@ func (d *diffSyncer) sendPushSpaceRequest(ctx context.Context, cl spacesyncproto
} }
_, err = cl.PushSpace(ctx, &spacesyncproto.PushSpaceRequest{ _, err = cl.PushSpace(ctx, &spacesyncproto.PushSpaceRequest{
SpaceId: d.spaceId,
SpaceHeader: header, SpaceHeader: header,
AclRoot: root, AclRoot: root,
}) })

View File

@ -25,7 +25,7 @@ import (
type pushSpaceRequestMatcher struct { type pushSpaceRequestMatcher struct {
spaceId string spaceId string
aclRoot *aclrecordproto.RawACLRecordWithId aclRoot *aclrecordproto.RawACLRecordWithId
spaceHeader *spacesyncproto.SpaceHeader spaceHeader *spacesyncproto.RawSpaceHeaderWithId
} }
func (p pushSpaceRequestMatcher) Matches(x interface{}) bool { func (p pushSpaceRequestMatcher) Matches(x interface{}) bool {
@ -34,7 +34,7 @@ func (p pushSpaceRequestMatcher) Matches(x interface{}) bool {
return false return false
} }
return res.SpaceId == p.spaceId && res.AclRoot == p.aclRoot && res.SpaceHeader == p.spaceHeader return res.AclRoot == p.aclRoot && res.SpaceHeader == p.spaceHeader
} }
func (p pushSpaceRequestMatcher) String() string { func (p pushSpaceRequestMatcher) String() string {
@ -73,7 +73,7 @@ func (m mockPeer) NewStream(ctx context.Context, rpc string, enc drpc.Encoding)
func newPushSpaceRequestMatcher( func newPushSpaceRequestMatcher(
spaceId string, spaceId string,
aclRoot *aclrecordproto.RawACLRecordWithId, aclRoot *aclrecordproto.RawACLRecordWithId,
spaceHeader *spacesyncproto.SpaceHeader) *pushSpaceRequestMatcher { spaceHeader *spacesyncproto.RawSpaceHeaderWithId) *pushSpaceRequestMatcher {
return &pushSpaceRequestMatcher{ return &pushSpaceRequestMatcher{
spaceId: spaceId, spaceId: spaceId,
aclRoot: aclRoot, aclRoot: aclRoot,
@ -125,7 +125,7 @@ func TestDiffSyncer_Sync(t *testing.T) {
t.Run("diff syncer sync space missing", func(t *testing.T) { t.Run("diff syncer sync space missing", func(t *testing.T) {
aclStorageMock := mock_aclstorage.NewMockListStorage(ctrl) aclStorageMock := mock_aclstorage.NewMockListStorage(ctrl)
aclRoot := &aclrecordproto.RawACLRecordWithId{} aclRoot := &aclrecordproto.RawACLRecordWithId{}
spaceHeader := &spacesyncproto.SpaceHeader{} spaceHeader := &spacesyncproto.RawSpaceHeaderWithId{}
connectorMock.EXPECT(). connectorMock.EXPECT().
GetResponsiblePeers(gomock.Any(), spaceId). GetResponsiblePeers(gomock.Any(), spaceId).

View File

@ -39,11 +39,21 @@ func storagePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload st
if err != nil { if err != nil {
return return
} }
id, err := cid.NewCIDFromBytes(marshalled) signature, err := payload.SigningKey.Sign(marshalled)
if err != nil { if err != nil {
return return
} }
rawHeader := &spacesyncproto.RawSpaceHeader{SpaceHeader: marshalled, Signature: signature}
marshalled, err = rawHeader.Marshal()
if err != nil {
return
}
id, err := cid.NewCIDFromBytes(marshalled)
spaceId := NewSpaceId(id, payload.ReplicationKey) spaceId := NewSpaceId(id, payload.ReplicationKey)
rawHeaderWithId := &spacesyncproto.RawSpaceHeaderWithId{
RawHeader: marshalled,
Id: spaceId,
}
// encrypting read key // encrypting read key
hasher := fnv.New64() hasher := fnv.New64()
@ -74,9 +84,8 @@ func storagePayloadForSpaceCreate(payload SpaceCreatePayload) (storagePayload st
// creating storage // creating storage
storagePayload = storage.SpaceStorageCreatePayload{ storagePayload = storage.SpaceStorageCreatePayload{
RecWithId: rawWithId, RecWithId: rawWithId,
SpaceHeader: header, SpaceHeaderWithId: rawHeaderWithId,
Id: id,
} }
return return
} }
@ -118,11 +127,21 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
if err != nil { if err != nil {
return return
} }
id, err := cid.NewCIDFromBytes(marshalled) signature, err := payload.SigningKey.Sign(marshalled)
if err != nil { if err != nil {
return return
} }
rawHeader := &spacesyncproto.RawSpaceHeader{SpaceHeader: marshalled, Signature: signature}
marshalled, err = rawHeader.Marshal()
if err != nil {
return
}
id, err := cid.NewCIDFromBytes(marshalled)
spaceId := NewSpaceId(id, repKey) spaceId := NewSpaceId(id, repKey)
rawHeaderWithId := &spacesyncproto.RawSpaceHeaderWithId{
RawHeader: marshalled,
Id: spaceId,
}
// deriving and encrypting read key // deriving and encrypting read key
readKey, err := aclrecordproto.ACLReadKeyDerive(signPrivKey, encPrivKey) readKey, err := aclrecordproto.ACLReadKeyDerive(signPrivKey, encPrivKey)
@ -157,9 +176,8 @@ func storagePayloadForSpaceDerive(payload SpaceDerivePayload) (storagePayload st
// creating storage // creating storage
storagePayload = storage.SpaceStorageCreatePayload{ storagePayload = storage.SpaceStorageCreatePayload{
RecWithId: rawWithId, RecWithId: rawWithId,
SpaceHeader: header, SpaceHeaderWithId: rawHeaderWithId,
Id: id,
} }
return return
} }

View File

@ -62,7 +62,7 @@ func (s *service) CreateSpace(
return return
} }
return s.GetSpace(ctx, storageCreate.Id) return s.GetSpace(ctx, storageCreate.SpaceHeaderWithId.GetId())
} }
func (s *service) DeriveSpace( func (s *service) DeriveSpace(
@ -78,7 +78,7 @@ func (s *service) DeriveSpace(
return return
} }
return s.GetSpace(ctx, storageCreate.Id) return s.GetSpace(ctx, storageCreate.SpaceHeaderWithId.GetId())
} }
func (s *service) GetSpace(ctx context.Context, id string) (Space, error) { func (s *service) GetSpace(ctx context.Context, id string) (Space, error) {

View File

@ -102,8 +102,7 @@ message ObjectErrorResponse {
// PushSpaceRequest is a request to add space on a node containing only one acl record // PushSpaceRequest is a request to add space on a node containing only one acl record
message PushSpaceRequest { message PushSpaceRequest {
string spaceId = 1; RawSpaceHeaderWithId spaceHeader = 2;
SpaceHeader spaceHeader = 2;
aclrecord.RawACLRecordWithId aclRoot = 3; aclrecord.RawACLRecordWithId aclRoot = 3;
} }
@ -118,3 +117,13 @@ message SpaceHeader {
uint64 replicationKey = 4; uint64 replicationKey = 4;
bytes seed = 5; bytes seed = 5;
} }
message RawSpaceHeader {
bytes spaceHeader = 1;
bytes signature = 2;
}
message RawSpaceHeaderWithId {
bytes rawHeader = 1;
string id = 2;
}

View File

@ -747,8 +747,7 @@ func (m *ObjectErrorResponse) GetError() string {
// PushSpaceRequest is a request to add space on a node containing only one acl record // PushSpaceRequest is a request to add space on a node containing only one acl record
type PushSpaceRequest struct { type PushSpaceRequest struct {
SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` SpaceHeader *RawSpaceHeaderWithId `protobuf:"bytes,2,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
SpaceHeader *SpaceHeader `protobuf:"bytes,2,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
AclRoot *aclrecordproto.RawACLRecordWithId `protobuf:"bytes,3,opt,name=aclRoot,proto3" json:"aclRoot,omitempty"` AclRoot *aclrecordproto.RawACLRecordWithId `protobuf:"bytes,3,opt,name=aclRoot,proto3" json:"aclRoot,omitempty"`
} }
@ -785,14 +784,7 @@ func (m *PushSpaceRequest) XXX_DiscardUnknown() {
var xxx_messageInfo_PushSpaceRequest proto.InternalMessageInfo var xxx_messageInfo_PushSpaceRequest proto.InternalMessageInfo
func (m *PushSpaceRequest) GetSpaceId() string { func (m *PushSpaceRequest) GetSpaceHeader() *RawSpaceHeaderWithId {
if m != nil {
return m.SpaceId
}
return ""
}
func (m *PushSpaceRequest) GetSpaceHeader() *SpaceHeader {
if m != nil { if m != nil {
return m.SpaceHeader return m.SpaceHeader
} }
@ -920,6 +912,110 @@ func (m *SpaceHeader) GetSeed() []byte {
return nil return nil
} }
type RawSpaceHeader struct {
SpaceHeader []byte `protobuf:"bytes,1,opt,name=spaceHeader,proto3" json:"spaceHeader,omitempty"`
Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
}
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_5855f4ef9cf24cdb, []int{14}
}
func (m *RawSpaceHeader) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *RawSpaceHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_RawSpaceHeader.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 *RawSpaceHeader) XXX_Merge(src proto.Message) {
xxx_messageInfo_RawSpaceHeader.Merge(m, src)
}
func (m *RawSpaceHeader) XXX_Size() int {
return m.Size()
}
func (m *RawSpaceHeader) XXX_DiscardUnknown() {
xxx_messageInfo_RawSpaceHeader.DiscardUnknown(m)
}
var xxx_messageInfo_RawSpaceHeader proto.InternalMessageInfo
func (m *RawSpaceHeader) GetSpaceHeader() []byte {
if m != nil {
return m.SpaceHeader
}
return nil
}
func (m *RawSpaceHeader) GetSignature() []byte {
if m != nil {
return m.Signature
}
return nil
}
type RawSpaceHeaderWithId struct {
RawHeader []byte `protobuf:"bytes,1,opt,name=rawHeader,proto3" json:"rawHeader,omitempty"`
Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"`
}
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_5855f4ef9cf24cdb, []int{15}
}
func (m *RawSpaceHeaderWithId) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *RawSpaceHeaderWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_RawSpaceHeaderWithId.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 *RawSpaceHeaderWithId) XXX_Merge(src proto.Message) {
xxx_messageInfo_RawSpaceHeaderWithId.Merge(m, src)
}
func (m *RawSpaceHeaderWithId) XXX_Size() int {
return m.Size()
}
func (m *RawSpaceHeaderWithId) XXX_DiscardUnknown() {
xxx_messageInfo_RawSpaceHeaderWithId.DiscardUnknown(m)
}
var xxx_messageInfo_RawSpaceHeaderWithId proto.InternalMessageInfo
func (m *RawSpaceHeaderWithId) GetRawHeader() []byte {
if m != nil {
return m.RawHeader
}
return nil
}
func (m *RawSpaceHeaderWithId) GetId() string {
if m != nil {
return m.Id
}
return ""
}
func init() { func init() {
proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value)
proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange")
@ -936,6 +1032,8 @@ func init() {
proto.RegisterType((*PushSpaceRequest)(nil), "anySpace.PushSpaceRequest") proto.RegisterType((*PushSpaceRequest)(nil), "anySpace.PushSpaceRequest")
proto.RegisterType((*PushSpaceResponse)(nil), "anySpace.PushSpaceResponse") proto.RegisterType((*PushSpaceResponse)(nil), "anySpace.PushSpaceResponse")
proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader") proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader")
proto.RegisterType((*RawSpaceHeader)(nil), "anySpace.RawSpaceHeader")
proto.RegisterType((*RawSpaceHeaderWithId)(nil), "anySpace.RawSpaceHeaderWithId")
} }
func init() { func init() {
@ -943,65 +1041,68 @@ func init() {
} }
var fileDescriptor_5855f4ef9cf24cdb = []byte{ var fileDescriptor_5855f4ef9cf24cdb = []byte{
// 919 bytes of a gzipped FileDescriptorProto // 965 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x8e, 0x1b, 0x45, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x92, 0xdb, 0x44,
0x10, 0xf6, 0x78, 0xbd, 0x6b, 0xbb, 0xbc, 0x3f, 0x4e, 0x87, 0x0d, 0x83, 0x43, 0x1c, 0x33, 0x07, 0x10, 0xb6, 0xbc, 0x3f, 0xb6, 0xdb, 0x5e, 0xaf, 0x33, 0xf9, 0x41, 0x38, 0xc4, 0x31, 0x3a, 0x50,
0xb4, 0x02, 0xb1, 0x46, 0xe6, 0x10, 0x60, 0x91, 0x50, 0xb2, 0x78, 0x65, 0x2b, 0xe4, 0x47, 0xbd, 0x5b, 0x50, 0xac, 0x29, 0x73, 0xe0, 0x67, 0xa9, 0x82, 0x64, 0xe3, 0x2d, 0xbb, 0x42, 0x92, 0xad,
0x09, 0x48, 0x88, 0x4b, 0x67, 0xa6, 0xd6, 0x1e, 0x32, 0x9e, 0x1e, 0xa6, 0xdb, 0x6c, 0xfc, 0x04, 0xd9, 0x04, 0xaa, 0x28, 0x2e, 0x13, 0x69, 0xd6, 0x16, 0x91, 0x35, 0x62, 0x66, 0x8c, 0xe3, 0x27,
0x5c, 0x40, 0xe2, 0x09, 0x90, 0x78, 0x16, 0x2e, 0x1c, 0x73, 0xcc, 0x11, 0xed, 0xbe, 0x08, 0xea, 0xe0, 0x02, 0x55, 0xbc, 0x02, 0xcf, 0xc2, 0x85, 0x63, 0x8e, 0x39, 0x52, 0xbb, 0x2f, 0x42, 0x4d,
0x9a, 0x19, 0xcf, 0xd8, 0x4c, 0xb2, 0xc7, 0x5c, 0x3c, 0x5d, 0x55, 0x5f, 0x55, 0x7f, 0x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0x09, 0x00, 0x00, 0xb0, 0x3e, 0xb3, 0xee, 0x1e, 0xfd, 0x7b, 0xd1, 0xb3, 0x5e, 0x5c, 0xf4, 0xac, 0xff, 0x2e, 0x7a,
0xd6, 0x5f, 0x97, 0xbd, 0xca, 0x8b, 0xcb, 0x5e, 0xe5, 0xe5, 0x65, 0xaf, 0xf2, 0xd3, 0x87, 0x6f,
0xfd, 0xc7, 0xf5, 0x74, 0x17, 0xbf, 0x3e, 0xff, 0x3f, 0x00, 0x00, 0xff, 0xff, 0x2e, 0x4f, 0xd9,
0xa3, 0x9d, 0x09, 0x00, 0x00,
} }
func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) {
@ -1632,13 +1733,6 @@ func (m *PushSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i-- i--
dAtA[i] = 0x12 dAtA[i] = 0x12
} }
if len(m.SpaceId) > 0 {
i -= len(m.SpaceId)
copy(dAtA[i:], m.SpaceId)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceId)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
@ -1719,6 +1813,80 @@ func (m *SpaceHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
func (m *RawSpaceHeader) 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 *RawSpaceHeader) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *RawSpaceHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Signature) > 0 {
i -= len(m.Signature)
copy(dAtA[i:], m.Signature)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Signature)))
i--
dAtA[i] = 0x12
}
if len(m.SpaceHeader) > 0 {
i -= len(m.SpaceHeader)
copy(dAtA[i:], m.SpaceHeader)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceHeader)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func (m *RawSpaceHeaderWithId) 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 *RawSpaceHeaderWithId) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *RawSpaceHeaderWithId) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.Id) > 0 {
i -= len(m.Id)
copy(dAtA[i:], m.Id)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Id)))
i--
dAtA[i] = 0x12
}
if len(m.RawHeader) > 0 {
i -= len(m.RawHeader)
copy(dAtA[i:], m.RawHeader)
i = encodeVarintSpacesync(dAtA, i, uint64(len(m.RawHeader)))
i--
dAtA[i] = 0xa
}
return len(dAtA) - i, nil
}
func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int {
offset -= sovSpacesync(v) offset -= sovSpacesync(v)
base := offset base := offset
@ -2010,10 +2178,6 @@ func (m *PushSpaceRequest) Size() (n int) {
} }
var l int var l int
_ = l _ = l
l = len(m.SpaceId)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
if m.SpaceHeader != nil { if m.SpaceHeader != nil {
l = m.SpaceHeader.Size() l = m.SpaceHeader.Size()
n += 1 + l + sovSpacesync(uint64(l)) n += 1 + l + sovSpacesync(uint64(l))
@ -2061,6 +2225,40 @@ func (m *SpaceHeader) Size() (n int) {
return n return n
} }
func (m *RawSpaceHeader) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.SpaceHeader)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
l = len(m.Signature)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
return n
}
func (m *RawSpaceHeaderWithId) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
l = len(m.RawHeader)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
l = len(m.Id)
if l > 0 {
n += 1 + l + sovSpacesync(uint64(l))
}
return n
}
func sovSpacesync(x uint64) (n int) { func sovSpacesync(x uint64) (n int) {
return (math_bits.Len64(x|1) + 6) / 7 return (math_bits.Len64(x|1) + 6) / 7
} }
@ -3588,38 +3786,6 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
return fmt.Errorf("proto: PushSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire) return fmt.Errorf("proto: PushSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire)
} }
switch fieldNum { switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", 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.SpaceId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 2: case 2:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", wireType) return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", wireType)
@ -3650,7 +3816,7 @@ func (m *PushSpaceRequest) Unmarshal(dAtA []byte) error {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
if m.SpaceHeader == nil { if m.SpaceHeader == nil {
m.SpaceHeader = &SpaceHeader{} m.SpaceHeader = &RawSpaceHeaderWithId{}
} }
if err := m.SpaceHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { if err := m.SpaceHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err return err
@ -3951,6 +4117,240 @@ func (m *SpaceHeader) Unmarshal(dAtA []byte) error {
} }
return nil return nil
} }
func (m *RawSpaceHeader) 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: RawSpaceHeader: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: RawSpaceHeader: 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)
}
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.SpaceHeader = append(m.SpaceHeader[:0], dAtA[iNdEx:postIndex]...)
if m.SpaceHeader == nil {
m.SpaceHeader = []byte{}
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Signature", 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.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...)
if m.Signature == nil {
m.Signature = []byte{}
}
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 *RawSpaceHeaderWithId) 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: RawSpaceHeaderWithId: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: RawSpaceHeaderWithId: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field RawHeader", 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.RawHeader = append(m.RawHeader[:0], dAtA[iNdEx:postIndex]...)
if m.RawHeader == nil {
m.RawHeader = []byte{}
}
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Id", 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.Id = string(dAtA[iNdEx:postIndex])
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 skipSpacesync(dAtA []byte) (n int, err error) { func skipSpacesync(dAtA []byte) (n int, err error) {
l := len(dAtA) l := len(dAtA)
iNdEx := 0 iNdEx := 0

View File

@ -149,10 +149,10 @@ func (mr *MockSpaceStorageMockRecorder) CreateTreeStorage(arg0 interface{}) *gom
} }
// SpaceHeader mocks base method. // SpaceHeader mocks base method.
func (m *MockSpaceStorage) SpaceHeader() (*spacesyncproto.SpaceHeader, error) { func (m *MockSpaceStorage) SpaceHeader() (*spacesyncproto.RawSpaceHeaderWithId, error) {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "SpaceHeader") ret := m.ctrl.Call(m, "SpaceHeader")
ret0, _ := ret[0].(*spacesyncproto.SpaceHeader) ret0, _ := ret[0].(*spacesyncproto.RawSpaceHeaderWithId)
ret1, _ := ret[1].(error) ret1, _ := ret[1].(error)
return ret0, ret1 return ret0, ret1
} }

View File

@ -17,14 +17,13 @@ var ErrSpaceStorageMissing = errors.New("space storage missing")
type SpaceStorage interface { type SpaceStorage interface {
storage.Provider storage.Provider
ACLStorage() (storage.ListStorage, error) ACLStorage() (storage.ListStorage, error)
SpaceHeader() (*spacesyncproto.SpaceHeader, error) SpaceHeader() (*spacesyncproto.RawSpaceHeaderWithId, error)
StoredIds() ([]string, error) StoredIds() ([]string, error)
} }
type SpaceStorageCreatePayload struct { type SpaceStorageCreatePayload struct {
RecWithId *aclrecordproto.RawACLRecordWithId RecWithId *aclrecordproto.RawACLRecordWithId
SpaceHeader *spacesyncproto.SpaceHeader SpaceHeaderWithId *spacesyncproto.RawSpaceHeaderWithId
Id string
} }
type SpaceStorageProvider interface { type SpaceStorageProvider interface {

View File

@ -12,7 +12,7 @@ type rpcHandler struct {
} }
func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpaceRequest) (resp *spacesyncproto.PushSpaceResponse, err error) { func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpaceRequest) (resp *spacesyncproto.PushSpaceResponse, err error) {
_, err = r.s.GetSpace(ctx, req.SpaceId) _, err = r.s.GetSpace(ctx, req.SpaceHeader.Id)
if err == nil { if err == nil {
err = spacesyncproto.ErrSpaceExists err = spacesyncproto.ErrSpaceExists
return return
@ -23,9 +23,8 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac
} }
payload := storage.SpaceStorageCreatePayload{ payload := storage.SpaceStorageCreatePayload{
RecWithId: req.AclRoot, RecWithId: req.AclRoot,
SpaceHeader: req.SpaceHeader, SpaceHeaderWithId: req.SpaceHeader,
Id: req.SpaceId,
} }
_, err = r.s.spaceStorageProvider.CreateSpaceStorage(payload) _, err = r.s.spaceStorageProvider.CreateSpaceStorage(payload)
if err != nil { if err != nil {

View File

@ -10,7 +10,7 @@ type treeKeys struct {
} }
func (t treeKeys) HeadsKey() string { func (t treeKeys) HeadsKey() string {
return fmt.Sprintf("%s/heads", t.id) return fmt.Sprintf("t/%s/heads", t.id)
} }
func (t treeKeys) RootKey() string { func (t treeKeys) RootKey() string {
@ -18,7 +18,7 @@ func (t treeKeys) RootKey() string {
} }
func (t treeKeys) RawChangeKey(id string) string { func (t treeKeys) RawChangeKey(id string) string {
return fmt.Sprintf("%s/%s", t.id, id) return fmt.Sprintf("t/%s/%s", t.id, id)
} }
type spaceKeys struct { type spaceKeys struct {
@ -33,5 +33,5 @@ func (s spaceKeys) ACLKey() string {
} }
func isTreeKey(path string) bool { func isTreeKey(path string) bool {
return strings.HasPrefix(path, "t/") return strings.HasPrefix(path, "t/") && len(strings.Split(path, "/")) > 2
} }

View File

@ -49,7 +49,8 @@ func newSpaceStorage(rootPath string, spaceId string) (store spacestorage.SpaceS
} }
func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreatePayload) (store spacestorage.SpaceStorage, err error) { func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreatePayload) (store spacestorage.SpaceStorage, err error) {
dbPath := path.Join(rootPath, payload.Id) // TODO: add payload verification
dbPath := path.Join(rootPath, payload.SpaceHeaderWithId.Id)
db, err := pogreb.Open(dbPath, nil) db, err := pogreb.Open(dbPath, nil)
if err != nil { if err != nil {
return return
@ -65,19 +66,24 @@ func createSpaceStorage(rootPath string, payload spacestorage.SpaceStorageCreate
return return
} }
err = db.Put([]byte(payload.RecWithId.Id), payload.RecWithId.Payload) marshalledRec, err := payload.RecWithId.Marshal()
if err != nil {
return
}
err = db.Put([]byte(keys.ACLKey()), marshalledRec)
if err != nil { if err != nil {
return return
} }
marshalled, err := payload.SpaceHeader.Marshal() marshalledHeader, err := payload.SpaceHeaderWithId.Marshal()
if err != nil { if err != nil {
return return
} }
err = db.Put([]byte(payload.Id), marshalled) err = db.Put([]byte(keys.HeaderKey()), marshalledHeader)
if err != nil { if err != nil {
return return
} }
store = &spaceStorage{ store = &spaceStorage{
objDb: db, objDb: db,
keys: keys, keys: keys,
@ -100,6 +106,7 @@ func (s *spaceStorage) CreateTreeStorage(payload storage.TreeStorageCreatePayloa
err = spacestorage.ErrSpaceStorageExists err = spacestorage.ErrSpaceStorageExists
return return
} }
return createTreeStorage(s.objDb, payload) return createTreeStorage(s.objDb, payload)
} }
@ -107,19 +114,20 @@ func (s *spaceStorage) ACLStorage() (storage.ListStorage, error) {
return nil, nil return nil, nil
} }
func (s *spaceStorage) SpaceHeader() (header *spacesyncproto.SpaceHeader, err error) { func (s *spaceStorage) SpaceHeader() (header *spacesyncproto.RawSpaceHeaderWithId, err error) {
res, err := s.objDb.Get([]byte(s.keys.HeaderKey())) res, err := s.objDb.Get([]byte(s.keys.HeaderKey()))
if err != nil { if err != nil {
return return
} }
header = &spacesyncproto.SpaceHeader{} header = &spacesyncproto.RawSpaceHeaderWithId{}
err = proto.Unmarshal(res, header) err = proto.Unmarshal(res, header)
return return
} }
func (s *spaceStorage) StoredIds() (ids []string, err error) { func (s *spaceStorage) StoredIds() (ids []string, err error) {
index := s.objDb.Items() index := s.objDb.Items()
_, value, err := index.Next() _, value, err := index.Next()
for err == nil { for err == nil {
strVal := string(value) strVal := string(value)
@ -128,6 +136,7 @@ func (s *spaceStorage) StoredIds() (ids []string, err error) {
} }
_, value, err = index.Next() _, value, err = index.Next()
} }
if err != pogreb.ErrIterationDone { if err != pogreb.ErrIterationDone {
return return
} }

View File

@ -28,11 +28,19 @@ func newTreeStorage(db *pogreb.DB, treeId string) (ts storage.TreeStorage, err e
if err != nil { if err != nil {
return return
} }
if heads == nil {
err = storage.ErrUnknownTreeId
return
}
res, err := db.Get([]byte(path.RootKey())) res, err := db.Get([]byte(path.RootKey()))
if err != nil { if err != nil {
return return
} }
if res == nil {
err = storage.ErrUnknownTreeId
return
}
root := &treechangeproto.RawTreeChangeWithId{} root := &treechangeproto.RawTreeChangeWithId{}
err = proto.Unmarshal(res, root) err = proto.Unmarshal(res, root)
@ -53,31 +61,46 @@ func newTreeStorage(db *pogreb.DB, treeId string) (ts storage.TreeStorage, err e
} }
func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) { func createTreeStorage(db *pogreb.DB, payload storage.TreeStorageCreatePayload) (ts storage.TreeStorage, err error) {
path := treeKeys{payload.TreeId} keys := treeKeys{id: payload.TreeId}
has, err := db.Has([]byte(keys.RootKey()))
if err != nil {
return
}
if !has {
err = storage.ErrUnknownTreeId
return
}
heads := createHeadsPayload(payload.Heads) heads := createHeadsPayload(payload.Heads)
for _, ch := range payload.Changes { for _, ch := range payload.Changes {
err = db.Put([]byte(path.RawChangeKey(ch.Id)), ch.GetRawChange()) err = db.Put([]byte(keys.RawChangeKey(ch.Id)), ch.GetRawChange())
if err != nil { if err != nil {
return return
} }
} }
err = db.Put([]byte(path.HeadsKey()), heads) err = db.Put([]byte(keys.HeadsKey()), heads)
if err != nil { if err != nil {
return return
} }
err = db.Put([]byte(path.RootKey()), payload.RootRawChange.GetRawChange()) // duplicating same change in raw changes
err = db.Put([]byte(keys.RawChangeKey(payload.TreeId)), payload.RootRawChange.GetRawChange())
if err != nil {
return
}
err = db.Put([]byte(keys.RootKey()), payload.RootRawChange.GetRawChange())
if err != nil { if err != nil {
return return
} }
ts = &treeStorage{ ts = &treeStorage{
db: db, db: db,
path: path, path: keys,
rootPath: []byte(path.RootKey()), rootPath: []byte(keys.RootKey()),
headsPath: []byte(path.HeadsKey()), headsPath: []byte(keys.HeadsKey()),
id: payload.TreeId, id: payload.TreeId,
heads: payload.Heads, heads: payload.Heads,
root: payload.RootRawChange, root: payload.RootRawChange,

View File

@ -324,7 +324,6 @@ func (m *ACLRoot) GetTimestamp() int64 {
type ACLContentValue struct { type ACLContentValue struct {
// Types that are valid to be assigned to Value: // Types that are valid to be assigned to Value:
//
// *ACLContentValue_UserAdd // *ACLContentValue_UserAdd
// *ACLContentValue_UserRemove // *ACLContentValue_UserRemove
// *ACLContentValue_UserPermissionChange // *ACLContentValue_UserPermissionChange

View File

@ -60,7 +60,6 @@ var xxx_messageInfo_PlainTextChange proto.InternalMessageInfo
type PlainTextChange_Content struct { type PlainTextChange_Content struct {
// Types that are valid to be assigned to Value: // Types that are valid to be assigned to Value:
//
// *PlainTextChange_Content_TextAppend // *PlainTextChange_Content_TextAppend
Value isPlainTextChange_Content_Value `protobuf_oneof:"value"` Value isPlainTextChange_Content_Value `protobuf_oneof:"value"`
} }

View File

@ -137,7 +137,7 @@ func (mr *MockObjectTreeMockRecorder) HasChanges(arg0 ...interface{}) *gomock.Ca
// Header mocks base method. // Header mocks base method.
func (m *MockObjectTree) Header() *treechangeproto.RawTreeChangeWithId { func (m *MockObjectTree) Header() *treechangeproto.RawTreeChangeWithId {
m.ctrl.T.Helper() m.ctrl.T.Helper()
ret := m.ctrl.Call(m, "HeaderKey") ret := m.ctrl.Call(m, "Header")
ret0, _ := ret[0].(*treechangeproto.RawTreeChangeWithId) ret0, _ := ret[0].(*treechangeproto.RawTreeChangeWithId)
return ret0 return ret0
} }
@ -145,7 +145,7 @@ func (m *MockObjectTree) Header() *treechangeproto.RawTreeChangeWithId {
// Header indicates an expected call of Header. // Header indicates an expected call of Header.
func (mr *MockObjectTreeMockRecorder) Header() *gomock.Call { func (mr *MockObjectTreeMockRecorder) Header() *gomock.Call {
mr.mock.ctrl.T.Helper() mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HeaderKey", reflect.TypeOf((*MockObjectTree)(nil).Header)) return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Header", reflect.TypeOf((*MockObjectTree)(nil).Header))
} }
// Heads mocks base method. // Heads mocks base method.