From 357e889dad0f3e7404184211107b8bb55aa57074 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Wed, 7 Sep 2022 19:43:01 +0300 Subject: [PATCH 01/44] change proto generator to std gogo --- go.mod | 2 + go.sum | 8 + pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 811 +++++++++--------- pkg/acl/acltree/aclstate.go | 46 +- pkg/acl/acltree/aclstatebuilder.go | 2 +- pkg/acl/acltree/change.go | 2 +- pkg/acl/acltree/changebuilder.go | 14 +- pkg/acl/acltree/treegraph_nix.go | 4 +- pkg/acl/example/plaintextdocument/document.go | 18 +- .../plaintextdocument/plaintextdocstate.go | 6 +- .../testchangepb/testdocumentchanges.pb.go | 211 ++--- .../treestoragebuilder/treestoragebuilder.go | 68 +- .../treestoragebuildergraph_nix.go | 6 +- service/net/pool/message.go | 8 +- service/space/remotediff/remotediff.go | 22 +- service/space/service.go | 6 +- service/space/space.go | 2 +- service/space/spacesync/spacesync.pb.go | 327 +++---- service/sync/document/service.go | 22 +- service/sync/message/service.go | 2 +- service/sync/requesthandler/requesthandler.go | 28 +- syncproto/helpers.go | 18 +- syncproto/sync.pb.go | 538 ++++++------ 23 files changed, 1092 insertions(+), 1079 deletions(-) diff --git a/go.mod b/go.mod index 61ad4841..e27f9d45 100644 --- a/go.mod +++ b/go.mod @@ -32,6 +32,7 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fogleman/gg v1.3.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect + github.com/golang/protobuf v1.5.2 // indirect github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/libp2p/go-openssl v0.0.7 // indirect @@ -52,6 +53,7 @@ require ( golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect + google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect lukechampine.com/blake3 v1.1.6 // indirect diff --git a/go.sum b/go.sum index 3aecda9c..84667305 100644 --- a/go.sum +++ b/go.sum @@ -32,6 +32,10 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= +github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= +github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= +github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= @@ -178,6 +182,10 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= +google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= +google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index 4a892fdf..d42f22ba 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -22,34 +22,34 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type ACLChangeUserPermissions int32 +type ACLChange_UserPermissions int32 const ( - ACLChange_Admin ACLChangeUserPermissions = 0 - ACLChange_Writer ACLChangeUserPermissions = 1 - ACLChange_Reader ACLChangeUserPermissions = 2 - ACLChange_Removed ACLChangeUserPermissions = 3 + ACLChange_Admin ACLChange_UserPermissions = 0 + ACLChange_Writer ACLChange_UserPermissions = 1 + ACLChange_Reader ACLChange_UserPermissions = 2 + ACLChange_Removed ACLChange_UserPermissions = 3 ) -var ACLChangeUserPermissions_name = map[int32]string{ +var ACLChange_UserPermissions_name = map[int32]string{ 0: "Admin", 1: "Writer", 2: "Reader", 3: "Removed", } -var ACLChangeUserPermissions_value = map[string]int32{ +var ACLChange_UserPermissions_value = map[string]int32{ "Admin": 0, "Writer": 1, "Reader": 2, "Removed": 3, } -func (x ACLChangeUserPermissions) String() string { - return proto.EnumName(ACLChangeUserPermissions_name, int32(x)) +func (x ACLChange_UserPermissions) String() string { + return proto.EnumName(ACLChange_UserPermissions_name, int32(x)) } -func (ACLChangeUserPermissions) EnumDescriptor() ([]byte, []int) { +func (ACLChange_UserPermissions) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 0} } @@ -115,10 +115,10 @@ func (m *RawChange) GetId() string { // the element of change tree used to store and internal apply smartBlock history type ACLChange struct { - TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` - AclHeadIds []string `protobuf:"bytes,2,rep,name=aclHeadIds,proto3" json:"aclHeadIds,omitempty"` - SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` - AclData *ACLChangeACLData `protobuf:"bytes,4,opt,name=aclData,proto3" json:"aclData,omitempty"` + TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` + AclHeadIds []string `protobuf:"bytes,2,rep,name=aclHeadIds,proto3" json:"aclHeadIds,omitempty"` + SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` + AclData *ACLChange_ACLData `protobuf:"bytes,4,opt,name=aclData,proto3" json:"aclData,omitempty"` // the data is encoded with read key and should be read in ChangesData format ChangesData []byte `protobuf:"bytes,5,opt,name=changesData,proto3" json:"changesData,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,6,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` @@ -180,7 +180,7 @@ func (m *ACLChange) GetSnapshotBaseId() string { return "" } -func (m *ACLChange) GetAclData() *ACLChangeACLData { +func (m *ACLChange) GetAclData() *ACLChange_ACLData { if m != nil { return m.AclData } @@ -215,29 +215,30 @@ func (m *ACLChange) GetIdentity() string { return "" } -type ACLChangeACLContentValue struct { +type ACLChange_ACLContentValue struct { // Types that are valid to be assigned to Value: - // *ACLChangeACLContentValueValueOfUserAdd - // *ACLChangeACLContentValueValueOfUserRemove - // *ACLChangeACLContentValueValueOfUserPermissionChange - // *ACLChangeACLContentValueValueOfUserInvite - // *ACLChangeACLContentValueValueOfUserJoin - // *ACLChangeACLContentValueValueOfUserConfirm - Value IsACLChangeACLContentValueValue `protobuf_oneof:"value"` + // + // *ACLChange_ACLContent_Value_UserAdd + // *ACLChange_ACLContent_Value_UserRemove + // *ACLChange_ACLContent_Value_UserPermissionChange + // *ACLChange_ACLContent_Value_UserInvite + // *ACLChange_ACLContent_Value_UserJoin + // *ACLChange_ACLContent_Value_UserConfirm + Value isACLChange_ACLContent_Value_Value `protobuf_oneof:"value"` } -func (m *ACLChangeACLContentValue) Reset() { *m = ACLChangeACLContentValue{} } -func (m *ACLChangeACLContentValue) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLContentValue) ProtoMessage() {} -func (*ACLChangeACLContentValue) Descriptor() ([]byte, []int) { +func (m *ACLChange_ACLContentValue) Reset() { *m = ACLChange_ACLContentValue{} } +func (m *ACLChange_ACLContentValue) String() string { return proto.CompactTextString(m) } +func (*ACLChange_ACLContentValue) ProtoMessage() {} +func (*ACLChange_ACLContentValue) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 0} } -func (m *ACLChangeACLContentValue) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_ACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_ACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLContentValue.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_ACLContentValue.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -247,128 +248,128 @@ func (m *ACLChangeACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *ACLChangeACLContentValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLContentValue.Merge(m, src) +func (m *ACLChange_ACLContentValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_ACLContentValue.Merge(m, src) } -func (m *ACLChangeACLContentValue) XXX_Size() int { +func (m *ACLChange_ACLContentValue) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLContentValue) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLContentValue.DiscardUnknown(m) +func (m *ACLChange_ACLContentValue) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_ACLContentValue.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLContentValue proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_ACLContentValue proto.InternalMessageInfo -type IsACLChangeACLContentValueValue interface { - IsACLChangeACLContentValueValue() +type isACLChange_ACLContent_Value_Value interface { + isACLChange_ACLContent_Value_Value() MarshalTo([]byte) (int, error) Size() int } -type ACLChangeACLContentValueValueOfUserAdd struct { - UserAdd *ACLChangeUserAdd `protobuf:"bytes,1,opt,name=userAdd,proto3,oneof" json:"userAdd,omitempty"` +type ACLChange_ACLContent_Value_UserAdd struct { + UserAdd *ACLChange_UserAdd `protobuf:"bytes,1,opt,name=userAdd,proto3,oneof" json:"userAdd,omitempty"` } -type ACLChangeACLContentValueValueOfUserRemove struct { - UserRemove *ACLChangeUserRemove `protobuf:"bytes,2,opt,name=userRemove,proto3,oneof" json:"userRemove,omitempty"` +type ACLChange_ACLContent_Value_UserRemove struct { + UserRemove *ACLChange_UserRemove `protobuf:"bytes,2,opt,name=userRemove,proto3,oneof" json:"userRemove,omitempty"` } -type ACLChangeACLContentValueValueOfUserPermissionChange struct { - UserPermissionChange *ACLChangeUserPermissionChange `protobuf:"bytes,3,opt,name=userPermissionChange,proto3,oneof" json:"userPermissionChange,omitempty"` +type ACLChange_ACLContent_Value_UserPermissionChange struct { + UserPermissionChange *ACLChange_UserPermissionChange `protobuf:"bytes,3,opt,name=userPermissionChange,proto3,oneof" json:"userPermissionChange,omitempty"` } -type ACLChangeACLContentValueValueOfUserInvite struct { - UserInvite *ACLChangeUserInvite `protobuf:"bytes,4,opt,name=userInvite,proto3,oneof" json:"userInvite,omitempty"` +type ACLChange_ACLContent_Value_UserInvite struct { + UserInvite *ACLChange_UserInvite `protobuf:"bytes,4,opt,name=userInvite,proto3,oneof" json:"userInvite,omitempty"` } -type ACLChangeACLContentValueValueOfUserJoin struct { - UserJoin *ACLChangeUserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` +type ACLChange_ACLContent_Value_UserJoin struct { + UserJoin *ACLChange_UserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` } -type ACLChangeACLContentValueValueOfUserConfirm struct { - UserConfirm *ACLChangeUserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` +type ACLChange_ACLContent_Value_UserConfirm struct { + UserConfirm *ACLChange_UserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` } -func (*ACLChangeACLContentValueValueOfUserAdd) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserRemove) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserPermissionChange) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserInvite) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserJoin) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserConfirm) IsACLChangeACLContentValueValue() {} +func (*ACLChange_ACLContent_Value_UserAdd) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContent_Value_UserRemove) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContent_Value_UserPermissionChange) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContent_Value_UserInvite) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContent_Value_UserJoin) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContent_Value_UserConfirm) isACLChange_ACLContent_Value_Value() {} -func (m *ACLChangeACLContentValue) GetValue() IsACLChangeACLContentValueValue { +func (m *ACLChange_ACLContentValue) GetValue() isACLChange_ACLContent_Value_Value { if m != nil { return m.Value } return nil } -func (m *ACLChangeACLContentValue) GetUserAdd() *ACLChangeUserAdd { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserAdd); ok { +func (m *ACLChange_ACLContentValue) GetUserAdd() *ACLChange_UserAdd { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserAdd); ok { return x.UserAdd } return nil } -func (m *ACLChangeACLContentValue) GetUserRemove() *ACLChangeUserRemove { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserRemove); ok { +func (m *ACLChange_ACLContentValue) GetUserRemove() *ACLChange_UserRemove { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserRemove); ok { return x.UserRemove } return nil } -func (m *ACLChangeACLContentValue) GetUserPermissionChange() *ACLChangeUserPermissionChange { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserPermissionChange); ok { +func (m *ACLChange_ACLContentValue) GetUserPermissionChange() *ACLChange_UserPermissionChange { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserPermissionChange); ok { return x.UserPermissionChange } return nil } -func (m *ACLChangeACLContentValue) GetUserInvite() *ACLChangeUserInvite { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserInvite); ok { +func (m *ACLChange_ACLContentValue) GetUserInvite() *ACLChange_UserInvite { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserInvite); ok { return x.UserInvite } return nil } -func (m *ACLChangeACLContentValue) GetUserJoin() *ACLChangeUserJoin { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserJoin); ok { +func (m *ACLChange_ACLContentValue) GetUserJoin() *ACLChange_UserJoin { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserJoin); ok { return x.UserJoin } return nil } -func (m *ACLChangeACLContentValue) GetUserConfirm() *ACLChangeUserConfirm { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserConfirm); ok { +func (m *ACLChange_ACLContentValue) GetUserConfirm() *ACLChange_UserConfirm { + if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserConfirm); ok { return x.UserConfirm } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*ACLChangeACLContentValue) XXX_OneofWrappers() []interface{} { +func (*ACLChange_ACLContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*ACLChangeACLContentValueValueOfUserAdd)(nil), - (*ACLChangeACLContentValueValueOfUserRemove)(nil), - (*ACLChangeACLContentValueValueOfUserPermissionChange)(nil), - (*ACLChangeACLContentValueValueOfUserInvite)(nil), - (*ACLChangeACLContentValueValueOfUserJoin)(nil), - (*ACLChangeACLContentValueValueOfUserConfirm)(nil), + (*ACLChange_ACLContent_Value_UserAdd)(nil), + (*ACLChange_ACLContent_Value_UserRemove)(nil), + (*ACLChange_ACLContent_Value_UserPermissionChange)(nil), + (*ACLChange_ACLContent_Value_UserInvite)(nil), + (*ACLChange_ACLContent_Value_UserJoin)(nil), + (*ACLChange_ACLContent_Value_UserConfirm)(nil), } } -type ACLChangeACLData struct { - AclSnapshot *ACLChangeACLSnapshot `protobuf:"bytes,1,opt,name=aclSnapshot,proto3" json:"aclSnapshot,omitempty"` - AclContent []*ACLChangeACLContentValue `protobuf:"bytes,2,rep,name=aclContent,proto3" json:"aclContent,omitempty"` +type ACLChange_ACLData struct { + AclSnapshot *ACLChange_ACLSnapshot `protobuf:"bytes,1,opt,name=aclSnapshot,proto3" json:"aclSnapshot,omitempty"` + AclContent []*ACLChange_ACLContentValue `protobuf:"bytes,2,rep,name=aclContent,proto3" json:"aclContent,omitempty"` } -func (m *ACLChangeACLData) Reset() { *m = ACLChangeACLData{} } -func (m *ACLChangeACLData) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLData) ProtoMessage() {} -func (*ACLChangeACLData) Descriptor() ([]byte, []int) { +func (m *ACLChange_ACLData) Reset() { *m = ACLChange_ACLData{} } +func (m *ACLChange_ACLData) String() string { return proto.CompactTextString(m) } +func (*ACLChange_ACLData) ProtoMessage() {} +func (*ACLChange_ACLData) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 1} } -func (m *ACLChangeACLData) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_ACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_ACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLData.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_ACLData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -378,49 +379,49 @@ func (m *ACLChangeACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *ACLChangeACLData) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLData.Merge(m, src) +func (m *ACLChange_ACLData) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_ACLData.Merge(m, src) } -func (m *ACLChangeACLData) XXX_Size() int { +func (m *ACLChange_ACLData) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLData) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLData.DiscardUnknown(m) +func (m *ACLChange_ACLData) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_ACLData.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLData proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_ACLData proto.InternalMessageInfo -func (m *ACLChangeACLData) GetAclSnapshot() *ACLChangeACLSnapshot { +func (m *ACLChange_ACLData) GetAclSnapshot() *ACLChange_ACLSnapshot { if m != nil { return m.AclSnapshot } return nil } -func (m *ACLChangeACLData) GetAclContent() []*ACLChangeACLContentValue { +func (m *ACLChange_ACLData) GetAclContent() []*ACLChange_ACLContentValue { if m != nil { return m.AclContent } return nil } -type ACLChangeACLSnapshot struct { +type ACLChange_ACLSnapshot struct { // We don't need ACLState as a separate message now, because we simplified the snapshot model - AclState *ACLChangeACLState `protobuf:"bytes,1,opt,name=aclState,proto3" json:"aclState,omitempty"` + AclState *ACLChange_ACLState `protobuf:"bytes,1,opt,name=aclState,proto3" json:"aclState,omitempty"` } -func (m *ACLChangeACLSnapshot) Reset() { *m = ACLChangeACLSnapshot{} } -func (m *ACLChangeACLSnapshot) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLSnapshot) ProtoMessage() {} -func (*ACLChangeACLSnapshot) Descriptor() ([]byte, []int) { +func (m *ACLChange_ACLSnapshot) Reset() { *m = ACLChange_ACLSnapshot{} } +func (m *ACLChange_ACLSnapshot) String() string { return proto.CompactTextString(m) } +func (*ACLChange_ACLSnapshot) ProtoMessage() {} +func (*ACLChange_ACLSnapshot) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 2} } -func (m *ACLChangeACLSnapshot) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_ACLSnapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_ACLSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLSnapshot.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_ACLSnapshot.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -430,43 +431,43 @@ func (m *ACLChangeACLSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *ACLChangeACLSnapshot) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLSnapshot.Merge(m, src) +func (m *ACLChange_ACLSnapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_ACLSnapshot.Merge(m, src) } -func (m *ACLChangeACLSnapshot) XXX_Size() int { +func (m *ACLChange_ACLSnapshot) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLSnapshot) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLSnapshot.DiscardUnknown(m) +func (m *ACLChange_ACLSnapshot) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_ACLSnapshot.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLSnapshot proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_ACLSnapshot proto.InternalMessageInfo -func (m *ACLChangeACLSnapshot) GetAclState() *ACLChangeACLState { +func (m *ACLChange_ACLSnapshot) GetAclState() *ACLChange_ACLState { if m != nil { return m.AclState } return nil } -type ACLChangeACLState struct { - ReadKeyHashes []uint64 `protobuf:"varint,1,rep,packed,name=readKeyHashes,proto3" json:"readKeyHashes,omitempty"` - UserStates []*ACLChangeUserState `protobuf:"bytes,2,rep,name=userStates,proto3" json:"userStates,omitempty"` - Invites map[string]*ACLChangeUserInvite `protobuf:"bytes,3,rep,name=invites,proto3" json:"invites,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` +type ACLChange_ACLState struct { + ReadKeyHashes []uint64 `protobuf:"varint,1,rep,packed,name=readKeyHashes,proto3" json:"readKeyHashes,omitempty"` + UserStates []*ACLChange_UserState `protobuf:"bytes,2,rep,name=userStates,proto3" json:"userStates,omitempty"` + Invites map[string]*ACLChange_UserInvite `protobuf:"bytes,3,rep,name=invites,proto3" json:"invites,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (m *ACLChangeACLState) Reset() { *m = ACLChangeACLState{} } -func (m *ACLChangeACLState) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLState) ProtoMessage() {} -func (*ACLChangeACLState) Descriptor() ([]byte, []int) { +func (m *ACLChange_ACLState) Reset() { *m = ACLChange_ACLState{} } +func (m *ACLChange_ACLState) String() string { return proto.CompactTextString(m) } +func (*ACLChange_ACLState) ProtoMessage() {} +func (*ACLChange_ACLState) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 3} } -func (m *ACLChangeACLState) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_ACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_ACLState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLState.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_ACLState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -476,59 +477,59 @@ func (m *ACLChangeACLState) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *ACLChangeACLState) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLState.Merge(m, src) +func (m *ACLChange_ACLState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_ACLState.Merge(m, src) } -func (m *ACLChangeACLState) XXX_Size() int { +func (m *ACLChange_ACLState) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLState) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLState.DiscardUnknown(m) +func (m *ACLChange_ACLState) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_ACLState.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLState proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_ACLState proto.InternalMessageInfo -func (m *ACLChangeACLState) GetReadKeyHashes() []uint64 { +func (m *ACLChange_ACLState) GetReadKeyHashes() []uint64 { if m != nil { return m.ReadKeyHashes } return nil } -func (m *ACLChangeACLState) GetUserStates() []*ACLChangeUserState { +func (m *ACLChange_ACLState) GetUserStates() []*ACLChange_UserState { if m != nil { return m.UserStates } return nil } -func (m *ACLChangeACLState) GetInvites() map[string]*ACLChangeUserInvite { +func (m *ACLChange_ACLState) GetInvites() map[string]*ACLChange_UserInvite { if m != nil { return m.Invites } return nil } -type ACLChangeUserState struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` - IsConfirmed bool `protobuf:"varint,5,opt,name=IsConfirmed,proto3" json:"IsConfirmed,omitempty"` +type ACLChange_UserState struct { + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLChange_UserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChange_UserPermissions" json:"permissions,omitempty"` + IsConfirmed bool `protobuf:"varint,5,opt,name=IsConfirmed,proto3" json:"IsConfirmed,omitempty"` } -func (m *ACLChangeUserState) Reset() { *m = ACLChangeUserState{} } -func (m *ACLChangeUserState) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserState) ProtoMessage() {} -func (*ACLChangeUserState) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserState) Reset() { *m = ACLChange_UserState{} } +func (m *ACLChange_UserState) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserState) ProtoMessage() {} +func (*ACLChange_UserState) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 4} } -func (m *ACLChangeUserState) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserState.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -538,47 +539,47 @@ func (m *ACLChangeUserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserState) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserState.Merge(m, src) +func (m *ACLChange_UserState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserState.Merge(m, src) } -func (m *ACLChangeUserState) XXX_Size() int { +func (m *ACLChange_UserState) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserState) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserState.DiscardUnknown(m) +func (m *ACLChange_UserState) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserState.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserState proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserState proto.InternalMessageInfo -func (m *ACLChangeUserState) GetIdentity() string { +func (m *ACLChange_UserState) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserState) GetEncryptionKey() []byte { +func (m *ACLChange_UserState) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserState) GetEncryptedReadKeys() [][]byte { +func (m *ACLChange_UserState) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserState) GetPermissions() ACLChangeUserPermissions { +func (m *ACLChange_UserState) GetPermissions() ACLChange_UserPermissions { if m != nil { return m.Permissions } return ACLChange_Admin } -func (m *ACLChangeUserState) GetIsConfirmed() bool { +func (m *ACLChange_UserState) GetIsConfirmed() bool { if m != nil { return m.IsConfirmed } @@ -586,25 +587,25 @@ func (m *ACLChangeUserState) GetIsConfirmed() bool { } // we already know identity and encryptionKey -type ACLChangeUserAdd struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` +type ACLChange_UserAdd struct { + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLChange_UserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChange_UserPermissions" json:"permissions,omitempty"` } -func (m *ACLChangeUserAdd) Reset() { *m = ACLChangeUserAdd{} } -func (m *ACLChangeUserAdd) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserAdd) ProtoMessage() {} -func (*ACLChangeUserAdd) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserAdd) Reset() { *m = ACLChange_UserAdd{} } +func (m *ACLChange_UserAdd) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserAdd) ProtoMessage() {} +func (*ACLChange_UserAdd) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 5} } -func (m *ACLChangeUserAdd) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserAdd.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserAdd.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -614,40 +615,40 @@ func (m *ACLChangeUserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *ACLChangeUserAdd) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserAdd.Merge(m, src) +func (m *ACLChange_UserAdd) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserAdd.Merge(m, src) } -func (m *ACLChangeUserAdd) XXX_Size() int { +func (m *ACLChange_UserAdd) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserAdd) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserAdd.DiscardUnknown(m) +func (m *ACLChange_UserAdd) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserAdd.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserAdd proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserAdd proto.InternalMessageInfo -func (m *ACLChangeUserAdd) GetIdentity() string { +func (m *ACLChange_UserAdd) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserAdd) GetEncryptionKey() []byte { +func (m *ACLChange_UserAdd) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserAdd) GetEncryptedReadKeys() [][]byte { +func (m *ACLChange_UserAdd) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserAdd) GetPermissions() ACLChangeUserPermissions { +func (m *ACLChange_UserAdd) GetPermissions() ACLChange_UserPermissions { if m != nil { return m.Permissions } @@ -655,23 +656,23 @@ func (m *ACLChangeUserAdd) GetPermissions() ACLChangeUserPermissions { } // TODO: this is not used as of now -type ACLChangeUserConfirm struct { +type ACLChange_UserConfirm struct { Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` } -func (m *ACLChangeUserConfirm) Reset() { *m = ACLChangeUserConfirm{} } -func (m *ACLChangeUserConfirm) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserConfirm) ProtoMessage() {} -func (*ACLChangeUserConfirm) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserConfirm) Reset() { *m = ACLChange_UserConfirm{} } +func (m *ACLChange_UserConfirm) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserConfirm) ProtoMessage() {} +func (*ACLChange_UserConfirm) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 6} } -func (m *ACLChangeUserConfirm) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserConfirm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserConfirm.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserConfirm.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -681,52 +682,52 @@ func (m *ACLChangeUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *ACLChangeUserConfirm) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserConfirm.Merge(m, src) +func (m *ACLChange_UserConfirm) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserConfirm.Merge(m, src) } -func (m *ACLChangeUserConfirm) XXX_Size() int { +func (m *ACLChange_UserConfirm) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserConfirm) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserConfirm.DiscardUnknown(m) +func (m *ACLChange_UserConfirm) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserConfirm.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserConfirm proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserConfirm proto.InternalMessageInfo -func (m *ACLChangeUserConfirm) GetIdentity() string { +func (m *ACLChange_UserConfirm) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserConfirm) GetUserAddId() string { +func (m *ACLChange_UserConfirm) GetUserAddId() string { if m != nil { return m.UserAddId } return "" } -type ACLChangeUserInvite struct { - AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` - EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` - InviteId string `protobuf:"bytes,5,opt,name=InviteId,proto3" json:"InviteId,omitempty"` +type ACLChange_UserInvite struct { + AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` + EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLChange_UserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChange_UserPermissions" json:"permissions,omitempty"` + InviteId string `protobuf:"bytes,5,opt,name=InviteId,proto3" json:"InviteId,omitempty"` } -func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} } -func (m *ACLChangeUserInvite) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserInvite) ProtoMessage() {} -func (*ACLChangeUserInvite) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserInvite) Reset() { *m = ACLChange_UserInvite{} } +func (m *ACLChange_UserInvite) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserInvite) ProtoMessage() {} +func (*ACLChange_UserInvite) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 7} } -func (m *ACLChangeUserInvite) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserInvite.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserInvite.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -736,54 +737,54 @@ func (m *ACLChangeUserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserInvite) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserInvite.Merge(m, src) +func (m *ACLChange_UserInvite) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserInvite.Merge(m, src) } -func (m *ACLChangeUserInvite) XXX_Size() int { +func (m *ACLChange_UserInvite) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserInvite) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserInvite.DiscardUnknown(m) +func (m *ACLChange_UserInvite) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserInvite.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserInvite proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserInvite proto.InternalMessageInfo -func (m *ACLChangeUserInvite) GetAcceptPublicKey() []byte { +func (m *ACLChange_UserInvite) GetAcceptPublicKey() []byte { if m != nil { return m.AcceptPublicKey } return nil } -func (m *ACLChangeUserInvite) GetEncryptPublicKey() []byte { +func (m *ACLChange_UserInvite) GetEncryptPublicKey() []byte { if m != nil { return m.EncryptPublicKey } return nil } -func (m *ACLChangeUserInvite) GetEncryptedReadKeys() [][]byte { +func (m *ACLChange_UserInvite) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserInvite) GetPermissions() ACLChangeUserPermissions { +func (m *ACLChange_UserInvite) GetPermissions() ACLChange_UserPermissions { if m != nil { return m.Permissions } return ACLChange_Admin } -func (m *ACLChangeUserInvite) GetInviteId() string { +func (m *ACLChange_UserInvite) GetInviteId() string { if m != nil { return m.InviteId } return "" } -type ACLChangeUserJoin struct { +type ACLChange_UserJoin struct { Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` @@ -791,18 +792,18 @@ type ACLChangeUserJoin struct { EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` } -func (m *ACLChangeUserJoin) Reset() { *m = ACLChangeUserJoin{} } -func (m *ACLChangeUserJoin) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserJoin) ProtoMessage() {} -func (*ACLChangeUserJoin) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserJoin) Reset() { *m = ACLChange_UserJoin{} } +func (m *ACLChange_UserJoin) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserJoin) ProtoMessage() {} +func (*ACLChange_UserJoin) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 8} } -func (m *ACLChangeUserJoin) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserJoin.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserJoin.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -812,70 +813,70 @@ func (m *ACLChangeUserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *ACLChangeUserJoin) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserJoin.Merge(m, src) +func (m *ACLChange_UserJoin) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserJoin.Merge(m, src) } -func (m *ACLChangeUserJoin) XXX_Size() int { +func (m *ACLChange_UserJoin) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserJoin) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserJoin.DiscardUnknown(m) +func (m *ACLChange_UserJoin) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserJoin.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserJoin proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserJoin proto.InternalMessageInfo -func (m *ACLChangeUserJoin) GetIdentity() string { +func (m *ACLChange_UserJoin) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserJoin) GetEncryptionKey() []byte { +func (m *ACLChange_UserJoin) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserJoin) GetAcceptSignature() []byte { +func (m *ACLChange_UserJoin) GetAcceptSignature() []byte { if m != nil { return m.AcceptSignature } return nil } -func (m *ACLChangeUserJoin) GetUserInviteId() string { +func (m *ACLChange_UserJoin) GetUserInviteId() string { if m != nil { return m.UserInviteId } return "" } -func (m *ACLChangeUserJoin) GetEncryptedReadKeys() [][]byte { +func (m *ACLChange_UserJoin) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -type ACLChangeUserRemove struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - ReadKeyReplaces []*ACLChangeReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` +type ACLChange_UserRemove struct { + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + ReadKeyReplaces []*ACLChange_ReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` } -func (m *ACLChangeUserRemove) Reset() { *m = ACLChangeUserRemove{} } -func (m *ACLChangeUserRemove) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserRemove) ProtoMessage() {} -func (*ACLChangeUserRemove) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserRemove) Reset() { *m = ACLChange_UserRemove{} } +func (m *ACLChange_UserRemove) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserRemove) ProtoMessage() {} +func (*ACLChange_UserRemove) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 9} } -func (m *ACLChangeUserRemove) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserRemove.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserRemove.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -885,50 +886,50 @@ func (m *ACLChangeUserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserRemove) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserRemove.Merge(m, src) +func (m *ACLChange_UserRemove) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserRemove.Merge(m, src) } -func (m *ACLChangeUserRemove) XXX_Size() int { +func (m *ACLChange_UserRemove) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserRemove) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserRemove.DiscardUnknown(m) +func (m *ACLChange_UserRemove) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserRemove.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserRemove proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserRemove proto.InternalMessageInfo -func (m *ACLChangeUserRemove) GetIdentity() string { +func (m *ACLChange_UserRemove) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserRemove) GetReadKeyReplaces() []*ACLChangeReadKeyReplace { +func (m *ACLChange_UserRemove) GetReadKeyReplaces() []*ACLChange_ReadKeyReplace { if m != nil { return m.ReadKeyReplaces } return nil } -type ACLChangeReadKeyReplace struct { +type ACLChange_ReadKeyReplace struct { Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKey []byte `protobuf:"bytes,3,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` } -func (m *ACLChangeReadKeyReplace) Reset() { *m = ACLChangeReadKeyReplace{} } -func (m *ACLChangeReadKeyReplace) String() string { return proto.CompactTextString(m) } -func (*ACLChangeReadKeyReplace) ProtoMessage() {} -func (*ACLChangeReadKeyReplace) Descriptor() ([]byte, []int) { +func (m *ACLChange_ReadKeyReplace) Reset() { *m = ACLChange_ReadKeyReplace{} } +func (m *ACLChange_ReadKeyReplace) String() string { return proto.CompactTextString(m) } +func (*ACLChange_ReadKeyReplace) ProtoMessage() {} +func (*ACLChange_ReadKeyReplace) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 10} } -func (m *ACLChangeReadKeyReplace) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_ReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_ReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeReadKeyReplace.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_ReadKeyReplace.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -938,56 +939,56 @@ func (m *ACLChangeReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *ACLChangeReadKeyReplace) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeReadKeyReplace.Merge(m, src) +func (m *ACLChange_ReadKeyReplace) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_ReadKeyReplace.Merge(m, src) } -func (m *ACLChangeReadKeyReplace) XXX_Size() int { +func (m *ACLChange_ReadKeyReplace) XXX_Size() int { return m.Size() } -func (m *ACLChangeReadKeyReplace) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeReadKeyReplace.DiscardUnknown(m) +func (m *ACLChange_ReadKeyReplace) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_ReadKeyReplace.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeReadKeyReplace proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_ReadKeyReplace proto.InternalMessageInfo -func (m *ACLChangeReadKeyReplace) GetIdentity() string { +func (m *ACLChange_ReadKeyReplace) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeReadKeyReplace) GetEncryptionKey() []byte { +func (m *ACLChange_ReadKeyReplace) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeReadKeyReplace) GetEncryptedReadKey() []byte { +func (m *ACLChange_ReadKeyReplace) GetEncryptedReadKey() []byte { if m != nil { return m.EncryptedReadKey } return nil } -type ACLChangeUserPermissionChange struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` +type ACLChange_UserPermissionChange struct { + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Permissions ACLChange_UserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLChange_UserPermissions" json:"permissions,omitempty"` } -func (m *ACLChangeUserPermissionChange) Reset() { *m = ACLChangeUserPermissionChange{} } -func (m *ACLChangeUserPermissionChange) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserPermissionChange) ProtoMessage() {} -func (*ACLChangeUserPermissionChange) Descriptor() ([]byte, []int) { +func (m *ACLChange_UserPermissionChange) Reset() { *m = ACLChange_UserPermissionChange{} } +func (m *ACLChange_UserPermissionChange) String() string { return proto.CompactTextString(m) } +func (*ACLChange_UserPermissionChange) ProtoMessage() {} +func (*ACLChange_UserPermissionChange) Descriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{1, 11} } -func (m *ACLChangeUserPermissionChange) XXX_Unmarshal(b []byte) error { +func (m *ACLChange_UserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserPermissionChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLChange_UserPermissionChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserPermissionChange.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLChange_UserPermissionChange.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -997,26 +998,26 @@ func (m *ACLChangeUserPermissionChange) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *ACLChangeUserPermissionChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserPermissionChange.Merge(m, src) +func (m *ACLChange_UserPermissionChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLChange_UserPermissionChange.Merge(m, src) } -func (m *ACLChangeUserPermissionChange) XXX_Size() int { +func (m *ACLChange_UserPermissionChange) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserPermissionChange) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserPermissionChange.DiscardUnknown(m) +func (m *ACLChange_UserPermissionChange) XXX_DiscardUnknown() { + xxx_messageInfo_ACLChange_UserPermissionChange.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserPermissionChange proto.InternalMessageInfo +var xxx_messageInfo_ACLChange_UserPermissionChange proto.InternalMessageInfo -func (m *ACLChangeUserPermissionChange) GetIdentity() string { +func (m *ACLChange_UserPermissionChange) GetIdentity() string { if m != nil { return m.Identity } return "" } -func (m *ACLChangeUserPermissionChange) GetPermissions() ACLChangeUserPermissions { +func (m *ACLChange_UserPermissionChange) GetPermissions() ACLChange_UserPermissions { if m != nil { return m.Permissions } @@ -1024,22 +1025,22 @@ func (m *ACLChangeUserPermissionChange) GetPermissions() ACLChangeUserPermission } func init() { - proto.RegisterEnum("acl.ACLChangeUserPermissions", ACLChangeUserPermissions_name, ACLChangeUserPermissions_value) + proto.RegisterEnum("acl.ACLChange_UserPermissions", ACLChange_UserPermissions_name, ACLChange_UserPermissions_value) proto.RegisterType((*RawChange)(nil), "acl.RawChange") proto.RegisterType((*ACLChange)(nil), "acl.ACLChange") - proto.RegisterType((*ACLChangeACLContentValue)(nil), "acl.ACLChange.ACLContentValue") - proto.RegisterType((*ACLChangeACLData)(nil), "acl.ACLChange.ACLData") - proto.RegisterType((*ACLChangeACLSnapshot)(nil), "acl.ACLChange.ACLSnapshot") - proto.RegisterType((*ACLChangeACLState)(nil), "acl.ACLChange.ACLState") - proto.RegisterMapType((map[string]*ACLChangeUserInvite)(nil), "acl.ACLChange.ACLState.InvitesEntry") - proto.RegisterType((*ACLChangeUserState)(nil), "acl.ACLChange.UserState") - proto.RegisterType((*ACLChangeUserAdd)(nil), "acl.ACLChange.UserAdd") - proto.RegisterType((*ACLChangeUserConfirm)(nil), "acl.ACLChange.UserConfirm") - proto.RegisterType((*ACLChangeUserInvite)(nil), "acl.ACLChange.UserInvite") - proto.RegisterType((*ACLChangeUserJoin)(nil), "acl.ACLChange.UserJoin") - proto.RegisterType((*ACLChangeUserRemove)(nil), "acl.ACLChange.UserRemove") - proto.RegisterType((*ACLChangeReadKeyReplace)(nil), "acl.ACLChange.ReadKeyReplace") - proto.RegisterType((*ACLChangeUserPermissionChange)(nil), "acl.ACLChange.UserPermissionChange") + proto.RegisterType((*ACLChange_ACLContentValue)(nil), "acl.ACLChange.ACLContentValue") + proto.RegisterType((*ACLChange_ACLData)(nil), "acl.ACLChange.ACLData") + proto.RegisterType((*ACLChange_ACLSnapshot)(nil), "acl.ACLChange.ACLSnapshot") + proto.RegisterType((*ACLChange_ACLState)(nil), "acl.ACLChange.ACLState") + proto.RegisterMapType((map[string]*ACLChange_UserInvite)(nil), "acl.ACLChange.ACLState.InvitesEntry") + proto.RegisterType((*ACLChange_UserState)(nil), "acl.ACLChange.UserState") + proto.RegisterType((*ACLChange_UserAdd)(nil), "acl.ACLChange.UserAdd") + proto.RegisterType((*ACLChange_UserConfirm)(nil), "acl.ACLChange.UserConfirm") + proto.RegisterType((*ACLChange_UserInvite)(nil), "acl.ACLChange.UserInvite") + proto.RegisterType((*ACLChange_UserJoin)(nil), "acl.ACLChange.UserJoin") + proto.RegisterType((*ACLChange_UserRemove)(nil), "acl.ACLChange.UserRemove") + proto.RegisterType((*ACLChange_ReadKeyReplace)(nil), "acl.ACLChange.ReadKeyReplace") + proto.RegisterType((*ACLChange_UserPermissionChange)(nil), "acl.ACLChange.UserPermissionChange") } func init() { @@ -1238,7 +1239,7 @@ func (m *ACLChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValue) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_ACLContentValue) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1248,12 +1249,12 @@ func (m *ACLChangeACLContentValue) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLContentValue) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1270,12 +1271,12 @@ func (m *ACLChangeACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserAdd != nil { { @@ -1291,12 +1292,12 @@ func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalToSizedBuffer(dAtA []byt } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserRemove) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserRemove != nil { { @@ -1312,12 +1313,12 @@ func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalToSizedBuffer(dAtA [] } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserPermissionChange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserPermissionChange != nil { { @@ -1333,12 +1334,12 @@ func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalToSizedBuff } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserInvite) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserInvite != nil { { @@ -1354,12 +1355,12 @@ func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalToSizedBuffer(dAtA [] } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserJoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserJoin != nil { { @@ -1375,12 +1376,12 @@ func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserConfirm) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContent_Value_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserConfirm != nil { { @@ -1396,7 +1397,7 @@ func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalToSizedBuffer(dAtA [ } return len(dAtA) - i, nil } -func (m *ACLChangeACLData) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_ACLData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1406,12 +1407,12 @@ func (m *ACLChangeACLData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLData) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1445,7 +1446,7 @@ func (m *ACLChangeACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeACLSnapshot) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_ACLSnapshot) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1455,12 +1456,12 @@ func (m *ACLChangeACLSnapshot) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLSnapshot) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLSnapshot) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1480,7 +1481,7 @@ func (m *ACLChangeACLSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeACLState) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_ACLState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1490,12 +1491,12 @@ func (m *ACLChangeACLState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLState) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1561,7 +1562,7 @@ func (m *ACLChangeACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserState) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1571,12 +1572,12 @@ func (m *ACLChangeUserState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserState) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1622,7 +1623,7 @@ func (m *ACLChangeUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserAdd) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserAdd) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1632,12 +1633,12 @@ func (m *ACLChangeUserAdd) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserAdd) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1673,7 +1674,7 @@ func (m *ACLChangeUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserConfirm) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserConfirm) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1683,12 +1684,12 @@ func (m *ACLChangeUserConfirm) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserConfirm) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserConfirm) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1710,7 +1711,7 @@ func (m *ACLChangeUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserInvite) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserInvite) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1720,12 +1721,12 @@ func (m *ACLChangeUserInvite) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserInvite) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserInvite) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1768,7 +1769,7 @@ func (m *ACLChangeUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserJoin) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserJoin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1778,12 +1779,12 @@ func (m *ACLChangeUserJoin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserJoin) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserJoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1828,7 +1829,7 @@ func (m *ACLChangeUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserRemove) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserRemove) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1838,12 +1839,12 @@ func (m *ACLChangeUserRemove) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserRemove) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserRemove) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1872,7 +1873,7 @@ func (m *ACLChangeUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeReadKeyReplace) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_ReadKeyReplace) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1882,12 +1883,12 @@ func (m *ACLChangeReadKeyReplace) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeReadKeyReplace) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ReadKeyReplace) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1916,7 +1917,7 @@ func (m *ACLChangeReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *ACLChangeUserPermissionChange) Marshal() (dAtA []byte, err error) { +func (m *ACLChange_UserPermissionChange) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1926,12 +1927,12 @@ func (m *ACLChangeUserPermissionChange) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserPermissionChange) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_UserPermissionChange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2026,7 +2027,7 @@ func (m *ACLChange) Size() (n int) { return n } -func (m *ACLChangeACLContentValue) Size() (n int) { +func (m *ACLChange_ACLContentValue) Size() (n int) { if m == nil { return 0 } @@ -2038,7 +2039,7 @@ func (m *ACLChangeACLContentValue) Size() (n int) { return n } -func (m *ACLChangeACLContentValueValueOfUserAdd) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserAdd) Size() (n int) { if m == nil { return 0 } @@ -2050,7 +2051,7 @@ func (m *ACLChangeACLContentValueValueOfUserAdd) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserRemove) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserRemove) Size() (n int) { if m == nil { return 0 } @@ -2062,7 +2063,7 @@ func (m *ACLChangeACLContentValueValueOfUserRemove) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserPermissionChange) Size() (n int) { if m == nil { return 0 } @@ -2074,7 +2075,7 @@ func (m *ACLChangeACLContentValueValueOfUserPermissionChange) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserInvite) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserInvite) Size() (n int) { if m == nil { return 0 } @@ -2086,7 +2087,7 @@ func (m *ACLChangeACLContentValueValueOfUserInvite) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserJoin) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserJoin) Size() (n int) { if m == nil { return 0 } @@ -2098,7 +2099,7 @@ func (m *ACLChangeACLContentValueValueOfUserJoin) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserConfirm) Size() (n int) { +func (m *ACLChange_ACLContent_Value_UserConfirm) Size() (n int) { if m == nil { return 0 } @@ -2110,7 +2111,7 @@ func (m *ACLChangeACLContentValueValueOfUserConfirm) Size() (n int) { } return n } -func (m *ACLChangeACLData) Size() (n int) { +func (m *ACLChange_ACLData) Size() (n int) { if m == nil { return 0 } @@ -2129,7 +2130,7 @@ func (m *ACLChangeACLData) Size() (n int) { return n } -func (m *ACLChangeACLSnapshot) Size() (n int) { +func (m *ACLChange_ACLSnapshot) Size() (n int) { if m == nil { return 0 } @@ -2142,7 +2143,7 @@ func (m *ACLChangeACLSnapshot) Size() (n int) { return n } -func (m *ACLChangeACLState) Size() (n int) { +func (m *ACLChange_ACLState) Size() (n int) { if m == nil { return 0 } @@ -2177,7 +2178,7 @@ func (m *ACLChangeACLState) Size() (n int) { return n } -func (m *ACLChangeUserState) Size() (n int) { +func (m *ACLChange_UserState) Size() (n int) { if m == nil { return 0 } @@ -2206,7 +2207,7 @@ func (m *ACLChangeUserState) Size() (n int) { return n } -func (m *ACLChangeUserAdd) Size() (n int) { +func (m *ACLChange_UserAdd) Size() (n int) { if m == nil { return 0 } @@ -2232,7 +2233,7 @@ func (m *ACLChangeUserAdd) Size() (n int) { return n } -func (m *ACLChangeUserConfirm) Size() (n int) { +func (m *ACLChange_UserConfirm) Size() (n int) { if m == nil { return 0 } @@ -2249,7 +2250,7 @@ func (m *ACLChangeUserConfirm) Size() (n int) { return n } -func (m *ACLChangeUserInvite) Size() (n int) { +func (m *ACLChange_UserInvite) Size() (n int) { if m == nil { return 0 } @@ -2279,7 +2280,7 @@ func (m *ACLChangeUserInvite) Size() (n int) { return n } -func (m *ACLChangeUserJoin) Size() (n int) { +func (m *ACLChange_UserJoin) Size() (n int) { if m == nil { return 0 } @@ -2310,7 +2311,7 @@ func (m *ACLChangeUserJoin) Size() (n int) { return n } -func (m *ACLChangeUserRemove) Size() (n int) { +func (m *ACLChange_UserRemove) Size() (n int) { if m == nil { return 0 } @@ -2329,7 +2330,7 @@ func (m *ACLChangeUserRemove) Size() (n int) { return n } -func (m *ACLChangeReadKeyReplace) Size() (n int) { +func (m *ACLChange_ReadKeyReplace) Size() (n int) { if m == nil { return 0 } @@ -2350,7 +2351,7 @@ func (m *ACLChangeReadKeyReplace) Size() (n int) { return n } -func (m *ACLChangeUserPermissionChange) Size() (n int) { +func (m *ACLChange_UserPermissionChange) Size() (n int) { if m == nil { return 0 } @@ -2677,7 +2678,7 @@ func (m *ACLChange) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AclData == nil { - m.AclData = &ACLChangeACLData{} + m.AclData = &ACLChange_ACLData{} } if err := m.AclData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2808,7 +2809,7 @@ func (m *ACLChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { +func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2866,11 +2867,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserAdd{} + v := &ACLChange_UserAdd{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserAdd{v} + m.Value = &ACLChange_ACLContent_Value_UserAdd{v} iNdEx = postIndex case 2: if wireType != 2 { @@ -2901,11 +2902,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserRemove{} + v := &ACLChange_UserRemove{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserRemove{v} + m.Value = &ACLChange_ACLContent_Value_UserRemove{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -2936,11 +2937,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserPermissionChange{} + v := &ACLChange_UserPermissionChange{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserPermissionChange{v} + m.Value = &ACLChange_ACLContent_Value_UserPermissionChange{v} iNdEx = postIndex case 4: if wireType != 2 { @@ -2971,11 +2972,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserInvite{} + v := &ACLChange_UserInvite{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserInvite{v} + m.Value = &ACLChange_ACLContent_Value_UserInvite{v} iNdEx = postIndex case 5: if wireType != 2 { @@ -3006,11 +3007,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserJoin{} + v := &ACLChange_UserJoin{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserJoin{v} + m.Value = &ACLChange_ACLContent_Value_UserJoin{v} iNdEx = postIndex case 6: if wireType != 2 { @@ -3041,11 +3042,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserConfirm{} + v := &ACLChange_UserConfirm{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserConfirm{v} + m.Value = &ACLChange_ACLContent_Value_UserConfirm{v} iNdEx = postIndex default: iNdEx = preIndex @@ -3068,7 +3069,7 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { +func (m *ACLChange_ACLData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3127,7 +3128,7 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AclSnapshot == nil { - m.AclSnapshot = &ACLChangeACLSnapshot{} + m.AclSnapshot = &ACLChange_ACLSnapshot{} } if err := m.AclSnapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3162,7 +3163,7 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AclContent = append(m.AclContent, &ACLChangeACLContentValue{}) + m.AclContent = append(m.AclContent, &ACLChange_ACLContentValue{}) if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3188,7 +3189,7 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLSnapshot) Unmarshal(dAtA []byte) error { +func (m *ACLChange_ACLSnapshot) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3247,7 +3248,7 @@ func (m *ACLChangeACLSnapshot) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.AclState == nil { - m.AclState = &ACLChangeACLState{} + m.AclState = &ACLChange_ACLState{} } if err := m.AclState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -3274,7 +3275,7 @@ func (m *ACLChangeACLSnapshot) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { +func (m *ACLChange_ACLState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3408,7 +3409,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UserStates = append(m.UserStates, &ACLChangeUserState{}) + m.UserStates = append(m.UserStates, &ACLChange_UserState{}) if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3443,10 +3444,10 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Invites == nil { - m.Invites = make(map[string]*ACLChangeUserInvite) + m.Invites = make(map[string]*ACLChange_UserInvite) } var mapkey string - var mapvalue *ACLChangeUserInvite + var mapvalue *ACLChange_UserInvite for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -3520,7 +3521,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &ACLChangeUserInvite{} + mapvalue = &ACLChange_UserInvite{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -3563,7 +3564,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3704,7 +3705,7 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLChange_UserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -3750,7 +3751,7 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserAdd) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3891,7 +3892,7 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLChange_UserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -3917,7 +3918,7 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserConfirm) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4031,7 +4032,7 @@ func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserInvite) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4174,7 +4175,7 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLChange_UserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -4232,7 +4233,7 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserJoin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4446,7 +4447,7 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserRemove) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4536,7 +4537,7 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLChangeReadKeyReplace{}) + m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLChange_ReadKeyReplace{}) if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4562,7 +4563,7 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { +func (m *ACLChange_ReadKeyReplace) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4712,7 +4713,7 @@ func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { +func (m *ACLChange_UserPermissionChange) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4787,7 +4788,7 @@ func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLChange_UserPermissions(b&0x7F) << shift if b < 0x80 { break } diff --git a/pkg/acl/acltree/aclstate.go b/pkg/acl/acltree/aclstate.go index a7443f69..d28d59b2 100644 --- a/pkg/acl/acltree/aclstate.go +++ b/pkg/acl/acltree/aclstate.go @@ -20,8 +20,8 @@ var ErrUserAlreadyExists = errors.New("user already exists") type ACLState struct { currentReadKeyHash uint64 userReadKeys map[uint64]*symmetric.Key - userStates map[string]*aclpb.ACLChangeUserState - userInvites map[string]*aclpb.ACLChangeUserInvite + userStates map[string]*aclpb.ACLChange_UserState + userInvites map[string]*aclpb.ACLChange_UserInvite signingPubKeyDecoder signingkey.PubKeyDecoder encryptionKey encryptionkey.PrivKey identity string @@ -35,8 +35,8 @@ func newACLState( identity: identity, encryptionKey: encryptionKey, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLChangeUserState), - userInvites: make(map[string]*aclpb.ACLChangeUserInvite), + userStates: make(map[string]*aclpb.ACLChange_UserState), + userInvites: make(map[string]*aclpb.ACLChange_UserInvite), signingPubKeyDecoder: signingPubKeyDecoder, } } @@ -50,8 +50,8 @@ func newACLStateFromSnapshotChange( identity: identity, encryptionKey: encryptionKey, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLChangeUserState), - userInvites: make(map[string]*aclpb.ACLChangeUserInvite), + userStates: make(map[string]*aclpb.ACLChange_UserState), + userInvites: make(map[string]*aclpb.ACLChange_UserInvite), signingPubKeyDecoder: signingPubKeyDecoder, } err := st.recreateFromSnapshotChange(snapshotChange) @@ -90,13 +90,13 @@ func (st *ACLState) recreateFromSnapshotChange(snapshotChange *aclpb.ACLChange) return nil } -func (st *ACLState) makeSnapshot() *aclpb.ACLChangeACLSnapshot { - var userStates []*aclpb.ACLChangeUserState +func (st *ACLState) makeSnapshot() *aclpb.ACLChange_ACLSnapshot { + var userStates []*aclpb.ACLChange_UserState for _, st := range st.userStates { userStates = append(userStates, st) } - return &aclpb.ACLChangeACLSnapshot{AclState: &aclpb.ACLChangeACLState{ + return &aclpb.ACLChange_ACLSnapshot{AclState: &aclpb.ACLChange_ACLState{ ReadKeyHashes: nil, UserStates: userStates, // TODO: make states and invites in same format Invites: st.userInvites, @@ -138,7 +138,7 @@ func (st *ACLState) applyChange(change *aclpb.ACLChange) (err error) { } // TODO: remove changeId, because it is not needed -func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error { +func (st *ACLState) applyChangeContent(ch *aclpb.ACLChange_ACLContentValue) error { switch { case ch.GetUserPermissionChange() != nil: return st.applyUserPermissionChange(ch.GetUserPermissionChange()) @@ -157,7 +157,7 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error } } -func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChangeUserPermissionChange) error { +func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChange_UserPermissionChange) error { if _, exists := st.userStates[ch.Identity]; !exists { return ErrNoSuchUser } @@ -166,12 +166,12 @@ func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChangeUserPermissionC return nil } -func (st *ACLState) applyUserInvite(ch *aclpb.ACLChangeUserInvite) error { +func (st *ACLState) applyUserInvite(ch *aclpb.ACLChange_UserInvite) error { st.userInvites[ch.InviteId] = ch return nil } -func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { +func (st *ACLState) applyUserJoin(ch *aclpb.ACLChange_UserJoin) error { invite, exists := st.userInvites[ch.UserInviteId] if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) @@ -214,7 +214,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { } // adding user to the list - userState := &aclpb.ACLChangeUserState{ + userState := &aclpb.ACLChange_UserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, EncryptedReadKeys: ch.EncryptedReadKeys, @@ -225,12 +225,12 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { return nil } -func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error { +func (st *ACLState) applyUserAdd(ch *aclpb.ACLChange_UserAdd) error { if _, exists := st.userStates[ch.Identity]; exists { return ErrUserAlreadyExists } - st.userStates[ch.Identity] = &aclpb.ACLChangeUserState{ + st.userStates[ch.Identity] = &aclpb.ACLChange_UserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, @@ -251,7 +251,7 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error { return nil } -func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error { +func (st *ACLState) applyUserRemove(ch *aclpb.ACLChange_UserRemove) error { if ch.Identity == st.identity { return ErrDocumentForbidden } @@ -283,7 +283,7 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error { return nil } -func (st *ACLState) applyUserConfirm(ch *aclpb.ACLChangeUserConfirm) error { +func (st *ACLState) applyUserConfirm(ch *aclpb.ACLChange_UserConfirm) error { if _, exists := st.userStates[ch.Identity]; !exists { return ErrNoSuchUser } @@ -309,7 +309,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChangeUserPermissions) bool { +func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChange_UserPermissions) bool { state, exists := st.userStates[identity] if !exists { return false @@ -329,7 +329,7 @@ func (st *ACLState) isUserAdd(ch *aclpb.ACLChange) bool { return ch.AclData.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == ch.Identity } -func (st *ACLState) getPermissionDecreasedUsers(ch *aclpb.ACLChange) (identities []*aclpb.ACLChangeUserPermissionChange) { +func (st *ACLState) getPermissionDecreasedUsers(ch *aclpb.ACLChange) (identities []*aclpb.ACLChange_UserPermissionChange) { // this should be called after general checks are completed if ch.GetAclData().GetAclContent() == nil { return nil @@ -343,7 +343,7 @@ func (st *ACLState) getPermissionDecreasedUsers(ch *aclpb.ACLChange) (identities currentState := st.userStates[content.Identity] // the comparison works in different direction :-) if content.Permissions > currentState.Permissions { - identities = append(identities, &aclpb.ACLChangeUserPermissionChange{ + identities = append(identities, &aclpb.ACLChange_UserPermissionChange{ Identity: content.Identity, Permissions: content.Permissions, }) @@ -351,7 +351,7 @@ func (st *ACLState) getPermissionDecreasedUsers(ch *aclpb.ACLChange) (identities } if c.GetUserRemove() != nil { content := c.GetUserRemove() - identities = append(identities, &aclpb.ACLChangeUserPermissionChange{ + identities = append(identities, &aclpb.ACLChange_UserPermissionChange{ Identity: content.Identity, Permissions: aclpb.ACLChange_Removed, }) @@ -405,7 +405,7 @@ func (st *ACLState) equal(other *ACLState) bool { return true } -func (st *ACLState) GetUserStates() map[string]*aclpb.ACLChangeUserState { +func (st *ACLState) GetUserStates() map[string]*aclpb.ACLChange_UserState { // TODO: we should provide better API that would not allow to change this map from the outside return st.userStates } diff --git a/pkg/acl/acltree/aclstatebuilder.go b/pkg/acl/acltree/aclstatebuilder.go index d63d535c..8528f9cf 100644 --- a/pkg/acl/acltree/aclstatebuilder.go +++ b/pkg/acl/acltree/aclstatebuilder.go @@ -16,7 +16,7 @@ type aclStateBuilder struct { } type decreasedPermissionsParameters struct { - users []*aclpb.ACLChangeUserPermissionChange + users []*aclpb.ACLChange_UserPermissionChange startChange string } diff --git a/pkg/acl/acltree/change.go b/pkg/acl/acltree/change.go index c768ef23..a615dfa9 100644 --- a/pkg/acl/acltree/change.go +++ b/pkg/acl/acltree/change.go @@ -10,7 +10,7 @@ import ( type ChangeContent struct { ChangesData proto.Marshaler - ACLData *aclpb.ACLChangeACLData + ACLData *aclpb.ACLChange_ACLData Id string // TODO: this is just for testing, because id should be created automatically from content } diff --git a/pkg/acl/acltree/changebuilder.go b/pkg/acl/acltree/changebuilder.go index b5b26b63..5bfb145f 100644 --- a/pkg/acl/acltree/changebuilder.go +++ b/pkg/acl/acltree/changebuilder.go @@ -14,7 +14,7 @@ import ( type MarshalledChange = []byte type ACLChangeBuilder interface { - UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error + UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChange_UserPermissions) error AddId(id string) // TODO: this is only for testing SetMakeSnapshot(bool) // TODO: who should decide this? probably ACLTree so we can delete it } @@ -29,7 +29,7 @@ type changeBuilder struct { tree *Tree acc *account.AccountData - aclData *aclpb.ACLChangeACLData + aclData *aclpb.ACLChange_ACLData changeContent proto.Marshaler id string makeSnapshot bool @@ -46,7 +46,7 @@ func (c *changeBuilder) Init(state *ACLState, tree *Tree, acc *account.AccountDa c.tree = tree c.acc = acc - c.aclData = &aclpb.ACLChangeACLData{} + c.aclData = &aclpb.ACLChange_ACLData{} // setting read key for further encryption etc if state.currentReadKeyHash == 0 { c.readKey, _ = symmetric.NewRandom() @@ -68,7 +68,7 @@ func (c *changeBuilder) SetMakeSnapshot(b bool) { c.makeSnapshot = b } -func (c *changeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error { +func (c *changeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChange_UserPermissions) error { var allKeys []*symmetric.Key if c.aclState.currentReadKeyHash != 0 { for _, key := range c.aclState.userReadKeys { @@ -91,9 +91,9 @@ func (c *changeBuilder) UserAdd(identity string, encryptionKey encryptionkey.Pub if err != nil { return err } - ch := &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{ - UserAdd: &aclpb.ACLChangeUserAdd{ + ch := &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContent_Value_UserAdd{ + UserAdd: &aclpb.ACLChange_UserAdd{ Identity: identity, EncryptionKey: rawKey, EncryptedReadKeys: encryptedKeys, diff --git a/pkg/acl/acltree/treegraph_nix.go b/pkg/acl/acltree/treegraph_nix.go index 4d798939..72dc0c7d 100644 --- a/pkg/acl/acltree/treegraph_nix.go +++ b/pkg/acl/acltree/treegraph_nix.go @@ -60,7 +60,7 @@ func (t *Tree) Graph() (data string, err error) { if c.Content.AclData != nil { for _, chc := range c.Content.AclData.AclContent { tp := fmt.Sprintf("%T", chc.Value) - tp = strings.Replace(tp, "ACLChangeACLContentValueValueOf", "", 1) + tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1) res := "" for _, ts := range tp { if unicode.IsUpper(ts) { @@ -74,7 +74,7 @@ func (t *Tree) Graph() (data string, err error) { // TODO: add some parser to provide custom unmarshalling for the document change //for _, chc := range c.DecryptedDocumentChange.Content { // tp := fmt.Sprintf("%T", chc.Value) - // tp = strings.Replace(tp, "ChangeContentValueOf", "", 1) + // tp = strings.Replace(tp, "ChangeContent_Value_", "", 1) // res := "" // for _, ts := range tp { // if unicode.IsUpper(ts) { diff --git a/pkg/acl/example/plaintextdocument/document.go b/pkg/acl/example/plaintextdocument/document.go index d97bf430..2c66b5b1 100644 --- a/pkg/acl/example/plaintextdocument/document.go +++ b/pkg/acl/example/plaintextdocument/document.go @@ -34,8 +34,8 @@ func (p *plainTextDocument) Text() string { func (p *plainTextDocument) AddText(ctx context.Context, text string) error { _, err := p.aclTree.AddContent(ctx, func(builder acltree.ChangeBuilder) error { builder.AddChangeContent( - &testchangepb.PlainTextChangeData{ - Content: []*testchangepb.PlainTextChangeContent{ + &testchangepb.PlainTextChange_Data{ + Content: []*testchangepb.PlainTextChange_Content{ createAppendTextChangeContent(text), }, }) @@ -150,18 +150,18 @@ func NewPlainTextDocument( } func createInitialChangeContent(text string) proto.Marshaler { - return &testchangepb.PlainTextChangeData{ - Content: []*testchangepb.PlainTextChangeContent{ + return &testchangepb.PlainTextChange_Data{ + Content: []*testchangepb.PlainTextChange_Content{ createAppendTextChangeContent(text), }, - Snapshot: &testchangepb.PlainTextChangeSnapshot{Text: text}, + Snapshot: &testchangepb.PlainTextChange_Snapshot{Text: text}, } } -func createAppendTextChangeContent(text string) *testchangepb.PlainTextChangeContent { - return &testchangepb.PlainTextChangeContent{ - Value: &testchangepb.PlainTextChangeContentValueOfTextAppend{ - TextAppend: &testchangepb.PlainTextChangeTextAppend{ +func createAppendTextChangeContent(text string) *testchangepb.PlainTextChange_Content { + return &testchangepb.PlainTextChange_Content{ + Value: &testchangepb.PlainTextChange_Content_TextAppend{ + TextAppend: &testchangepb.PlainTextChange_TextAppend{ Text: text, }, }, diff --git a/pkg/acl/example/plaintextdocument/plaintextdocstate.go b/pkg/acl/example/plaintextdocument/plaintextdocstate.go index 3a3afec3..22ac1e4d 100644 --- a/pkg/acl/example/plaintextdocument/plaintextdocstate.go +++ b/pkg/acl/example/plaintextdocument/plaintextdocstate.go @@ -20,7 +20,7 @@ func NewDocumentState(text string, id string) *DocumentState { } func BuildDocumentStateFromChange(change []byte, id string) (*DocumentState, error) { - var changesData testchangepb.PlainTextChangeData + var changesData testchangepb.PlainTextChange_Data err := proto.Unmarshal(change, &changesData) if err != nil { return nil, err @@ -33,7 +33,7 @@ func BuildDocumentStateFromChange(change []byte, id string) (*DocumentState, err } func (p *DocumentState) ApplyChange(change []byte, id string) (*DocumentState, error) { - var changesData testchangepb.PlainTextChangeData + var changesData testchangepb.PlainTextChange_Data err := proto.Unmarshal(change, &changesData) if err != nil { return nil, err @@ -49,7 +49,7 @@ func (p *DocumentState) ApplyChange(change []byte, id string) (*DocumentState, e return p, nil } -func (p *DocumentState) applyChange(ch *testchangepb.PlainTextChangeContent) error { +func (p *DocumentState) applyChange(ch *testchangepb.PlainTextChange_Content) error { switch { case ch.GetTextAppend() != nil: text := ch.GetTextAppend().GetText() diff --git a/pkg/acl/testutils/testchanges/testchangepb/testdocumentchanges.pb.go b/pkg/acl/testutils/testchanges/testchangepb/testdocumentchanges.pb.go index 874061c6..cfec475b 100644 --- a/pkg/acl/testutils/testchanges/testchangepb/testdocumentchanges.pb.go +++ b/pkg/acl/testutils/testchanges/testchangepb/testdocumentchanges.pb.go @@ -58,24 +58,25 @@ func (m *PlainTextChange) XXX_DiscardUnknown() { var xxx_messageInfo_PlainTextChange proto.InternalMessageInfo -type PlainTextChangeContent struct { +type PlainTextChange_Content struct { // Types that are valid to be assigned to Value: - // *PlainTextChangeContentValueOfTextAppend - Value IsPlainTextChangeContentValue `protobuf_oneof:"value"` + // + // *PlainTextChange_Content_TextAppend + Value isPlainTextChange_Content_Value `protobuf_oneof:"value"` } -func (m *PlainTextChangeContent) Reset() { *m = PlainTextChangeContent{} } -func (m *PlainTextChangeContent) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeContent) ProtoMessage() {} -func (*PlainTextChangeContent) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Content) Reset() { *m = PlainTextChange_Content{} } +func (m *PlainTextChange_Content) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Content) ProtoMessage() {} +func (*PlainTextChange_Content) Descriptor() ([]byte, []int) { return fileDescriptor_c07268f9f08f2beb, []int{0, 0} } -func (m *PlainTextChangeContent) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Content) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeContent.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Content.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -85,67 +86,67 @@ func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *PlainTextChangeContent) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeContent.Merge(m, src) +func (m *PlainTextChange_Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Content.Merge(m, src) } -func (m *PlainTextChangeContent) XXX_Size() int { +func (m *PlainTextChange_Content) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeContent) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeContent.DiscardUnknown(m) +func (m *PlainTextChange_Content) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Content.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeContent proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Content proto.InternalMessageInfo -type IsPlainTextChangeContentValue interface { - IsPlainTextChangeContentValue() +type isPlainTextChange_Content_Value interface { + isPlainTextChange_Content_Value() MarshalTo([]byte) (int, error) Size() int } -type PlainTextChangeContentValueOfTextAppend struct { - TextAppend *PlainTextChangeTextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"` +type PlainTextChange_Content_TextAppend struct { + TextAppend *PlainTextChange_TextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"` } -func (*PlainTextChangeContentValueOfTextAppend) IsPlainTextChangeContentValue() {} +func (*PlainTextChange_Content_TextAppend) isPlainTextChange_Content_Value() {} -func (m *PlainTextChangeContent) GetValue() IsPlainTextChangeContentValue { +func (m *PlainTextChange_Content) GetValue() isPlainTextChange_Content_Value { if m != nil { return m.Value } return nil } -func (m *PlainTextChangeContent) GetTextAppend() *PlainTextChangeTextAppend { - if x, ok := m.GetValue().(*PlainTextChangeContentValueOfTextAppend); ok { +func (m *PlainTextChange_Content) GetTextAppend() *PlainTextChange_TextAppend { + if x, ok := m.GetValue().(*PlainTextChange_Content_TextAppend); ok { return x.TextAppend } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*PlainTextChangeContent) XXX_OneofWrappers() []interface{} { +func (*PlainTextChange_Content) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*PlainTextChangeContentValueOfTextAppend)(nil), + (*PlainTextChange_Content_TextAppend)(nil), } } -type PlainTextChangeTextAppend struct { +type PlainTextChange_TextAppend struct { Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` } -func (m *PlainTextChangeTextAppend) Reset() { *m = PlainTextChangeTextAppend{} } -func (m *PlainTextChangeTextAppend) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeTextAppend) ProtoMessage() {} -func (*PlainTextChangeTextAppend) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_TextAppend) Reset() { *m = PlainTextChange_TextAppend{} } +func (m *PlainTextChange_TextAppend) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_TextAppend) ProtoMessage() {} +func (*PlainTextChange_TextAppend) Descriptor() ([]byte, []int) { return fileDescriptor_c07268f9f08f2beb, []int{0, 1} } -func (m *PlainTextChangeTextAppend) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_TextAppend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_TextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeTextAppend.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_TextAppend.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -155,41 +156,41 @@ func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *PlainTextChangeTextAppend) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeTextAppend.Merge(m, src) +func (m *PlainTextChange_TextAppend) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_TextAppend.Merge(m, src) } -func (m *PlainTextChangeTextAppend) XXX_Size() int { +func (m *PlainTextChange_TextAppend) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeTextAppend) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeTextAppend.DiscardUnknown(m) +func (m *PlainTextChange_TextAppend) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_TextAppend.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeTextAppend proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_TextAppend proto.InternalMessageInfo -func (m *PlainTextChangeTextAppend) GetText() string { +func (m *PlainTextChange_TextAppend) GetText() string { if m != nil { return m.Text } return "" } -type PlainTextChangeSnapshot struct { +type PlainTextChange_Snapshot struct { Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` } -func (m *PlainTextChangeSnapshot) Reset() { *m = PlainTextChangeSnapshot{} } -func (m *PlainTextChangeSnapshot) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeSnapshot) ProtoMessage() {} -func (*PlainTextChangeSnapshot) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Snapshot) Reset() { *m = PlainTextChange_Snapshot{} } +func (m *PlainTextChange_Snapshot) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Snapshot) ProtoMessage() {} +func (*PlainTextChange_Snapshot) Descriptor() ([]byte, []int) { return fileDescriptor_c07268f9f08f2beb, []int{0, 2} } -func (m *PlainTextChangeSnapshot) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Snapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeSnapshot.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Snapshot.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -199,42 +200,42 @@ func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *PlainTextChangeSnapshot) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeSnapshot.Merge(m, src) +func (m *PlainTextChange_Snapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Snapshot.Merge(m, src) } -func (m *PlainTextChangeSnapshot) XXX_Size() int { +func (m *PlainTextChange_Snapshot) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeSnapshot) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeSnapshot.DiscardUnknown(m) +func (m *PlainTextChange_Snapshot) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Snapshot.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeSnapshot proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Snapshot proto.InternalMessageInfo -func (m *PlainTextChangeSnapshot) GetText() string { +func (m *PlainTextChange_Snapshot) GetText() string { if m != nil { return m.Text } return "" } -type PlainTextChangeData struct { - Content []*PlainTextChangeContent `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` - Snapshot *PlainTextChangeSnapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` +type PlainTextChange_Data struct { + Content []*PlainTextChange_Content `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` + Snapshot *PlainTextChange_Snapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` } -func (m *PlainTextChangeData) Reset() { *m = PlainTextChangeData{} } -func (m *PlainTextChangeData) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeData) ProtoMessage() {} -func (*PlainTextChangeData) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Data) Reset() { *m = PlainTextChange_Data{} } +func (m *PlainTextChange_Data) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Data) ProtoMessage() {} +func (*PlainTextChange_Data) Descriptor() ([]byte, []int) { return fileDescriptor_c07268f9f08f2beb, []int{0, 3} } -func (m *PlainTextChangeData) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Data) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeData.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Data.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -244,26 +245,26 @@ func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *PlainTextChangeData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeData.Merge(m, src) +func (m *PlainTextChange_Data) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Data.Merge(m, src) } -func (m *PlainTextChangeData) XXX_Size() int { +func (m *PlainTextChange_Data) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeData) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeData.DiscardUnknown(m) +func (m *PlainTextChange_Data) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Data.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeData proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Data proto.InternalMessageInfo -func (m *PlainTextChangeData) GetContent() []*PlainTextChangeContent { +func (m *PlainTextChange_Data) GetContent() []*PlainTextChange_Content { if m != nil { return m.Content } return nil } -func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot { +func (m *PlainTextChange_Data) GetSnapshot() *PlainTextChange_Snapshot { if m != nil { return m.Snapshot } @@ -272,10 +273,10 @@ func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot { func init() { proto.RegisterType((*PlainTextChange)(nil), "anytype.PlainTextChange") - proto.RegisterType((*PlainTextChangeContent)(nil), "anytype.PlainTextChange.Content") - proto.RegisterType((*PlainTextChangeTextAppend)(nil), "anytype.PlainTextChange.TextAppend") - proto.RegisterType((*PlainTextChangeSnapshot)(nil), "anytype.PlainTextChange.Snapshot") - proto.RegisterType((*PlainTextChangeData)(nil), "anytype.PlainTextChange.Data") + proto.RegisterType((*PlainTextChange_Content)(nil), "anytype.PlainTextChange.Content") + proto.RegisterType((*PlainTextChange_TextAppend)(nil), "anytype.PlainTextChange.TextAppend") + proto.RegisterType((*PlainTextChange_Snapshot)(nil), "anytype.PlainTextChange.Snapshot") + proto.RegisterType((*PlainTextChange_Data)(nil), "anytype.PlainTextChange.Data") } func init() { @@ -327,7 +328,7 @@ func (m *PlainTextChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Content) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -337,12 +338,12 @@ func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeContent) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -359,12 +360,12 @@ func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *PlainTextChangeContentValueOfTextAppend) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content_TextAppend) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.TextAppend != nil { { @@ -380,7 +381,7 @@ func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } -func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_TextAppend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -390,12 +391,12 @@ func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeTextAppend) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_TextAppend) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -410,7 +411,7 @@ func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Snapshot) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -420,12 +421,12 @@ func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeSnapshot) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Snapshot) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -440,7 +441,7 @@ func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Data) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -450,12 +451,12 @@ func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeData) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Data) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Data) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -509,7 +510,7 @@ func (m *PlainTextChange) Size() (n int) { return n } -func (m *PlainTextChangeContent) Size() (n int) { +func (m *PlainTextChange_Content) Size() (n int) { if m == nil { return 0 } @@ -521,7 +522,7 @@ func (m *PlainTextChangeContent) Size() (n int) { return n } -func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) { +func (m *PlainTextChange_Content_TextAppend) Size() (n int) { if m == nil { return 0 } @@ -533,7 +534,7 @@ func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) { } return n } -func (m *PlainTextChangeTextAppend) Size() (n int) { +func (m *PlainTextChange_TextAppend) Size() (n int) { if m == nil { return 0 } @@ -546,7 +547,7 @@ func (m *PlainTextChangeTextAppend) Size() (n int) { return n } -func (m *PlainTextChangeSnapshot) Size() (n int) { +func (m *PlainTextChange_Snapshot) Size() (n int) { if m == nil { return 0 } @@ -559,7 +560,7 @@ func (m *PlainTextChangeSnapshot) Size() (n int) { return n } -func (m *PlainTextChangeData) Size() (n int) { +func (m *PlainTextChange_Data) Size() (n int) { if m == nil { return 0 } @@ -634,7 +635,7 @@ func (m *PlainTextChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Content) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -692,11 +693,11 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &PlainTextChangeTextAppend{} + v := &PlainTextChange_TextAppend{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &PlainTextChangeContentValueOfTextAppend{v} + m.Value = &PlainTextChange_Content_TextAppend{v} iNdEx = postIndex default: iNdEx = preIndex @@ -719,7 +720,7 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_TextAppend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -801,7 +802,7 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Snapshot) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -883,7 +884,7 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Data) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -941,7 +942,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Content = append(m.Content, &PlainTextChangeContent{}) + m.Content = append(m.Content, &PlainTextChange_Content{}) if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -976,7 +977,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Snapshot == nil { - m.Snapshot = &PlainTextChangeSnapshot{} + m.Snapshot = &PlainTextChange_Snapshot{} } if err := m.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go b/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go index f7bb65bd..3b7c6f7d 100644 --- a/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go +++ b/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go @@ -239,12 +239,12 @@ func (t *TreeStorageBuilder) parseChange(ch *Change) *treeChange { aclChange := &aclpb.ACLChange{} aclChange.Identity = t.keychain.GetIdentity(ch.Identity) if len(ch.AclChanges) > 0 || ch.AclSnapshot != nil { - aclChange.AclData = &aclpb.ACLChangeACLData{} + aclChange.AclData = &aclpb.ACLChange_ACLData{} if ch.AclSnapshot != nil { aclChange.AclData.AclSnapshot = t.parseACLSnapshot(ch.AclSnapshot) } if ch.AclChanges != nil { - var aclChangeContents []*aclpb.ACLChangeACLContentValue + var aclChangeContents []*aclpb.ACLChange_ACLContentValue for _, ch := range ch.AclChanges { aclChangeContent := t.parseACLChange(ch) aclChangeContents = append(aclChangeContents, aclChangeContent) @@ -253,12 +253,12 @@ func (t *TreeStorageBuilder) parseChange(ch *Change) *treeChange { } } if len(ch.Changes) > 0 || ch.Snapshot != nil { - changesData := &testpb.PlainTextChangeData{} + changesData := &testpb.PlainTextChange_Data{} if ch.Snapshot != nil { changesData.Snapshot = t.parseChangeSnapshot(ch.Snapshot) } if len(ch.Changes) > 0 { - var changeContents []*testpb.PlainTextChangeContent + var changeContents []*testpb.PlainTextChange_Content for _, ch := range ch.Changes { aclChangeContent := t.parseDocumentChange(ch) changeContents = append(changeContents, aclChangeContent) @@ -283,16 +283,16 @@ func (t *TreeStorageBuilder) parseTreeId(description *TreeDescription) string { return description.Author + ".tree.id" } -func (t *TreeStorageBuilder) parseChangeSnapshot(s *PlainTextSnapshot) *testpb.PlainTextChangeSnapshot { - return &testpb.PlainTextChangeSnapshot{ +func (t *TreeStorageBuilder) parseChangeSnapshot(s *PlainTextSnapshot) *testpb.PlainTextChange_Snapshot { + return &testpb.PlainTextChange_Snapshot{ Text: s.Text, } } -func (t *TreeStorageBuilder) parseACLSnapshot(s *ACLSnapshot) *aclpb.ACLChangeACLSnapshot { - newState := &aclpb.ACLChangeACLState{} +func (t *TreeStorageBuilder) parseACLSnapshot(s *ACLSnapshot) *aclpb.ACLChange_ACLSnapshot { + newState := &aclpb.ACLChange_ACLState{} for _, state := range s.UserStates { - aclUserState := &aclpb.ACLChangeUserState{} + aclUserState := &aclpb.ACLChange_UserState{} aclUserState.Identity = t.keychain.GetIdentity(state.Identity) encKey := t.keychain. @@ -304,17 +304,17 @@ func (t *TreeStorageBuilder) parseACLSnapshot(s *ACLSnapshot) *aclpb.ACLChangeAC aclUserState.Permissions = t.convertPermission(state.Permissions) newState.UserStates = append(newState.UserStates, aclUserState) } - return &aclpb.ACLChangeACLSnapshot{ + return &aclpb.ACLChange_ACLSnapshot{ AclState: newState, } } -func (t *TreeStorageBuilder) parseDocumentChange(ch *PlainTextChange) (convCh *testpb.PlainTextChangeContent) { +func (t *TreeStorageBuilder) parseDocumentChange(ch *PlainTextChange) (convCh *testpb.PlainTextChange_Content) { switch { case ch.TextAppend != nil: - convCh = &testpb.PlainTextChangeContent{ - Value: &testpb.PlainTextChangeContentValueOfTextAppend{ - TextAppend: &testpb.PlainTextChangeTextAppend{ + convCh = &testpb.PlainTextChange_Content{ + Value: &testpb.PlainTextChange_Content_TextAppend{ + TextAppend: &testpb.PlainTextChange_TextAppend{ Text: ch.TextAppend.Text, }, }, @@ -327,7 +327,7 @@ func (t *TreeStorageBuilder) parseDocumentChange(ch *PlainTextChange) (convCh *t return convCh } -func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLChangeACLContentValue) { +func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLChange_ACLContentValue) { switch { case ch.UserAdd != nil: add := ch.UserAdd @@ -336,9 +336,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha GetKey(add.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{ - UserAdd: &aclpb.ACLChangeUserAdd{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContent_Value_UserAdd{ + UserAdd: &aclpb.ACLChange_UserAdd{ Identity: t.keychain.GetIdentity(add.Identity), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), @@ -360,9 +360,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha panic(err) } - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserJoin{ - UserJoin: &aclpb.ACLChangeUserJoin{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContentValueValueOfUserJoin{ + UserJoin: &aclpb.ACLChange_UserJoin{ Identity: t.keychain.GetIdentity(join.Identity), EncryptionKey: rawKey, AcceptSignature: signature, @@ -378,9 +378,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha GetKey(invite.EncryptionKey).(encryptionkey.PrivKey) rawEncKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserInvite{ - UserInvite: &aclpb.ACLChangeUserInvite{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContentValueValueOfUserInvite{ + UserInvite: &aclpb.ACLChange_UserInvite{ AcceptPublicKey: rawAcceptKey, EncryptPublicKey: rawEncKey, EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), @@ -392,9 +392,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha case ch.UserConfirm != nil: confirm := ch.UserConfirm - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserConfirm{ - UserConfirm: &aclpb.ACLChangeUserConfirm{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContentValueValueOfUserConfirm{ + UserConfirm: &aclpb.ACLChange_UserConfirm{ Identity: t.keychain.GetIdentity(confirm.Identity), UserAddId: confirm.UserAddId, }, @@ -403,9 +403,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha case ch.UserPermissionChange != nil: permissionChange := ch.UserPermissionChange - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserPermissionChange{ - UserPermissionChange: &aclpb.ACLChangeUserPermissionChange{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContentValueValueOfUserPermissionChange{ + UserPermissionChange: &aclpb.ACLChange_UserPermissionChange{ Identity: t.keychain.GetIdentity(permissionChange.Identity), Permissions: t.convertPermission(permissionChange.Permission), }, @@ -432,9 +432,9 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha }) } - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserRemove{ - UserRemove: &aclpb.ACLChangeUserRemove{ + convCh = &aclpb.ACLChange_ACLContentValue{ + Value: &aclpb.ACLChange_ACLContentValueValueOfUserRemove{ + UserRemove: &aclpb.ACLChange_UserRemove{ Identity: t.keychain.GetIdentity(remove.RemovedIdentity), ReadKeyReplaces: replaces, }, @@ -461,7 +461,7 @@ func (t *TreeStorageBuilder) encryptReadKeys(keys []string, encKey encryptionkey return } -func (t *TreeStorageBuilder) convertPermission(perm string) aclpb.ACLChangeUserPermissions { +func (t *TreeStorageBuilder) convertPermission(perm string) aclpb.ACLChange_UserPermissions { switch perm { case "admin": return aclpb.ACLChange_Admin diff --git a/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go b/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go index 935fd711..9d973a24 100644 --- a/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go +++ b/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go @@ -45,7 +45,7 @@ func (t *TreeStorageBuilder) Graph() (string, error) { var chSymbs []string if r.changesDataDecrypted != nil { - res := &testpb.PlainTextChangeData{} + res := &testpb.PlainTextChange_Data{} err := proto.Unmarshal(r.changesDataDecrypted, res) if err != nil { return err @@ -53,7 +53,7 @@ func (t *TreeStorageBuilder) Graph() (string, error) { for _, chc := range res.Content { tp := fmt.Sprintf("%T", chc.Value) - tp = strings.Replace(tp, "ChangeContentValueOf", "", 1) + tp = strings.Replace(tp, "ChangeContent_Value_", "", 1) res := "" for _, ts := range tp { if unicode.IsUpper(ts) { @@ -66,7 +66,7 @@ func (t *TreeStorageBuilder) Graph() (string, error) { if r.GetAclData() != nil { for _, chc := range r.GetAclData().AclContent { tp := fmt.Sprintf("%T", chc.Value) - tp = strings.Replace(tp, "ACLChangeACLContentValueValueOf", "", 1) + tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1) res := "" for _, ts := range tp { if unicode.IsUpper(ts) { diff --git a/service/net/pool/message.go b/service/net/pool/message.go index 7535a55f..15a76f2e 100644 --- a/service/net/pool/message.go +++ b/service/net/pool/message.go @@ -48,7 +48,7 @@ func (m *Message) ReplyType(tp syncproto.MessageType, data proto.Marshaler) (err func (m *Message) Ack() (err error) { ack := &syncproto.System{ - Ack: &syncproto.SystemAck{}, + Ack: &syncproto.System_Ack{}, } data, err := ack.Marshal() if err != nil { @@ -78,10 +78,10 @@ func (m *Message) Ack() (err error) { return } -func (m *Message) AckError(code syncproto.SystemErrorCode, description string) (err error) { +func (m *Message) AckError(code syncproto.System_Error_Code, description string) (err error) { ack := &syncproto.System{ - Ack: &syncproto.SystemAck{ - Error: &syncproto.SystemError{ + Ack: &syncproto.System_Ack{ + Error: &syncproto.System_Error{ Code: code, Description: description, }, diff --git a/service/space/remotediff/remotediff.go b/service/space/remotediff/remotediff.go index 6ace7a33..0bab5350 100644 --- a/service/space/remotediff/remotediff.go +++ b/service/space/remotediff/remotediff.go @@ -25,9 +25,9 @@ type remote struct { func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff.RangeResult) (results []ldiff.RangeResult, err error) { results = resBuf[:0] - pbRanges := make([]*spacesync.DiffRangeRequestRange, 0, len(ranges)) + pbRanges := make([]*spacesync.DiffRange_Request_Range, 0, len(ranges)) for _, rg := range ranges { - pbRanges = append(pbRanges, &spacesync.DiffRangeRequestRange{ + pbRanges = append(pbRanges, &spacesync.DiffRange_Request_Range{ From: rg.From, To: rg.To, Limit: uint32(rg.Limit), @@ -35,10 +35,10 @@ func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff } req := &spacesync.Space{ SpaceId: r.spaceId, - Message: &spacesync.SpaceContent{ - Value: &spacesync.SpaceContentValueOfDiffRange{ + Message: &spacesync.Space_Content{ + Value: &spacesync.Space_Content_DiffRange{ DiffRange: &spacesync.DiffRange{ - Request: &spacesync.DiffRangeRequest{ + Request: &spacesync.DiffRange_Request{ Ranges: pbRanges, }, }, @@ -99,21 +99,21 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, diffRange *spacesync return } - var rangeResp = &spacesync.DiffRangeResponse{ - Results: make([]*spacesync.DiffRangeResponseResult, len(res)), + var rangeResp = &spacesync.DiffRange_Response{ + Results: make([]*spacesync.DiffRange_Response_Result, len(res)), } for _, rangeRes := range res { - var elements []*spacesync.DiffRangeResponseResultElement + var elements []*spacesync.DiffRange_Response_Result_Element if len(rangeRes.Elements) > 0 { - elements = make([]*spacesync.DiffRangeResponseResultElement, 0, len(rangeRes.Elements)) + elements = make([]*spacesync.DiffRange_Response_Result_Element, 0, len(rangeRes.Elements)) for _, el := range rangeRes.Elements { - elements = append(elements, &spacesync.DiffRangeResponseResultElement{ + elements = append(elements, &spacesync.DiffRange_Response_Result_Element{ Id: el.Id, Head: el.Head, }) } } - rangeResp.Results = append(rangeResp.Results, &spacesync.DiffRangeResponseResult{ + rangeResp.Results = append(rangeResp.Results, &spacesync.DiffRange_Response_Result{ Hash: rangeRes.Hash, Elements: elements, Count: uint32(rangeRes.Count), diff --git a/service/space/service.go b/service/space/service.go index 364ce91d..5e61366d 100644 --- a/service/space/service.go +++ b/service/space/service.go @@ -78,9 +78,9 @@ func (s *service) Handle(ctx context.Context, data []byte) (resp proto.Marshaler return } if spaceReq.SpaceId != "" { - sp, err := s.get(ctx, spaceReq.SpaceId) - if err != nil { - return + sp, e := s.get(ctx, spaceReq.SpaceId) + if e != nil { + return nil, e } return sp.Handle(ctx, spaceReq) } diff --git a/service/space/space.go b/service/space/space.go index 776df945..f35452c1 100644 --- a/service/space/space.go +++ b/service/space/space.go @@ -73,7 +73,7 @@ func (s *space) Handle(ctx context.Context, msg *spacesync.Space) (repl *spacesy return nil, er } return &spacesync.Space{SpaceId: s.id, Message: &spacesync.SpaceContent{ - Value: &spacesync.SpaceContentValueOfDiffRange{ + Value: &spacesync.SpaceContent_Value_DiffRange{ DiffRange: resp, }, }}, nil diff --git a/service/space/spacesync/spacesync.pb.go b/service/space/spacesync/spacesync.pb.go index 530c11e3..af6fd478 100644 --- a/service/space/spacesync/spacesync.pb.go +++ b/service/space/spacesync/spacesync.pb.go @@ -23,8 +23,8 @@ var _ = math.Inf const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type Space struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Message *SpaceContent `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Message *Space_Content `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` } func (m *Space) Reset() { *m = Space{} } @@ -67,31 +67,32 @@ func (m *Space) GetSpaceId() string { return "" } -func (m *Space) GetMessage() *SpaceContent { +func (m *Space) GetMessage() *Space_Content { if m != nil { return m.Message } return nil } -type SpaceContent struct { +type Space_Content struct { // Types that are valid to be assigned to Value: - // *SpaceContentValueOfDiffRange - Value IsSpaceContentValue `protobuf_oneof:"value"` + // + // *Space_Content_DiffRange + Value isSpace_Content_Value `protobuf_oneof:"value"` } -func (m *SpaceContent) Reset() { *m = SpaceContent{} } -func (m *SpaceContent) String() string { return proto.CompactTextString(m) } -func (*SpaceContent) ProtoMessage() {} -func (*SpaceContent) Descriptor() ([]byte, []int) { +func (m *Space_Content) Reset() { *m = Space_Content{} } +func (m *Space_Content) String() string { return proto.CompactTextString(m) } +func (*Space_Content) ProtoMessage() {} +func (*Space_Content) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{0, 0} } -func (m *SpaceContent) XXX_Unmarshal(b []byte) error { +func (m *Space_Content) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SpaceContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Space_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SpaceContent.Marshal(b, m, deterministic) + return xxx_messageInfo_Space_Content.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -101,54 +102,54 @@ func (m *SpaceContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *SpaceContent) XXX_Merge(src proto.Message) { - xxx_messageInfo_SpaceContent.Merge(m, src) +func (m *Space_Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_Space_Content.Merge(m, src) } -func (m *SpaceContent) XXX_Size() int { +func (m *Space_Content) XXX_Size() int { return m.Size() } -func (m *SpaceContent) XXX_DiscardUnknown() { - xxx_messageInfo_SpaceContent.DiscardUnknown(m) +func (m *Space_Content) XXX_DiscardUnknown() { + xxx_messageInfo_Space_Content.DiscardUnknown(m) } -var xxx_messageInfo_SpaceContent proto.InternalMessageInfo +var xxx_messageInfo_Space_Content proto.InternalMessageInfo -type IsSpaceContentValue interface { - IsSpaceContentValue() +type isSpace_Content_Value interface { + isSpace_Content_Value() MarshalTo([]byte) (int, error) Size() int } -type SpaceContentValueOfDiffRange struct { +type Space_Content_DiffRange struct { DiffRange *DiffRange `protobuf:"bytes,1,opt,name=diffRange,proto3,oneof" json:"diffRange,omitempty"` } -func (*SpaceContentValueOfDiffRange) IsSpaceContentValue() {} +func (*Space_Content_DiffRange) isSpace_Content_Value() {} -func (m *SpaceContent) GetValue() IsSpaceContentValue { +func (m *Space_Content) GetValue() isSpace_Content_Value { if m != nil { return m.Value } return nil } -func (m *SpaceContent) GetDiffRange() *DiffRange { - if x, ok := m.GetValue().(*SpaceContentValueOfDiffRange); ok { +func (m *Space_Content) GetDiffRange() *DiffRange { + if x, ok := m.GetValue().(*Space_Content_DiffRange); ok { return x.DiffRange } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*SpaceContent) XXX_OneofWrappers() []interface{} { +func (*Space_Content) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*SpaceContentValueOfDiffRange)(nil), + (*Space_Content_DiffRange)(nil), } } type DiffRange struct { - Request *DiffRangeRequest `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` - Response *DiffRangeResponse `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` + Request *DiffRange_Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` + Response *DiffRange_Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` } func (m *DiffRange) Reset() { *m = DiffRange{} } @@ -184,36 +185,36 @@ func (m *DiffRange) XXX_DiscardUnknown() { var xxx_messageInfo_DiffRange proto.InternalMessageInfo -func (m *DiffRange) GetRequest() *DiffRangeRequest { +func (m *DiffRange) GetRequest() *DiffRange_Request { if m != nil { return m.Request } return nil } -func (m *DiffRange) GetResponse() *DiffRangeResponse { +func (m *DiffRange) GetResponse() *DiffRange_Response { if m != nil { return m.Response } return nil } -type DiffRangeRequest struct { - Ranges []*DiffRangeRequestRange `protobuf:"bytes,1,rep,name=ranges,proto3" json:"ranges,omitempty"` +type DiffRange_Request struct { + Ranges []*DiffRange_Request_Range `protobuf:"bytes,1,rep,name=ranges,proto3" json:"ranges,omitempty"` } -func (m *DiffRangeRequest) Reset() { *m = DiffRangeRequest{} } -func (m *DiffRangeRequest) String() string { return proto.CompactTextString(m) } -func (*DiffRangeRequest) ProtoMessage() {} -func (*DiffRangeRequest) Descriptor() ([]byte, []int) { +func (m *DiffRange_Request) Reset() { *m = DiffRange_Request{} } +func (m *DiffRange_Request) String() string { return proto.CompactTextString(m) } +func (*DiffRange_Request) ProtoMessage() {} +func (*DiffRange_Request) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{1, 0} } -func (m *DiffRangeRequest) XXX_Unmarshal(b []byte) error { +func (m *DiffRange_Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DiffRange_Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRangeRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_DiffRange_Request.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -223,43 +224,43 @@ func (m *DiffRangeRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *DiffRangeRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRangeRequest.Merge(m, src) +func (m *DiffRange_Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiffRange_Request.Merge(m, src) } -func (m *DiffRangeRequest) XXX_Size() int { +func (m *DiffRange_Request) XXX_Size() int { return m.Size() } -func (m *DiffRangeRequest) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRangeRequest.DiscardUnknown(m) +func (m *DiffRange_Request) XXX_DiscardUnknown() { + xxx_messageInfo_DiffRange_Request.DiscardUnknown(m) } -var xxx_messageInfo_DiffRangeRequest proto.InternalMessageInfo +var xxx_messageInfo_DiffRange_Request proto.InternalMessageInfo -func (m *DiffRangeRequest) GetRanges() []*DiffRangeRequestRange { +func (m *DiffRange_Request) GetRanges() []*DiffRange_Request_Range { if m != nil { return m.Ranges } return nil } -type DiffRangeRequestRange struct { +type DiffRange_Request_Range struct { From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` To uint64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *DiffRangeRequestRange) Reset() { *m = DiffRangeRequestRange{} } -func (m *DiffRangeRequestRange) String() string { return proto.CompactTextString(m) } -func (*DiffRangeRequestRange) ProtoMessage() {} -func (*DiffRangeRequestRange) Descriptor() ([]byte, []int) { +func (m *DiffRange_Request_Range) Reset() { *m = DiffRange_Request_Range{} } +func (m *DiffRange_Request_Range) String() string { return proto.CompactTextString(m) } +func (*DiffRange_Request_Range) ProtoMessage() {} +func (*DiffRange_Request_Range) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{1, 0, 0} } -func (m *DiffRangeRequestRange) XXX_Unmarshal(b []byte) error { +func (m *DiffRange_Request_Range) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRangeRequestRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DiffRange_Request_Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRangeRequestRange.Marshal(b, m, deterministic) + return xxx_messageInfo_DiffRange_Request_Range.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -269,55 +270,55 @@ func (m *DiffRangeRequestRange) XXX_Marshal(b []byte, deterministic bool) ([]byt return b[:n], nil } } -func (m *DiffRangeRequestRange) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRangeRequestRange.Merge(m, src) +func (m *DiffRange_Request_Range) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiffRange_Request_Range.Merge(m, src) } -func (m *DiffRangeRequestRange) XXX_Size() int { +func (m *DiffRange_Request_Range) XXX_Size() int { return m.Size() } -func (m *DiffRangeRequestRange) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRangeRequestRange.DiscardUnknown(m) +func (m *DiffRange_Request_Range) XXX_DiscardUnknown() { + xxx_messageInfo_DiffRange_Request_Range.DiscardUnknown(m) } -var xxx_messageInfo_DiffRangeRequestRange proto.InternalMessageInfo +var xxx_messageInfo_DiffRange_Request_Range proto.InternalMessageInfo -func (m *DiffRangeRequestRange) GetFrom() uint64 { +func (m *DiffRange_Request_Range) GetFrom() uint64 { if m != nil { return m.From } return 0 } -func (m *DiffRangeRequestRange) GetTo() uint64 { +func (m *DiffRange_Request_Range) GetTo() uint64 { if m != nil { return m.To } return 0 } -func (m *DiffRangeRequestRange) GetLimit() uint32 { +func (m *DiffRange_Request_Range) GetLimit() uint32 { if m != nil { return m.Limit } return 0 } -type DiffRangeResponse struct { - Results []*DiffRangeResponseResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +type DiffRange_Response struct { + Results []*DiffRange_Response_Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` } -func (m *DiffRangeResponse) Reset() { *m = DiffRangeResponse{} } -func (m *DiffRangeResponse) String() string { return proto.CompactTextString(m) } -func (*DiffRangeResponse) ProtoMessage() {} -func (*DiffRangeResponse) Descriptor() ([]byte, []int) { +func (m *DiffRange_Response) Reset() { *m = DiffRange_Response{} } +func (m *DiffRange_Response) String() string { return proto.CompactTextString(m) } +func (*DiffRange_Response) ProtoMessage() {} +func (*DiffRange_Response) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{1, 1} } -func (m *DiffRangeResponse) XXX_Unmarshal(b []byte) error { +func (m *DiffRange_Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRangeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DiffRange_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRangeResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_DiffRange_Response.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -327,43 +328,43 @@ func (m *DiffRangeResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *DiffRangeResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRangeResponse.Merge(m, src) +func (m *DiffRange_Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiffRange_Response.Merge(m, src) } -func (m *DiffRangeResponse) XXX_Size() int { +func (m *DiffRange_Response) XXX_Size() int { return m.Size() } -func (m *DiffRangeResponse) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRangeResponse.DiscardUnknown(m) +func (m *DiffRange_Response) XXX_DiscardUnknown() { + xxx_messageInfo_DiffRange_Response.DiscardUnknown(m) } -var xxx_messageInfo_DiffRangeResponse proto.InternalMessageInfo +var xxx_messageInfo_DiffRange_Response proto.InternalMessageInfo -func (m *DiffRangeResponse) GetResults() []*DiffRangeResponseResult { +func (m *DiffRange_Response) GetResults() []*DiffRange_Response_Result { if m != nil { return m.Results } return nil } -type DiffRangeResponseResult struct { - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Elements []*DiffRangeResponseResultElement `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"` - Count uint32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"` +type DiffRange_Response_Result struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Elements []*DiffRange_Response_Result_Element `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"` + Count uint32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"` } -func (m *DiffRangeResponseResult) Reset() { *m = DiffRangeResponseResult{} } -func (m *DiffRangeResponseResult) String() string { return proto.CompactTextString(m) } -func (*DiffRangeResponseResult) ProtoMessage() {} -func (*DiffRangeResponseResult) Descriptor() ([]byte, []int) { +func (m *DiffRange_Response_Result) Reset() { *m = DiffRange_Response_Result{} } +func (m *DiffRange_Response_Result) String() string { return proto.CompactTextString(m) } +func (*DiffRange_Response_Result) ProtoMessage() {} +func (*DiffRange_Response_Result) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0} } -func (m *DiffRangeResponseResult) XXX_Unmarshal(b []byte) error { +func (m *DiffRange_Response_Result) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRangeResponseResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DiffRange_Response_Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRangeResponseResult.Marshal(b, m, deterministic) + return xxx_messageInfo_DiffRange_Response_Result.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -373,56 +374,56 @@ func (m *DiffRangeResponseResult) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *DiffRangeResponseResult) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRangeResponseResult.Merge(m, src) +func (m *DiffRange_Response_Result) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiffRange_Response_Result.Merge(m, src) } -func (m *DiffRangeResponseResult) XXX_Size() int { +func (m *DiffRange_Response_Result) XXX_Size() int { return m.Size() } -func (m *DiffRangeResponseResult) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRangeResponseResult.DiscardUnknown(m) +func (m *DiffRange_Response_Result) XXX_DiscardUnknown() { + xxx_messageInfo_DiffRange_Response_Result.DiscardUnknown(m) } -var xxx_messageInfo_DiffRangeResponseResult proto.InternalMessageInfo +var xxx_messageInfo_DiffRange_Response_Result proto.InternalMessageInfo -func (m *DiffRangeResponseResult) GetHash() []byte { +func (m *DiffRange_Response_Result) GetHash() []byte { if m != nil { return m.Hash } return nil } -func (m *DiffRangeResponseResult) GetElements() []*DiffRangeResponseResultElement { +func (m *DiffRange_Response_Result) GetElements() []*DiffRange_Response_Result_Element { if m != nil { return m.Elements } return nil } -func (m *DiffRangeResponseResult) GetCount() uint32 { +func (m *DiffRange_Response_Result) GetCount() uint32 { if m != nil { return m.Count } return 0 } -type DiffRangeResponseResultElement struct { +type DiffRange_Response_Result_Element struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Head string `protobuf:"bytes,2,opt,name=head,proto3" json:"head,omitempty"` } -func (m *DiffRangeResponseResultElement) Reset() { *m = DiffRangeResponseResultElement{} } -func (m *DiffRangeResponseResultElement) String() string { return proto.CompactTextString(m) } -func (*DiffRangeResponseResultElement) ProtoMessage() {} -func (*DiffRangeResponseResultElement) Descriptor() ([]byte, []int) { +func (m *DiffRange_Response_Result_Element) Reset() { *m = DiffRange_Response_Result_Element{} } +func (m *DiffRange_Response_Result_Element) String() string { return proto.CompactTextString(m) } +func (*DiffRange_Response_Result_Element) ProtoMessage() {} +func (*DiffRange_Response_Result_Element) Descriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0, 0} } -func (m *DiffRangeResponseResultElement) XXX_Unmarshal(b []byte) error { +func (m *DiffRange_Response_Result_Element) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRangeResponseResultElement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *DiffRange_Response_Result_Element) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRangeResponseResultElement.Marshal(b, m, deterministic) + return xxx_messageInfo_DiffRange_Response_Result_Element.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -432,26 +433,26 @@ func (m *DiffRangeResponseResultElement) XXX_Marshal(b []byte, deterministic boo return b[:n], nil } } -func (m *DiffRangeResponseResultElement) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRangeResponseResultElement.Merge(m, src) +func (m *DiffRange_Response_Result_Element) XXX_Merge(src proto.Message) { + xxx_messageInfo_DiffRange_Response_Result_Element.Merge(m, src) } -func (m *DiffRangeResponseResultElement) XXX_Size() int { +func (m *DiffRange_Response_Result_Element) XXX_Size() int { return m.Size() } -func (m *DiffRangeResponseResultElement) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRangeResponseResultElement.DiscardUnknown(m) +func (m *DiffRange_Response_Result_Element) XXX_DiscardUnknown() { + xxx_messageInfo_DiffRange_Response_Result_Element.DiscardUnknown(m) } -var xxx_messageInfo_DiffRangeResponseResultElement proto.InternalMessageInfo +var xxx_messageInfo_DiffRange_Response_Result_Element proto.InternalMessageInfo -func (m *DiffRangeResponseResultElement) GetId() string { +func (m *DiffRange_Response_Result_Element) GetId() string { if m != nil { return m.Id } return "" } -func (m *DiffRangeResponseResultElement) GetHead() string { +func (m *DiffRange_Response_Result_Element) GetHead() string { if m != nil { return m.Head } @@ -460,13 +461,13 @@ func (m *DiffRangeResponseResultElement) GetHead() string { func init() { proto.RegisterType((*Space)(nil), "anytype.Space") - proto.RegisterType((*SpaceContent)(nil), "anytype.Space.Content") + proto.RegisterType((*Space_Content)(nil), "anytype.Space.Content") proto.RegisterType((*DiffRange)(nil), "anytype.DiffRange") - proto.RegisterType((*DiffRangeRequest)(nil), "anytype.DiffRange.Request") - proto.RegisterType((*DiffRangeRequestRange)(nil), "anytype.DiffRange.Request.Range") - proto.RegisterType((*DiffRangeResponse)(nil), "anytype.DiffRange.Response") - proto.RegisterType((*DiffRangeResponseResult)(nil), "anytype.DiffRange.Response.Result") - proto.RegisterType((*DiffRangeResponseResultElement)(nil), "anytype.DiffRange.Response.Result.Element") + proto.RegisterType((*DiffRange_Request)(nil), "anytype.DiffRange.Request") + proto.RegisterType((*DiffRange_Request_Range)(nil), "anytype.DiffRange.Request.Range") + proto.RegisterType((*DiffRange_Response)(nil), "anytype.DiffRange.Response") + proto.RegisterType((*DiffRange_Response_Result)(nil), "anytype.DiffRange.Response.Result") + proto.RegisterType((*DiffRange_Response_Result_Element)(nil), "anytype.DiffRange.Response.Result.Element") } func init() { @@ -546,7 +547,7 @@ func (m *Space) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SpaceContent) Marshal() (dAtA []byte, err error) { +func (m *Space_Content) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -556,12 +557,12 @@ func (m *SpaceContent) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SpaceContent) MarshalTo(dAtA []byte) (int, error) { +func (m *Space_Content) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SpaceContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Space_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -578,12 +579,12 @@ func (m *SpaceContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SpaceContentValueOfDiffRange) MarshalTo(dAtA []byte) (int, error) { +func (m *Space_Content_DiffRange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SpaceContentValueOfDiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Space_Content_DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.DiffRange != nil { { @@ -646,7 +647,7 @@ func (m *DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DiffRangeRequest) Marshal() (dAtA []byte, err error) { +func (m *DiffRange_Request) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -656,12 +657,12 @@ func (m *DiffRangeRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRangeRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *DiffRange_Request) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DiffRange_Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -683,7 +684,7 @@ func (m *DiffRangeRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DiffRangeRequestRange) Marshal() (dAtA []byte, err error) { +func (m *DiffRange_Request_Range) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -693,12 +694,12 @@ func (m *DiffRangeRequestRange) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRangeRequestRange) MarshalTo(dAtA []byte) (int, error) { +func (m *DiffRange_Request_Range) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRangeRequestRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DiffRange_Request_Range) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -721,7 +722,7 @@ func (m *DiffRangeRequestRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DiffRangeResponse) Marshal() (dAtA []byte, err error) { +func (m *DiffRange_Response) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -731,12 +732,12 @@ func (m *DiffRangeResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRangeResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *DiffRange_Response) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRangeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DiffRange_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -758,7 +759,7 @@ func (m *DiffRangeResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *DiffRangeResponseResult) Marshal() (dAtA []byte, err error) { +func (m *DiffRange_Response_Result) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -768,12 +769,12 @@ func (m *DiffRangeResponseResult) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRangeResponseResult) MarshalTo(dAtA []byte) (int, error) { +func (m *DiffRange_Response_Result) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRangeResponseResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DiffRange_Response_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -807,7 +808,7 @@ func (m *DiffRangeResponseResult) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *DiffRangeResponseResultElement) Marshal() (dAtA []byte, err error) { +func (m *DiffRange_Response_Result_Element) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -817,12 +818,12 @@ func (m *DiffRangeResponseResultElement) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRangeResponseResultElement) MarshalTo(dAtA []byte) (int, error) { +func (m *DiffRange_Response_Result_Element) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRangeResponseResultElement) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *DiffRange_Response_Result_Element) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -872,7 +873,7 @@ func (m *Space) Size() (n int) { return n } -func (m *SpaceContent) Size() (n int) { +func (m *Space_Content) Size() (n int) { if m == nil { return 0 } @@ -884,7 +885,7 @@ func (m *SpaceContent) Size() (n int) { return n } -func (m *SpaceContentValueOfDiffRange) Size() (n int) { +func (m *Space_Content_DiffRange) Size() (n int) { if m == nil { return 0 } @@ -913,7 +914,7 @@ func (m *DiffRange) Size() (n int) { return n } -func (m *DiffRangeRequest) Size() (n int) { +func (m *DiffRange_Request) Size() (n int) { if m == nil { return 0 } @@ -928,7 +929,7 @@ func (m *DiffRangeRequest) Size() (n int) { return n } -func (m *DiffRangeRequestRange) Size() (n int) { +func (m *DiffRange_Request_Range) Size() (n int) { if m == nil { return 0 } @@ -946,7 +947,7 @@ func (m *DiffRangeRequestRange) Size() (n int) { return n } -func (m *DiffRangeResponse) Size() (n int) { +func (m *DiffRange_Response) Size() (n int) { if m == nil { return 0 } @@ -961,7 +962,7 @@ func (m *DiffRangeResponse) Size() (n int) { return n } -func (m *DiffRangeResponseResult) Size() (n int) { +func (m *DiffRange_Response_Result) Size() (n int) { if m == nil { return 0 } @@ -983,7 +984,7 @@ func (m *DiffRangeResponseResult) Size() (n int) { return n } -func (m *DiffRangeResponseResultElement) Size() (n int) { +func (m *DiffRange_Response_Result_Element) Size() (n int) { if m == nil { return 0 } @@ -1097,7 +1098,7 @@ func (m *Space) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Message == nil { - m.Message = &SpaceContent{} + m.Message = &Space_Content{} } if err := m.Message.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1124,7 +1125,7 @@ func (m *Space) Unmarshal(dAtA []byte) error { } return nil } -func (m *SpaceContent) Unmarshal(dAtA []byte) error { +func (m *Space_Content) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1186,7 +1187,7 @@ func (m *SpaceContent) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &SpaceContentValueOfDiffRange{v} + m.Value = &Space_Content_DiffRange{v} iNdEx = postIndex default: iNdEx = preIndex @@ -1268,7 +1269,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Request == nil { - m.Request = &DiffRangeRequest{} + m.Request = &DiffRange_Request{} } if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1304,7 +1305,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Response == nil { - m.Response = &DiffRangeResponse{} + m.Response = &DiffRange_Response{} } if err := m.Response.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -1331,7 +1332,7 @@ func (m *DiffRange) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error { +func (m *DiffRange_Request) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1389,7 +1390,7 @@ func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Ranges = append(m.Ranges, &DiffRangeRequestRange{}) + m.Ranges = append(m.Ranges, &DiffRange_Request_Range{}) if err := m.Ranges[len(m.Ranges)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1415,7 +1416,7 @@ func (m *DiffRangeRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRangeRequestRange) Unmarshal(dAtA []byte) error { +func (m *DiffRange_Request_Range) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1522,7 +1523,7 @@ func (m *DiffRangeRequestRange) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error { +func (m *DiffRange_Response) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1580,7 +1581,7 @@ func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Results = append(m.Results, &DiffRangeResponseResult{}) + m.Results = append(m.Results, &DiffRange_Response_Result{}) if err := m.Results[len(m.Results)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1606,7 +1607,7 @@ func (m *DiffRangeResponse) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error { +func (m *DiffRange_Response_Result) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1698,7 +1699,7 @@ func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Elements = append(m.Elements, &DiffRangeResponseResultElement{}) + m.Elements = append(m.Elements, &DiffRange_Response_Result_Element{}) if err := m.Elements[len(m.Elements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1743,7 +1744,7 @@ func (m *DiffRangeResponseResult) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRangeResponseResultElement) Unmarshal(dAtA []byte) error { +func (m *DiffRange_Response_Result_Element) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { diff --git a/service/sync/document/service.go b/service/sync/document/service.go index b684e64b..03799c09 100644 --- a/service/sync/document/service.go +++ b/service/sync/document/service.go @@ -74,8 +74,8 @@ func (s *service) UpdateDocument(ctx context.Context, id, text string) (err erro err = s.treeCache.Do(ctx, id, func(tree acltree.ACLTree) error { ch, err = tree.AddContent(ctx, func(builder acltree.ChangeBuilder) error { builder.AddChangeContent( - &testchangepb.PlainTextChangeData{ - Content: []*testchangepb.PlainTextChangeContent{ + &testchangepb.PlainTextChange_Data{ + Content: []*testchangepb.PlainTextChange_Content{ createAppendTextChangeContent(text), }, }) @@ -100,7 +100,7 @@ func (s *service) UpdateDocument(ctx context.Context, id, text string) (err erro zap.String("header", header.String())). Debug("document updated in the database") - return s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{ + return s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.Sync_HeadUpdate{ Heads: heads, Changes: []*aclpb.RawChange{ch}, TreeId: id, @@ -155,7 +155,7 @@ func (s *service) CreateDocument(ctx context.Context, text string) (id string, e log.With(zap.String("id", id), zap.String("text", text)). Debug("creating document") - err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{ + err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.Sync_HeadUpdate{ Heads: heads, Changes: []*aclpb.RawChange{ch}, TreeId: id, @@ -169,18 +169,18 @@ func (s *service) CreateDocument(ctx context.Context, text string) (id string, e } func createInitialChangeContent(text string) proto.Marshaler { - return &testchangepb.PlainTextChangeData{ - Content: []*testchangepb.PlainTextChangeContent{ + return &testchangepb.PlainTextChange_Data{ + Content: []*testchangepb.PlainTextChange_Content{ createAppendTextChangeContent(text), }, - Snapshot: &testchangepb.PlainTextChangeSnapshot{Text: text}, + Snapshot: &testchangepb.PlainTextChange_Snapshot{Text: text}, } } -func createAppendTextChangeContent(text string) *testchangepb.PlainTextChangeContent { - return &testchangepb.PlainTextChangeContent{ - Value: &testchangepb.PlainTextChangeContentValueOfTextAppend{ - TextAppend: &testchangepb.PlainTextChangeTextAppend{ +func createAppendTextChangeContent(text string) *testchangepb.PlainTextChange_Content { + return &testchangepb.PlainTextChange_Content{ + Value: &testchangepb.PlainTextChange_Content_TextAppend{ + TextAppend: &testchangepb.PlainTextChange_TextAppend{ Text: text, }, }, diff --git a/service/sync/message/service.go b/service/sync/message/service.go index efe76900..7207a302 100644 --- a/service/sync/message/service.go +++ b/service/sync/message/service.go @@ -56,7 +56,7 @@ func (s *service) Close(ctx context.Context) (err error) { func (s *service) HandleMessage(ctx context.Context, msg *pool.Message) (err error) { defer func() { if err != nil { - msg.AckError(syncproto.SystemError_UNKNOWN, err.Error()) + msg.AckError(syncproto.System_Error_UNKNOWN, err.Error()) } else { msg.Ack() } diff --git a/service/sync/requesthandler/requesthandler.go b/service/sync/requesthandler/requesthandler.go index 2eb70551..2a960104 100644 --- a/service/sync/requesthandler/requesthandler.go +++ b/service/sync/requesthandler/requesthandler.go @@ -70,9 +70,9 @@ func (r *requestHandler) HandleSyncMessage(ctx context.Context, senderId string, return nil } -func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, update *syncproto.SyncHeadUpdate) (err error) { +func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, update *syncproto.Sync_HeadUpdate) (err error) { var ( - fullRequest *syncproto.SyncFullRequest + fullRequest *syncproto.Sync_Full_Request snapshotPath []string result acltree.AddResult ) @@ -100,7 +100,7 @@ func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, // if there are no such tree if err == treestorage.ErrUnknownTreeId { // TODO: maybe we can optimize this by sending the header and stuff right away, so when the tree is created we are able to add it on first request - fullRequest = &syncproto.SyncFullRequest{ + fullRequest = &syncproto.Sync_Full_Request{ TreeId: update.TreeId, TreeHeader: update.TreeHeader, } @@ -114,7 +114,7 @@ func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, return err } // otherwise sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ + newUpdate := &syncproto.Sync_HeadUpdate{ Heads: result.Heads, Changes: result.Added, SnapshotPath: snapshotPath, @@ -124,9 +124,9 @@ func (r *requestHandler) HandleHeadUpdate(ctx context.Context, senderId string, return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate)) } -func (r *requestHandler) HandleFullSyncRequest(ctx context.Context, senderId string, request *syncproto.SyncFullRequest) (err error) { +func (r *requestHandler) HandleFullSyncRequest(ctx context.Context, senderId string, request *syncproto.Sync_Full_Request) (err error) { var ( - fullResponse *syncproto.SyncFullResponse + fullResponse *syncproto.Sync_Full_Response snapshotPath []string result acltree.AddResult ) @@ -159,7 +159,7 @@ func (r *requestHandler) HandleFullSyncRequest(ctx context.Context, senderId str } // otherwise sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ + newUpdate := &syncproto.Sync_HeadUpdate{ Heads: result.Heads, Changes: result.Added, SnapshotPath: snapshotPath, @@ -169,7 +169,7 @@ func (r *requestHandler) HandleFullSyncRequest(ctx context.Context, senderId str return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate)) } -func (r *requestHandler) HandleFullSyncResponse(ctx context.Context, senderId string, response *syncproto.SyncFullResponse) (err error) { +func (r *requestHandler) HandleFullSyncResponse(ctx context.Context, senderId string, response *syncproto.Sync_Full_Response) (err error) { var ( snapshotPath []string result acltree.AddResult @@ -203,7 +203,7 @@ func (r *requestHandler) HandleFullSyncResponse(ctx context.Context, senderId st } } // sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ + newUpdate := &syncproto.Sync_HeadUpdate{ Heads: result.Heads, Changes: result.Added, SnapshotPath: snapshotPath, @@ -212,12 +212,12 @@ func (r *requestHandler) HandleFullSyncResponse(ctx context.Context, senderId st return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate)) } -func (r *requestHandler) prepareFullSyncRequest(treeId string, header *treepb.TreeHeader, theirPath []string, tree acltree.ACLTree) (*syncproto.SyncFullRequest, error) { +func (r *requestHandler) prepareFullSyncRequest(treeId string, header *treepb.TreeHeader, theirPath []string, tree acltree.ACLTree) (*syncproto.Sync_Full_Request, error) { ourChanges, err := tree.ChangesAfterCommonSnapshot(theirPath) if err != nil { return nil, err } - return &syncproto.SyncFullRequest{ + return &syncproto.Sync_Full_Request{ Heads: tree.Heads(), Changes: ourChanges, TreeId: treeId, @@ -230,7 +230,7 @@ func (r *requestHandler) prepareFullSyncResponse( treeId string, theirPath []string, theirChanges []*aclpb.RawChange, - tree acltree.ACLTree) (*syncproto.SyncFullResponse, error) { + tree acltree.ACLTree) (*syncproto.Sync_Full_Response, error) { // TODO: we can probably use the common snapshot calculated on the request step from previous peer ourChanges, err := tree.ChangesAfterCommonSnapshot(theirPath) if err != nil { @@ -251,7 +251,7 @@ func (r *requestHandler) prepareFullSyncResponse( log.With(zap.Int("len(changes)", len(final)), zap.String("id", treeId)). Debug("preparing changes for tree") - return &syncproto.SyncFullResponse{ + return &syncproto.Sync_Full_Response{ Heads: tree.Heads(), Changes: final, TreeId: treeId, @@ -260,7 +260,7 @@ func (r *requestHandler) prepareFullSyncResponse( }, nil } -func (r *requestHandler) createTree(ctx context.Context, response *syncproto.SyncFullResponse) error { +func (r *requestHandler) createTree(ctx context.Context, response *syncproto.Sync_Full_Response) error { return r.treeCache.Add( ctx, response.TreeId, diff --git a/syncproto/helpers.go b/syncproto/helpers.go index e3059bda..fe19c267 100644 --- a/syncproto/helpers.go +++ b/syncproto/helpers.go @@ -1,19 +1,19 @@ package syncproto -func WrapHeadUpdate(update *SyncHeadUpdate) *Sync { - return &Sync{Message: &SyncContentValue{ - Value: &SyncContentValueValueOfHeadUpdate{HeadUpdate: update}, +func WrapHeadUpdate(update *Sync_HeadUpdate) *Sync { + return &Sync{Message: &Sync_ContentValue{ + Value: &Sync_Content_Value_HeadUpdate{HeadUpdate: update}, }} } -func WrapFullRequest(request *SyncFullRequest) *Sync { - return &Sync{Message: &SyncContentValue{ - Value: &SyncContentValueValueOfFullSyncRequest{FullSyncRequest: request}, +func WrapFullRequest(request *Sync_Full_Request) *Sync { + return &Sync{Message: &Sync_ContentValue{ + Value: &Sync_Content_Value_FullSyncRequest{FullSyncRequest: request}, }} } -func WrapFullResponse(response *SyncFullResponse) *Sync { - return &Sync{Message: &SyncContentValue{ - Value: &SyncContentValueValueOfFullSyncResponse{FullSyncResponse: response}, +func WrapFullResponse(response *Sync_Full_Response) *Sync { + return &Sync{Message: &Sync_ContentValue{ + Value: &Sync_Content_Value_FullSyncResponse{FullSyncResponse: response}, }} } diff --git a/syncproto/sync.pb.go b/syncproto/sync.pb.go index aa69618b..e8df4661 100644 --- a/syncproto/sync.pb.go +++ b/syncproto/sync.pb.go @@ -52,28 +52,28 @@ func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{0} } -type SystemErrorCode int32 +type System_Error_Code int32 const ( - SystemError_UNKNOWN SystemErrorCode = 0 - SystemError_UNSUPPORTED_PROTOCOL_VERSION SystemErrorCode = 10 + System_Error_UNKNOWN System_Error_Code = 0 + System_Error_UNSUPPORTED_PROTOCOL_VERSION System_Error_Code = 10 ) -var SystemErrorCode_name = map[int32]string{ +var System_Error_Code_name = map[int32]string{ 0: "UNKNOWN", 10: "UNSUPPORTED_PROTOCOL_VERSION", } -var SystemErrorCode_value = map[string]int32{ +var System_Error_Code_value = map[string]int32{ "UNKNOWN": 0, "UNSUPPORTED_PROTOCOL_VERSION": 10, } -func (x SystemErrorCode) String() string { - return proto.EnumName(SystemErrorCode_name, int32(x)) +func (x System_Error_Code) String() string { + return proto.EnumName(System_Error_Code_name, int32(x)) } -func (SystemErrorCode) EnumDescriptor() ([]byte, []int) { +func (System_Error_Code) EnumDescriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 3, 0} } @@ -206,9 +206,9 @@ func (m *Header) GetDebugInfo() string { } type System struct { - Handshake *SystemHandshake `protobuf:"bytes,1,opt,name=handshake,proto3" json:"handshake,omitempty"` - Ping *SystemPing `protobuf:"bytes,2,opt,name=ping,proto3" json:"ping,omitempty"` - Ack *SystemAck `protobuf:"bytes,3,opt,name=ack,proto3" json:"ack,omitempty"` + Handshake *System_Handshake `protobuf:"bytes,1,opt,name=handshake,proto3" json:"handshake,omitempty"` + Ping *System_Ping `protobuf:"bytes,2,opt,name=ping,proto3" json:"ping,omitempty"` + Ack *System_Ack `protobuf:"bytes,3,opt,name=ack,proto3" json:"ack,omitempty"` } func (m *System) Reset() { *m = System{} } @@ -244,43 +244,43 @@ func (m *System) XXX_DiscardUnknown() { var xxx_messageInfo_System proto.InternalMessageInfo -func (m *System) GetHandshake() *SystemHandshake { +func (m *System) GetHandshake() *System_Handshake { if m != nil { return m.Handshake } return nil } -func (m *System) GetPing() *SystemPing { +func (m *System) GetPing() *System_Ping { if m != nil { return m.Ping } return nil } -func (m *System) GetAck() *SystemAck { +func (m *System) GetAck() *System_Ack { if m != nil { return m.Ack } return nil } -type SystemHandshake struct { +type System_Handshake struct { ProtocolVersion string `protobuf:"bytes,1,opt,name=protocolVersion,proto3" json:"protocolVersion,omitempty"` } -func (m *SystemHandshake) Reset() { *m = SystemHandshake{} } -func (m *SystemHandshake) String() string { return proto.CompactTextString(m) } -func (*SystemHandshake) ProtoMessage() {} -func (*SystemHandshake) Descriptor() ([]byte, []int) { +func (m *System_Handshake) Reset() { *m = System_Handshake{} } +func (m *System_Handshake) String() string { return proto.CompactTextString(m) } +func (*System_Handshake) ProtoMessage() {} +func (*System_Handshake) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 0} } -func (m *SystemHandshake) XXX_Unmarshal(b []byte) error { +func (m *System_Handshake) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemHandshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Handshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemHandshake.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Handshake.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -290,41 +290,41 @@ func (m *SystemHandshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *SystemHandshake) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemHandshake.Merge(m, src) +func (m *System_Handshake) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Handshake.Merge(m, src) } -func (m *SystemHandshake) XXX_Size() int { +func (m *System_Handshake) XXX_Size() int { return m.Size() } -func (m *SystemHandshake) XXX_DiscardUnknown() { - xxx_messageInfo_SystemHandshake.DiscardUnknown(m) +func (m *System_Handshake) XXX_DiscardUnknown() { + xxx_messageInfo_System_Handshake.DiscardUnknown(m) } -var xxx_messageInfo_SystemHandshake proto.InternalMessageInfo +var xxx_messageInfo_System_Handshake proto.InternalMessageInfo -func (m *SystemHandshake) GetProtocolVersion() string { +func (m *System_Handshake) GetProtocolVersion() string { if m != nil { return m.ProtocolVersion } return "" } -type SystemPing struct { +type System_Ping struct { UnixTime uint64 `protobuf:"varint,1,opt,name=unixTime,proto3" json:"unixTime,omitempty"` } -func (m *SystemPing) Reset() { *m = SystemPing{} } -func (m *SystemPing) String() string { return proto.CompactTextString(m) } -func (*SystemPing) ProtoMessage() {} -func (*SystemPing) Descriptor() ([]byte, []int) { +func (m *System_Ping) Reset() { *m = System_Ping{} } +func (m *System_Ping) String() string { return proto.CompactTextString(m) } +func (*System_Ping) ProtoMessage() {} +func (*System_Ping) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 1} } -func (m *SystemPing) XXX_Unmarshal(b []byte) error { +func (m *System_Ping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemPing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemPing.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Ping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -334,41 +334,41 @@ func (m *SystemPing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *SystemPing) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemPing.Merge(m, src) +func (m *System_Ping) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Ping.Merge(m, src) } -func (m *SystemPing) XXX_Size() int { +func (m *System_Ping) XXX_Size() int { return m.Size() } -func (m *SystemPing) XXX_DiscardUnknown() { - xxx_messageInfo_SystemPing.DiscardUnknown(m) +func (m *System_Ping) XXX_DiscardUnknown() { + xxx_messageInfo_System_Ping.DiscardUnknown(m) } -var xxx_messageInfo_SystemPing proto.InternalMessageInfo +var xxx_messageInfo_System_Ping proto.InternalMessageInfo -func (m *SystemPing) GetUnixTime() uint64 { +func (m *System_Ping) GetUnixTime() uint64 { if m != nil { return m.UnixTime } return 0 } -type SystemAck struct { - Error *SystemError `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +type System_Ack struct { + Error *System_Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } -func (m *SystemAck) Reset() { *m = SystemAck{} } -func (m *SystemAck) String() string { return proto.CompactTextString(m) } -func (*SystemAck) ProtoMessage() {} -func (*SystemAck) Descriptor() ([]byte, []int) { +func (m *System_Ack) Reset() { *m = System_Ack{} } +func (m *System_Ack) String() string { return proto.CompactTextString(m) } +func (*System_Ack) ProtoMessage() {} +func (*System_Ack) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 2} } -func (m *SystemAck) XXX_Unmarshal(b []byte) error { +func (m *System_Ack) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Ack) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemAck.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Ack.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -378,42 +378,42 @@ func (m *SystemAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *SystemAck) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemAck.Merge(m, src) +func (m *System_Ack) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Ack.Merge(m, src) } -func (m *SystemAck) XXX_Size() int { +func (m *System_Ack) XXX_Size() int { return m.Size() } -func (m *SystemAck) XXX_DiscardUnknown() { - xxx_messageInfo_SystemAck.DiscardUnknown(m) +func (m *System_Ack) XXX_DiscardUnknown() { + xxx_messageInfo_System_Ack.DiscardUnknown(m) } -var xxx_messageInfo_SystemAck proto.InternalMessageInfo +var xxx_messageInfo_System_Ack proto.InternalMessageInfo -func (m *SystemAck) GetError() *SystemError { +func (m *System_Ack) GetError() *System_Error { if m != nil { return m.Error } return nil } -type SystemError struct { - Code SystemErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=anytype.SystemErrorCode" json:"code,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +type System_Error struct { + Code System_Error_Code `protobuf:"varint,1,opt,name=code,proto3,enum=anytype.System_Error_Code" json:"code,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` } -func (m *SystemError) Reset() { *m = SystemError{} } -func (m *SystemError) String() string { return proto.CompactTextString(m) } -func (*SystemError) ProtoMessage() {} -func (*SystemError) Descriptor() ([]byte, []int) { +func (m *System_Error) Reset() { *m = System_Error{} } +func (m *System_Error) String() string { return proto.CompactTextString(m) } +func (*System_Error) ProtoMessage() {} +func (*System_Error) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 3} } -func (m *SystemError) XXX_Unmarshal(b []byte) error { +func (m *System_Error) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemError.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Error.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -423,26 +423,26 @@ func (m *SystemError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *SystemError) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemError.Merge(m, src) +func (m *System_Error) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Error.Merge(m, src) } -func (m *SystemError) XXX_Size() int { +func (m *System_Error) XXX_Size() int { return m.Size() } -func (m *SystemError) XXX_DiscardUnknown() { - xxx_messageInfo_SystemError.DiscardUnknown(m) +func (m *System_Error) XXX_DiscardUnknown() { + xxx_messageInfo_System_Error.DiscardUnknown(m) } -var xxx_messageInfo_SystemError proto.InternalMessageInfo +var xxx_messageInfo_System_Error proto.InternalMessageInfo -func (m *SystemError) GetCode() SystemErrorCode { +func (m *System_Error) GetCode() System_Error_Code { if m != nil { return m.Code } - return SystemError_UNKNOWN + return System_Error_UNKNOWN } -func (m *SystemError) GetDescription() string { +func (m *System_Error) GetDescription() string { if m != nil { return m.Description } @@ -450,8 +450,8 @@ func (m *SystemError) GetDescription() string { } type Sync struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Message *SyncContentValue `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Message *Sync_ContentValue `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` } func (m *Sync) Reset() { *m = Sync{} } @@ -494,33 +494,33 @@ func (m *Sync) GetSpaceId() string { return "" } -func (m *Sync) GetMessage() *SyncContentValue { +func (m *Sync) GetMessage() *Sync_ContentValue { if m != nil { return m.Message } return nil } -type SyncContentValue struct { +type Sync_ContentValue struct { // Types that are valid to be assigned to Value: - // *SyncContentValueValueOfHeadUpdate - // *SyncContentValueValueOfFullSyncRequest - // *SyncContentValueValueOfFullSyncResponse - Value IsSyncContentValueValue `protobuf_oneof:"value"` + // *Sync_Content_Value_HeadUpdate + // *Sync_Content_Value_FullSyncRequest + // *Sync_Content_Value_FullSyncResponse + Value isSync_Content_Value_Value `protobuf_oneof:"value"` } -func (m *SyncContentValue) Reset() { *m = SyncContentValue{} } -func (m *SyncContentValue) String() string { return proto.CompactTextString(m) } -func (*SyncContentValue) ProtoMessage() {} -func (*SyncContentValue) Descriptor() ([]byte, []int) { +func (m *Sync_ContentValue) Reset() { *m = Sync_ContentValue{} } +func (m *Sync_ContentValue) String() string { return proto.CompactTextString(m) } +func (*Sync_ContentValue) ProtoMessage() {} +func (*Sync_ContentValue) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{3, 0} } -func (m *SyncContentValue) XXX_Unmarshal(b []byte) error { +func (m *Sync_ContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SyncContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Sync_ContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SyncContentValue.Marshal(b, m, deterministic) + return xxx_messageInfo_Sync_ContentValue.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -530,76 +530,76 @@ func (m *SyncContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *SyncContentValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncContentValue.Merge(m, src) +func (m *Sync_ContentValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sync_ContentValue.Merge(m, src) } -func (m *SyncContentValue) XXX_Size() int { +func (m *Sync_ContentValue) XXX_Size() int { return m.Size() } -func (m *SyncContentValue) XXX_DiscardUnknown() { - xxx_messageInfo_SyncContentValue.DiscardUnknown(m) +func (m *Sync_ContentValue) XXX_DiscardUnknown() { + xxx_messageInfo_Sync_ContentValue.DiscardUnknown(m) } -var xxx_messageInfo_SyncContentValue proto.InternalMessageInfo +var xxx_messageInfo_Sync_ContentValue proto.InternalMessageInfo -type IsSyncContentValueValue interface { - IsSyncContentValueValue() +type isSync_Content_Value_Value interface { + isSync_Content_Value_Value() MarshalTo([]byte) (int, error) Size() int } -type SyncContentValueValueOfHeadUpdate struct { - HeadUpdate *SyncHeadUpdate `protobuf:"bytes,1,opt,name=headUpdate,proto3,oneof" json:"headUpdate,omitempty"` +type Sync_Content_Value_HeadUpdate struct { + HeadUpdate *Sync_HeadUpdate `protobuf:"bytes,1,opt,name=headUpdate,proto3,oneof" json:"headUpdate,omitempty"` } -type SyncContentValueValueOfFullSyncRequest struct { - FullSyncRequest *SyncFullRequest `protobuf:"bytes,2,opt,name=fullSyncRequest,proto3,oneof" json:"fullSyncRequest,omitempty"` +type Sync_Content_Value_FullSyncRequest struct { + FullSyncRequest *Sync_Full_Request `protobuf:"bytes,2,opt,name=fullSyncRequest,proto3,oneof" json:"fullSyncRequest,omitempty"` } -type SyncContentValueValueOfFullSyncResponse struct { - FullSyncResponse *SyncFullResponse `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` +type Sync_Content_Value_FullSyncResponse struct { + FullSyncResponse *Sync_Full_Response `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` } -func (*SyncContentValueValueOfHeadUpdate) IsSyncContentValueValue() {} -func (*SyncContentValueValueOfFullSyncRequest) IsSyncContentValueValue() {} -func (*SyncContentValueValueOfFullSyncResponse) IsSyncContentValueValue() {} +func (*Sync_Content_Value_HeadUpdate) isSync_Content_Value_Value() {} +func (*Sync_Content_Value_FullSyncRequest) isSync_Content_Value_Value() {} +func (*Sync_Content_Value_FullSyncResponse) isSync_Content_Value_Value() {} -func (m *SyncContentValue) GetValue() IsSyncContentValueValue { +func (m *Sync_ContentValue) GetValue() isSync_Content_Value_Value { if m != nil { return m.Value } return nil } -func (m *SyncContentValue) GetHeadUpdate() *SyncHeadUpdate { - if x, ok := m.GetValue().(*SyncContentValueValueOfHeadUpdate); ok { +func (m *Sync_ContentValue) GetHeadUpdate() *Sync_HeadUpdate { + if x, ok := m.GetValue().(*Sync_Content_Value_HeadUpdate); ok { return x.HeadUpdate } return nil } -func (m *SyncContentValue) GetFullSyncRequest() *SyncFullRequest { - if x, ok := m.GetValue().(*SyncContentValueValueOfFullSyncRequest); ok { +func (m *Sync_ContentValue) GetFullSyncRequest() *Sync_Full_Request { + if x, ok := m.GetValue().(*Sync_Content_Value_FullSyncRequest); ok { return x.FullSyncRequest } return nil } -func (m *SyncContentValue) GetFullSyncResponse() *SyncFullResponse { - if x, ok := m.GetValue().(*SyncContentValueValueOfFullSyncResponse); ok { +func (m *Sync_ContentValue) GetFullSyncResponse() *Sync_Full_Response { + if x, ok := m.GetValue().(*Sync_Content_Value_FullSyncResponse); ok { return x.FullSyncResponse } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*SyncContentValue) XXX_OneofWrappers() []interface{} { +func (*Sync_ContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*SyncContentValueValueOfHeadUpdate)(nil), - (*SyncContentValueValueOfFullSyncRequest)(nil), - (*SyncContentValueValueOfFullSyncResponse)(nil), + (*Sync_Content_Value_HeadUpdate)(nil), + (*Sync_Content_Value_FullSyncRequest)(nil), + (*Sync_Content_Value_FullSyncResponse)(nil), } } -type SyncHeadUpdate struct { +type Sync_HeadUpdate struct { Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"` @@ -607,18 +607,18 @@ type SyncHeadUpdate struct { TreeHeader *treepb.TreeHeader `protobuf:"bytes,5,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` } -func (m *SyncHeadUpdate) Reset() { *m = SyncHeadUpdate{} } -func (m *SyncHeadUpdate) String() string { return proto.CompactTextString(m) } -func (*SyncHeadUpdate) ProtoMessage() {} -func (*SyncHeadUpdate) Descriptor() ([]byte, []int) { +func (m *Sync_HeadUpdate) Reset() { *m = Sync_HeadUpdate{} } +func (m *Sync_HeadUpdate) String() string { return proto.CompactTextString(m) } +func (*Sync_HeadUpdate) ProtoMessage() {} +func (*Sync_HeadUpdate) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{3, 1} } -func (m *SyncHeadUpdate) XXX_Unmarshal(b []byte) error { +func (m *Sync_HeadUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SyncHeadUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Sync_HeadUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SyncHeadUpdate.Marshal(b, m, deterministic) + return xxx_messageInfo_Sync_HeadUpdate.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -628,68 +628,68 @@ func (m *SyncHeadUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, erro return b[:n], nil } } -func (m *SyncHeadUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncHeadUpdate.Merge(m, src) +func (m *Sync_HeadUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sync_HeadUpdate.Merge(m, src) } -func (m *SyncHeadUpdate) XXX_Size() int { +func (m *Sync_HeadUpdate) XXX_Size() int { return m.Size() } -func (m *SyncHeadUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_SyncHeadUpdate.DiscardUnknown(m) +func (m *Sync_HeadUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_Sync_HeadUpdate.DiscardUnknown(m) } -var xxx_messageInfo_SyncHeadUpdate proto.InternalMessageInfo +var xxx_messageInfo_Sync_HeadUpdate proto.InternalMessageInfo -func (m *SyncHeadUpdate) GetHeads() []string { +func (m *Sync_HeadUpdate) GetHeads() []string { if m != nil { return m.Heads } return nil } -func (m *SyncHeadUpdate) GetChanges() []*aclpb.RawChange { +func (m *Sync_HeadUpdate) GetChanges() []*aclpb.RawChange { if m != nil { return m.Changes } return nil } -func (m *SyncHeadUpdate) GetTreeId() string { +func (m *Sync_HeadUpdate) GetTreeId() string { if m != nil { return m.TreeId } return "" } -func (m *SyncHeadUpdate) GetSnapshotPath() []string { +func (m *Sync_HeadUpdate) GetSnapshotPath() []string { if m != nil { return m.SnapshotPath } return nil } -func (m *SyncHeadUpdate) GetTreeHeader() *treepb.TreeHeader { +func (m *Sync_HeadUpdate) GetTreeHeader() *treepb.TreeHeader { if m != nil { return m.TreeHeader } return nil } -type SyncFull struct { +type Sync_Full struct { } -func (m *SyncFull) Reset() { *m = SyncFull{} } -func (m *SyncFull) String() string { return proto.CompactTextString(m) } -func (*SyncFull) ProtoMessage() {} -func (*SyncFull) Descriptor() ([]byte, []int) { +func (m *Sync_Full) Reset() { *m = Sync_Full{} } +func (m *Sync_Full) String() string { return proto.CompactTextString(m) } +func (*Sync_Full) ProtoMessage() {} +func (*Sync_Full) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{3, 2} } -func (m *SyncFull) XXX_Unmarshal(b []byte) error { +func (m *Sync_Full) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SyncFull) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Sync_Full) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SyncFull.Marshal(b, m, deterministic) + return xxx_messageInfo_Sync_Full.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -699,20 +699,20 @@ func (m *SyncFull) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *SyncFull) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFull.Merge(m, src) +func (m *Sync_Full) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sync_Full.Merge(m, src) } -func (m *SyncFull) XXX_Size() int { +func (m *Sync_Full) XXX_Size() int { return m.Size() } -func (m *SyncFull) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFull.DiscardUnknown(m) +func (m *Sync_Full) XXX_DiscardUnknown() { + xxx_messageInfo_Sync_Full.DiscardUnknown(m) } -var xxx_messageInfo_SyncFull proto.InternalMessageInfo +var xxx_messageInfo_Sync_Full proto.InternalMessageInfo // here with send the request with all changes we have (we already know sender's snapshot path) -type SyncFullRequest struct { +type Sync_Full_Request struct { Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"` @@ -720,18 +720,18 @@ type SyncFullRequest struct { TreeHeader *treepb.TreeHeader `protobuf:"bytes,5,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` } -func (m *SyncFullRequest) Reset() { *m = SyncFullRequest{} } -func (m *SyncFullRequest) String() string { return proto.CompactTextString(m) } -func (*SyncFullRequest) ProtoMessage() {} -func (*SyncFullRequest) Descriptor() ([]byte, []int) { +func (m *Sync_Full_Request) Reset() { *m = Sync_Full_Request{} } +func (m *Sync_Full_Request) String() string { return proto.CompactTextString(m) } +func (*Sync_Full_Request) ProtoMessage() {} +func (*Sync_Full_Request) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{3, 2, 0} } -func (m *SyncFullRequest) XXX_Unmarshal(b []byte) error { +func (m *Sync_Full_Request) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SyncFullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Sync_Full_Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SyncFullRequest.Marshal(b, m, deterministic) + return xxx_messageInfo_Sync_Full_Request.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -741,54 +741,54 @@ func (m *SyncFullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *SyncFullRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFullRequest.Merge(m, src) +func (m *Sync_Full_Request) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sync_Full_Request.Merge(m, src) } -func (m *SyncFullRequest) XXX_Size() int { +func (m *Sync_Full_Request) XXX_Size() int { return m.Size() } -func (m *SyncFullRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFullRequest.DiscardUnknown(m) +func (m *Sync_Full_Request) XXX_DiscardUnknown() { + xxx_messageInfo_Sync_Full_Request.DiscardUnknown(m) } -var xxx_messageInfo_SyncFullRequest proto.InternalMessageInfo +var xxx_messageInfo_Sync_Full_Request proto.InternalMessageInfo -func (m *SyncFullRequest) GetHeads() []string { +func (m *Sync_Full_Request) GetHeads() []string { if m != nil { return m.Heads } return nil } -func (m *SyncFullRequest) GetChanges() []*aclpb.RawChange { +func (m *Sync_Full_Request) GetChanges() []*aclpb.RawChange { if m != nil { return m.Changes } return nil } -func (m *SyncFullRequest) GetTreeId() string { +func (m *Sync_Full_Request) GetTreeId() string { if m != nil { return m.TreeId } return "" } -func (m *SyncFullRequest) GetSnapshotPath() []string { +func (m *Sync_Full_Request) GetSnapshotPath() []string { if m != nil { return m.SnapshotPath } return nil } -func (m *SyncFullRequest) GetTreeHeader() *treepb.TreeHeader { +func (m *Sync_Full_Request) GetTreeHeader() *treepb.TreeHeader { if m != nil { return m.TreeHeader } return nil } -type SyncFullResponse struct { +type Sync_Full_Response struct { Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"` @@ -796,18 +796,18 @@ type SyncFullResponse struct { TreeHeader *treepb.TreeHeader `protobuf:"bytes,5,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` } -func (m *SyncFullResponse) Reset() { *m = SyncFullResponse{} } -func (m *SyncFullResponse) String() string { return proto.CompactTextString(m) } -func (*SyncFullResponse) ProtoMessage() {} -func (*SyncFullResponse) Descriptor() ([]byte, []int) { +func (m *Sync_Full_Response) Reset() { *m = Sync_Full_Response{} } +func (m *Sync_Full_Response) String() string { return proto.CompactTextString(m) } +func (*Sync_Full_Response) ProtoMessage() {} +func (*Sync_Full_Response) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{3, 2, 1} } -func (m *SyncFullResponse) XXX_Unmarshal(b []byte) error { +func (m *Sync_Full_Response) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SyncFullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *Sync_Full_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SyncFullResponse.Marshal(b, m, deterministic) + return xxx_messageInfo_Sync_Full_Response.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -817,47 +817,47 @@ func (m *SyncFullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *SyncFullResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFullResponse.Merge(m, src) +func (m *Sync_Full_Response) XXX_Merge(src proto.Message) { + xxx_messageInfo_Sync_Full_Response.Merge(m, src) } -func (m *SyncFullResponse) XXX_Size() int { +func (m *Sync_Full_Response) XXX_Size() int { return m.Size() } -func (m *SyncFullResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFullResponse.DiscardUnknown(m) +func (m *Sync_Full_Response) XXX_DiscardUnknown() { + xxx_messageInfo_Sync_Full_Response.DiscardUnknown(m) } -var xxx_messageInfo_SyncFullResponse proto.InternalMessageInfo +var xxx_messageInfo_Sync_Full_Response proto.InternalMessageInfo -func (m *SyncFullResponse) GetHeads() []string { +func (m *Sync_Full_Response) GetHeads() []string { if m != nil { return m.Heads } return nil } -func (m *SyncFullResponse) GetChanges() []*aclpb.RawChange { +func (m *Sync_Full_Response) GetChanges() []*aclpb.RawChange { if m != nil { return m.Changes } return nil } -func (m *SyncFullResponse) GetTreeId() string { +func (m *Sync_Full_Response) GetTreeId() string { if m != nil { return m.TreeId } return "" } -func (m *SyncFullResponse) GetSnapshotPath() []string { +func (m *Sync_Full_Response) GetSnapshotPath() []string { if m != nil { return m.SnapshotPath } return nil } -func (m *SyncFullResponse) GetTreeHeader() *treepb.TreeHeader { +func (m *Sync_Full_Response) GetTreeHeader() *treepb.TreeHeader { if m != nil { return m.TreeHeader } @@ -866,20 +866,20 @@ func (m *SyncFullResponse) GetTreeHeader() *treepb.TreeHeader { func init() { proto.RegisterEnum("anytype.MessageType", MessageType_name, MessageType_value) - proto.RegisterEnum("anytype.SystemErrorCode", SystemErrorCode_name, SystemErrorCode_value) + proto.RegisterEnum("anytype.System_Error_Code", System_Error_Code_name, System_Error_Code_value) proto.RegisterType((*Message)(nil), "anytype.Message") proto.RegisterType((*Header)(nil), "anytype.Header") proto.RegisterType((*System)(nil), "anytype.System") - proto.RegisterType((*SystemHandshake)(nil), "anytype.System.Handshake") - proto.RegisterType((*SystemPing)(nil), "anytype.System.Ping") - proto.RegisterType((*SystemAck)(nil), "anytype.System.Ack") - proto.RegisterType((*SystemError)(nil), "anytype.System.Error") + proto.RegisterType((*System_Handshake)(nil), "anytype.System.Handshake") + proto.RegisterType((*System_Ping)(nil), "anytype.System.Ping") + proto.RegisterType((*System_Ack)(nil), "anytype.System.Ack") + proto.RegisterType((*System_Error)(nil), "anytype.System.Error") proto.RegisterType((*Sync)(nil), "anytype.Sync") - proto.RegisterType((*SyncContentValue)(nil), "anytype.Sync.ContentValue") - proto.RegisterType((*SyncHeadUpdate)(nil), "anytype.Sync.HeadUpdate") - proto.RegisterType((*SyncFull)(nil), "anytype.Sync.Full") - proto.RegisterType((*SyncFullRequest)(nil), "anytype.Sync.Full.Request") - proto.RegisterType((*SyncFullResponse)(nil), "anytype.Sync.Full.Response") + proto.RegisterType((*Sync_ContentValue)(nil), "anytype.Sync.ContentValue") + proto.RegisterType((*Sync_HeadUpdate)(nil), "anytype.Sync.HeadUpdate") + proto.RegisterType((*Sync_Full)(nil), "anytype.Sync.Full") + proto.RegisterType((*Sync_Full_Request)(nil), "anytype.Sync.Full.Request") + proto.RegisterType((*Sync_Full_Response)(nil), "anytype.Sync.Full.Response") } func init() { proto.RegisterFile("syncproto/proto/sync.proto", fileDescriptor_4b28dfdd48a89166) } @@ -1091,7 +1091,7 @@ func (m *System) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemHandshake) Marshal() (dAtA []byte, err error) { +func (m *System_Handshake) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1101,12 +1101,12 @@ func (m *SystemHandshake) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemHandshake) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Handshake) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemHandshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Handshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1121,7 +1121,7 @@ func (m *SystemHandshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemPing) Marshal() (dAtA []byte, err error) { +func (m *System_Ping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1131,12 +1131,12 @@ func (m *SystemPing) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemPing) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Ping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Ping) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1149,7 +1149,7 @@ func (m *SystemPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemAck) Marshal() (dAtA []byte, err error) { +func (m *System_Ack) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1159,12 +1159,12 @@ func (m *SystemAck) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemAck) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Ack) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Ack) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1184,7 +1184,7 @@ func (m *SystemAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemError) Marshal() (dAtA []byte, err error) { +func (m *System_Error) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1194,12 +1194,12 @@ func (m *SystemError) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemError) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Error) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemError) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1261,7 +1261,7 @@ func (m *Sync) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SyncContentValue) Marshal() (dAtA []byte, err error) { +func (m *Sync_ContentValue) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1271,12 +1271,12 @@ func (m *SyncContentValue) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SyncContentValue) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_ContentValue) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_ContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1293,12 +1293,12 @@ func (m *SyncContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SyncContentValueValueOfHeadUpdate) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_HeadUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncContentValueValueOfHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.HeadUpdate != nil { { @@ -1314,12 +1314,12 @@ func (m *SyncContentValueValueOfHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (i } return len(dAtA) - i, nil } -func (m *SyncContentValueValueOfFullSyncRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_FullSyncRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncContentValueValueOfFullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_FullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.FullSyncRequest != nil { { @@ -1335,12 +1335,12 @@ func (m *SyncContentValueValueOfFullSyncRequest) MarshalToSizedBuffer(dAtA []byt } return len(dAtA) - i, nil } -func (m *SyncContentValueValueOfFullSyncResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_FullSyncResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncContentValueValueOfFullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Content_Value_FullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.FullSyncResponse != nil { { @@ -1356,7 +1356,7 @@ func (m *SyncContentValueValueOfFullSyncResponse) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } -func (m *SyncHeadUpdate) Marshal() (dAtA []byte, err error) { +func (m *Sync_HeadUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1366,12 +1366,12 @@ func (m *SyncHeadUpdate) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SyncHeadUpdate) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_HeadUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1430,7 +1430,7 @@ func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SyncFull) Marshal() (dAtA []byte, err error) { +func (m *Sync_Full) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1440,12 +1440,12 @@ func (m *SyncFull) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SyncFull) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Full) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncFull) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Full) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1453,7 +1453,7 @@ func (m *SyncFull) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SyncFullRequest) Marshal() (dAtA []byte, err error) { +func (m *Sync_Full_Request) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1463,12 +1463,12 @@ func (m *SyncFullRequest) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SyncFullRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Full_Request) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncFullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Full_Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1527,7 +1527,7 @@ func (m *SyncFullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SyncFullResponse) Marshal() (dAtA []byte, err error) { +func (m *Sync_Full_Response) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1537,12 +1537,12 @@ func (m *SyncFullResponse) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SyncFullResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_Full_Response) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SyncFullResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_Full_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1676,7 +1676,7 @@ func (m *System) Size() (n int) { return n } -func (m *SystemHandshake) Size() (n int) { +func (m *System_Handshake) Size() (n int) { if m == nil { return 0 } @@ -1689,7 +1689,7 @@ func (m *SystemHandshake) Size() (n int) { return n } -func (m *SystemPing) Size() (n int) { +func (m *System_Ping) Size() (n int) { if m == nil { return 0 } @@ -1701,7 +1701,7 @@ func (m *SystemPing) Size() (n int) { return n } -func (m *SystemAck) Size() (n int) { +func (m *System_Ack) Size() (n int) { if m == nil { return 0 } @@ -1714,7 +1714,7 @@ func (m *SystemAck) Size() (n int) { return n } -func (m *SystemError) Size() (n int) { +func (m *System_Error) Size() (n int) { if m == nil { return 0 } @@ -1747,7 +1747,7 @@ func (m *Sync) Size() (n int) { return n } -func (m *SyncContentValue) Size() (n int) { +func (m *Sync_ContentValue) Size() (n int) { if m == nil { return 0 } @@ -1759,7 +1759,7 @@ func (m *SyncContentValue) Size() (n int) { return n } -func (m *SyncContentValueValueOfHeadUpdate) Size() (n int) { +func (m *Sync_Content_Value_HeadUpdate) Size() (n int) { if m == nil { return 0 } @@ -1771,7 +1771,7 @@ func (m *SyncContentValueValueOfHeadUpdate) Size() (n int) { } return n } -func (m *SyncContentValueValueOfFullSyncRequest) Size() (n int) { +func (m *Sync_Content_Value_FullSyncRequest) Size() (n int) { if m == nil { return 0 } @@ -1783,7 +1783,7 @@ func (m *SyncContentValueValueOfFullSyncRequest) Size() (n int) { } return n } -func (m *SyncContentValueValueOfFullSyncResponse) Size() (n int) { +func (m *Sync_Content_Value_FullSyncResponse) Size() (n int) { if m == nil { return 0 } @@ -1795,7 +1795,7 @@ func (m *SyncContentValueValueOfFullSyncResponse) Size() (n int) { } return n } -func (m *SyncHeadUpdate) Size() (n int) { +func (m *Sync_HeadUpdate) Size() (n int) { if m == nil { return 0 } @@ -1830,7 +1830,7 @@ func (m *SyncHeadUpdate) Size() (n int) { return n } -func (m *SyncFull) Size() (n int) { +func (m *Sync_Full) Size() (n int) { if m == nil { return 0 } @@ -1839,7 +1839,7 @@ func (m *SyncFull) Size() (n int) { return n } -func (m *SyncFullRequest) Size() (n int) { +func (m *Sync_Full_Request) Size() (n int) { if m == nil { return 0 } @@ -1874,7 +1874,7 @@ func (m *SyncFullRequest) Size() (n int) { return n } -func (m *SyncFullResponse) Size() (n int) { +func (m *Sync_Full_Response) Size() (n int) { if m == nil { return 0 } @@ -2267,7 +2267,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Handshake == nil { - m.Handshake = &SystemHandshake{} + m.Handshake = &System_Handshake{} } if err := m.Handshake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2303,7 +2303,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Ping == nil { - m.Ping = &SystemPing{} + m.Ping = &System_Ping{} } if err := m.Ping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2339,7 +2339,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Ack == nil { - m.Ack = &SystemAck{} + m.Ack = &System_Ack{} } if err := m.Ack.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2366,7 +2366,7 @@ func (m *System) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemHandshake) Unmarshal(dAtA []byte) error { +func (m *System_Handshake) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2448,7 +2448,7 @@ func (m *SystemHandshake) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemPing) Unmarshal(dAtA []byte) error { +func (m *System_Ping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2517,7 +2517,7 @@ func (m *SystemPing) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemAck) Unmarshal(dAtA []byte) error { +func (m *System_Ack) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2576,7 +2576,7 @@ func (m *SystemAck) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Error == nil { - m.Error = &SystemError{} + m.Error = &System_Error{} } if err := m.Error.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2603,7 +2603,7 @@ func (m *SystemAck) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemError) Unmarshal(dAtA []byte) error { +func (m *System_Error) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2646,7 +2646,7 @@ func (m *SystemError) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Code |= SystemErrorCode(b&0x7F) << shift + m.Code |= System_Error_Code(b&0x7F) << shift if b < 0x80 { break } @@ -2795,7 +2795,7 @@ func (m *Sync) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Message == nil { - m.Message = &SyncContentValue{} + m.Message = &Sync_ContentValue{} } if err := m.Message.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2822,7 +2822,7 @@ func (m *Sync) Unmarshal(dAtA []byte) error { } return nil } -func (m *SyncContentValue) Unmarshal(dAtA []byte) error { +func (m *Sync_ContentValue) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2880,11 +2880,11 @@ func (m *SyncContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &SyncHeadUpdate{} + v := &Sync_HeadUpdate{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &SyncContentValueValueOfHeadUpdate{v} + m.Value = &Sync_Content_Value_HeadUpdate{v} iNdEx = postIndex case 2: if wireType != 2 { @@ -2915,11 +2915,11 @@ func (m *SyncContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &SyncFullRequest{} + v := &Sync_Full_Request{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &SyncContentValueValueOfFullSyncRequest{v} + m.Value = &Sync_Content_Value_FullSyncRequest{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -2950,11 +2950,11 @@ func (m *SyncContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &SyncFullResponse{} + v := &Sync_Full_Response{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &SyncContentValueValueOfFullSyncResponse{v} + m.Value = &Sync_Content_Value_FullSyncResponse{v} iNdEx = postIndex default: iNdEx = preIndex @@ -2977,7 +2977,7 @@ func (m *SyncContentValue) Unmarshal(dAtA []byte) error { } return nil } -func (m *SyncHeadUpdate) Unmarshal(dAtA []byte) error { +func (m *Sync_HeadUpdate) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3193,7 +3193,7 @@ func (m *SyncHeadUpdate) Unmarshal(dAtA []byte) error { } return nil } -func (m *SyncFull) Unmarshal(dAtA []byte) error { +func (m *Sync_Full) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3243,7 +3243,7 @@ func (m *SyncFull) Unmarshal(dAtA []byte) error { } return nil } -func (m *SyncFullRequest) Unmarshal(dAtA []byte) error { +func (m *Sync_Full_Request) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3459,7 +3459,7 @@ func (m *SyncFullRequest) Unmarshal(dAtA []byte) error { } return nil } -func (m *SyncFullResponse) Unmarshal(dAtA []byte) error { +func (m *Sync_Full_Response) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { From 7afde45ac69747636b496b2ba803ec196882abce Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Wed, 7 Sep 2022 19:49:54 +0300 Subject: [PATCH 02/44] change proto generator to std gogo: fix tests --- pkg/acl/acltree/treegraph_nix.go | 2 +- .../treestoragebuilder/treestoragebuilder.go | 14 +++++++------- .../treestoragebuildergraph_nix.go | 2 +- service/space/space.go | 4 ++-- 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/pkg/acl/acltree/treegraph_nix.go b/pkg/acl/acltree/treegraph_nix.go index 72dc0c7d..68382fad 100644 --- a/pkg/acl/acltree/treegraph_nix.go +++ b/pkg/acl/acltree/treegraph_nix.go @@ -60,7 +60,7 @@ func (t *Tree) Graph() (data string, err error) { if c.Content.AclData != nil { for _, chc := range c.Content.AclData.AclContent { tp := fmt.Sprintf("%T", chc.Value) - tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1) + tp = strings.Replace(tp, "ACLChange_ACLContent_Value_", "", 1) res := "" for _, ts := range tp { if unicode.IsUpper(ts) { diff --git a/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go b/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go index 3b7c6f7d..162a3f5f 100644 --- a/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go +++ b/pkg/acl/testutils/treestoragebuilder/treestoragebuilder.go @@ -361,7 +361,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha } convCh = &aclpb.ACLChange_ACLContentValue{ - Value: &aclpb.ACLChange_ACLContentValueValueOfUserJoin{ + Value: &aclpb.ACLChange_ACLContent_Value_UserJoin{ UserJoin: &aclpb.ACLChange_UserJoin{ Identity: t.keychain.GetIdentity(join.Identity), EncryptionKey: rawKey, @@ -379,7 +379,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha rawEncKey, _ := encKey.GetPublic().Raw() convCh = &aclpb.ACLChange_ACLContentValue{ - Value: &aclpb.ACLChange_ACLContentValueValueOfUserInvite{ + Value: &aclpb.ACLChange_ACLContent_Value_UserInvite{ UserInvite: &aclpb.ACLChange_UserInvite{ AcceptPublicKey: rawAcceptKey, EncryptPublicKey: rawEncKey, @@ -393,7 +393,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha confirm := ch.UserConfirm convCh = &aclpb.ACLChange_ACLContentValue{ - Value: &aclpb.ACLChange_ACLContentValueValueOfUserConfirm{ + Value: &aclpb.ACLChange_ACLContent_Value_UserConfirm{ UserConfirm: &aclpb.ACLChange_UserConfirm{ Identity: t.keychain.GetIdentity(confirm.Identity), UserAddId: confirm.UserAddId, @@ -404,7 +404,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha permissionChange := ch.UserPermissionChange convCh = &aclpb.ACLChange_ACLContentValue{ - Value: &aclpb.ACLChange_ACLContentValueValueOfUserPermissionChange{ + Value: &aclpb.ACLChange_ACLContent_Value_UserPermissionChange{ UserPermissionChange: &aclpb.ACLChange_UserPermissionChange{ Identity: t.keychain.GetIdentity(permissionChange.Identity), Permissions: t.convertPermission(permissionChange.Permission), @@ -416,7 +416,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey) - var replaces []*aclpb.ACLChangeReadKeyReplace + var replaces []*aclpb.ACLChange_ReadKeyReplace for _, id := range remove.IdentitiesLeft { identity := t.keychain.GetIdentity(id) encKey := t.keychain.EncryptionKeys[id] @@ -425,7 +425,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha if err != nil { panic(err) } - replaces = append(replaces, &aclpb.ACLChangeReadKeyReplace{ + replaces = append(replaces, &aclpb.ACLChange_ReadKeyReplace{ Identity: identity, EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, @@ -433,7 +433,7 @@ func (t *TreeStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLCha } convCh = &aclpb.ACLChange_ACLContentValue{ - Value: &aclpb.ACLChange_ACLContentValueValueOfUserRemove{ + Value: &aclpb.ACLChange_ACLContent_Value_UserRemove{ UserRemove: &aclpb.ACLChange_UserRemove{ Identity: t.keychain.GetIdentity(remove.RemovedIdentity), ReadKeyReplaces: replaces, diff --git a/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go b/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go index 9d973a24..a68cb0a1 100644 --- a/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go +++ b/pkg/acl/testutils/treestoragebuilder/treestoragebuildergraph_nix.go @@ -66,7 +66,7 @@ func (t *TreeStorageBuilder) Graph() (string, error) { if r.GetAclData() != nil { for _, chc := range r.GetAclData().AclContent { tp := fmt.Sprintf("%T", chc.Value) - tp = strings.Replace(tp, "ACLChange_ACLContentValueValueOf", "", 1) + tp = strings.Replace(tp, "ACLChange_ACLContent_Value_", "", 1) res := "" for _, ts := range tp { if unicode.IsUpper(ts) { diff --git a/service/space/space.go b/service/space/space.go index f35452c1..59f04932 100644 --- a/service/space/space.go +++ b/service/space/space.go @@ -72,8 +72,8 @@ func (s *space) Handle(ctx context.Context, msg *spacesync.Space) (repl *spacesy if er != nil { return nil, er } - return &spacesync.Space{SpaceId: s.id, Message: &spacesync.SpaceContent{ - Value: &spacesync.SpaceContent_Value_DiffRange{ + return &spacesync.Space{SpaceId: s.id, Message: &spacesync.Space_Content{ + Value: &spacesync.Space_Content_DiffRange{ DiffRange: resp, }, }}, nil From 11cb1e1f31a2be87c4205d9a324c56b8de3df792 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 8 Sep 2022 00:00:46 +0300 Subject: [PATCH 03/44] drpc space service, new pool, new peer --- Makefile | 2 +- cmd/node/node.go | 2 +- go.mod | 2 +- go.sum | 2 + pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 116 +- pkg/ocache/ocache.go | 20 +- service/configuration/configuration.go | 4 +- service/net/dialer/dialer.go | 20 +- service/net/peer/peer.go | 70 +- service/net/pool/handler/reply.go | 32 - service/net/pool/message.go | 136 -- service/net/pool/peer.go | 28 - service/net/pool/pool.go | 375 +--- service/net/pool/pool_test.go | 213 ++ service/net/pool/request.go | 45 - service/net/pool/result.go | 53 - service/net/rpc/encoding.go | 18 - service/net/rpc/server/drpcserver.go | 18 +- service/net/rpc/stream.go | 55 - service/space/service.go | 24 +- service/space/space.go | 18 - .../space/spacesync/protos/spacesync.proto | 73 +- service/space/spacesync/spacesync.pb.go | 1713 ++++++----------- service/space/spacesync/spacesync_drpc.pb.go | 113 ++ syncproto/sync.pb.go | 62 +- 25 files changed, 1123 insertions(+), 2091 deletions(-) delete mode 100644 service/net/pool/handler/reply.go delete mode 100644 service/net/pool/message.go delete mode 100644 service/net/pool/peer.go create mode 100644 service/net/pool/pool_test.go delete mode 100644 service/net/pool/request.go delete mode 100644 service/net/pool/result.go delete mode 100644 service/net/rpc/encoding.go delete mode 100644 service/net/rpc/stream.go create mode 100644 service/space/spacesync/spacesync_drpc.pb.go diff --git a/Makefile b/Makefile index 82cb14de..8d0d2cb3 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ protos-go: $(GOGO_START) protoc --gogofaster_out=:. $(P_PLAINTEXT_CHANGES_PATH_PB)/protos/*.proto; mv $(P_PLAINTEXT_CHANGES_PATH_PB)/protos/*.go $(P_PLAINTEXT_CHANGES_PATH_PB) $(eval PKGMAP := $$(P_ACL_CHANGES),$$(P_TREE_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. service/space/spacesync/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. service/space/spacesync/protos/*.proto build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) diff --git a/cmd/node/node.go b/cmd/node/node.go index d9433a35..d6ded226 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -97,7 +97,7 @@ func Bootstrap(a *app.App) { Register(secure.New()). Register(server.New()). Register(dialer.New()). - Register(pool.NewPool()). + Register(pool.New()). Register(configuration.New()). Register(document.New()). Register(message.New()). diff --git a/go.mod b/go.mod index e27f9d45..47537c53 100644 --- a/go.mod +++ b/go.mod @@ -47,7 +47,7 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/zeebo/errs v1.2.2 // indirect + github.com/zeebo/errs v1.3.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect diff --git a/go.sum b/go.sum index 84667305..ba61ef8a 100644 --- a/go.sum +++ b/go.sum @@ -119,6 +119,8 @@ github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= +github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= +github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= github.com/zeebo/pcg v1.0.1/go.mod h1:09F0S9iiKrwn9rlI5yjLkmrug154/YRW6KnnXVDM/l4= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index d42f22ba..a6d2fca5 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -218,13 +218,13 @@ func (m *ACLChange) GetIdentity() string { type ACLChange_ACLContentValue struct { // Types that are valid to be assigned to Value: // - // *ACLChange_ACLContent_Value_UserAdd - // *ACLChange_ACLContent_Value_UserRemove - // *ACLChange_ACLContent_Value_UserPermissionChange - // *ACLChange_ACLContent_Value_UserInvite - // *ACLChange_ACLContent_Value_UserJoin - // *ACLChange_ACLContent_Value_UserConfirm - Value isACLChange_ACLContent_Value_Value `protobuf_oneof:"value"` + // *ACLChange_ACLContentValue_UserAdd + // *ACLChange_ACLContentValue_UserRemove + // *ACLChange_ACLContentValue_UserPermissionChange + // *ACLChange_ACLContentValue_UserInvite + // *ACLChange_ACLContentValue_UserJoin + // *ACLChange_ACLContentValue_UserConfirm + Value isACLChange_ACLContentValue_Value `protobuf_oneof:"value"` } func (m *ACLChange_ACLContentValue) Reset() { *m = ACLChange_ACLContentValue{} } @@ -260,39 +260,39 @@ func (m *ACLChange_ACLContentValue) XXX_DiscardUnknown() { var xxx_messageInfo_ACLChange_ACLContentValue proto.InternalMessageInfo -type isACLChange_ACLContent_Value_Value interface { - isACLChange_ACLContent_Value_Value() +type isACLChange_ACLContentValue_Value interface { + isACLChange_ACLContentValue_Value() MarshalTo([]byte) (int, error) Size() int } -type ACLChange_ACLContent_Value_UserAdd struct { +type ACLChange_ACLContentValue_UserAdd struct { UserAdd *ACLChange_UserAdd `protobuf:"bytes,1,opt,name=userAdd,proto3,oneof" json:"userAdd,omitempty"` } -type ACLChange_ACLContent_Value_UserRemove struct { +type ACLChange_ACLContentValue_UserRemove struct { UserRemove *ACLChange_UserRemove `protobuf:"bytes,2,opt,name=userRemove,proto3,oneof" json:"userRemove,omitempty"` } -type ACLChange_ACLContent_Value_UserPermissionChange struct { +type ACLChange_ACLContentValue_UserPermissionChange struct { UserPermissionChange *ACLChange_UserPermissionChange `protobuf:"bytes,3,opt,name=userPermissionChange,proto3,oneof" json:"userPermissionChange,omitempty"` } -type ACLChange_ACLContent_Value_UserInvite struct { +type ACLChange_ACLContentValue_UserInvite struct { UserInvite *ACLChange_UserInvite `protobuf:"bytes,4,opt,name=userInvite,proto3,oneof" json:"userInvite,omitempty"` } -type ACLChange_ACLContent_Value_UserJoin struct { +type ACLChange_ACLContentValue_UserJoin struct { UserJoin *ACLChange_UserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` } -type ACLChange_ACLContent_Value_UserConfirm struct { +type ACLChange_ACLContentValue_UserConfirm struct { UserConfirm *ACLChange_UserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` } -func (*ACLChange_ACLContent_Value_UserAdd) isACLChange_ACLContent_Value_Value() {} -func (*ACLChange_ACLContent_Value_UserRemove) isACLChange_ACLContent_Value_Value() {} -func (*ACLChange_ACLContent_Value_UserPermissionChange) isACLChange_ACLContent_Value_Value() {} -func (*ACLChange_ACLContent_Value_UserInvite) isACLChange_ACLContent_Value_Value() {} -func (*ACLChange_ACLContent_Value_UserJoin) isACLChange_ACLContent_Value_Value() {} -func (*ACLChange_ACLContent_Value_UserConfirm) isACLChange_ACLContent_Value_Value() {} +func (*ACLChange_ACLContentValue_UserAdd) isACLChange_ACLContentValue_Value() {} +func (*ACLChange_ACLContentValue_UserRemove) isACLChange_ACLContentValue_Value() {} +func (*ACLChange_ACLContentValue_UserPermissionChange) isACLChange_ACLContentValue_Value() {} +func (*ACLChange_ACLContentValue_UserInvite) isACLChange_ACLContentValue_Value() {} +func (*ACLChange_ACLContentValue_UserJoin) isACLChange_ACLContentValue_Value() {} +func (*ACLChange_ACLContentValue_UserConfirm) isACLChange_ACLContentValue_Value() {} -func (m *ACLChange_ACLContentValue) GetValue() isACLChange_ACLContent_Value_Value { +func (m *ACLChange_ACLContentValue) GetValue() isACLChange_ACLContentValue_Value { if m != nil { return m.Value } @@ -300,42 +300,42 @@ func (m *ACLChange_ACLContentValue) GetValue() isACLChange_ACLContent_Value_Valu } func (m *ACLChange_ACLContentValue) GetUserAdd() *ACLChange_UserAdd { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserAdd); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserAdd); ok { return x.UserAdd } return nil } func (m *ACLChange_ACLContentValue) GetUserRemove() *ACLChange_UserRemove { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserRemove); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserRemove); ok { return x.UserRemove } return nil } func (m *ACLChange_ACLContentValue) GetUserPermissionChange() *ACLChange_UserPermissionChange { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserPermissionChange); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserPermissionChange); ok { return x.UserPermissionChange } return nil } func (m *ACLChange_ACLContentValue) GetUserInvite() *ACLChange_UserInvite { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserInvite); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserInvite); ok { return x.UserInvite } return nil } func (m *ACLChange_ACLContentValue) GetUserJoin() *ACLChange_UserJoin { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserJoin); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserJoin); ok { return x.UserJoin } return nil } func (m *ACLChange_ACLContentValue) GetUserConfirm() *ACLChange_UserConfirm { - if x, ok := m.GetValue().(*ACLChange_ACLContent_Value_UserConfirm); ok { + if x, ok := m.GetValue().(*ACLChange_ACLContentValue_UserConfirm); ok { return x.UserConfirm } return nil @@ -344,12 +344,12 @@ func (m *ACLChange_ACLContentValue) GetUserConfirm() *ACLChange_UserConfirm { // XXX_OneofWrappers is for the internal use of the proto package. func (*ACLChange_ACLContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*ACLChange_ACLContent_Value_UserAdd)(nil), - (*ACLChange_ACLContent_Value_UserRemove)(nil), - (*ACLChange_ACLContent_Value_UserPermissionChange)(nil), - (*ACLChange_ACLContent_Value_UserInvite)(nil), - (*ACLChange_ACLContent_Value_UserJoin)(nil), - (*ACLChange_ACLContent_Value_UserConfirm)(nil), + (*ACLChange_ACLContentValue_UserAdd)(nil), + (*ACLChange_ACLContentValue_UserRemove)(nil), + (*ACLChange_ACLContentValue_UserPermissionChange)(nil), + (*ACLChange_ACLContentValue_UserInvite)(nil), + (*ACLChange_ACLContentValue_UserJoin)(nil), + (*ACLChange_ACLContentValue_UserConfirm)(nil), } } @@ -1271,12 +1271,12 @@ func (m *ACLChange_ACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserAdd) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserAdd != nil { { @@ -1292,12 +1292,12 @@ func (m *ACLChange_ACLContent_Value_UserAdd) MarshalToSizedBuffer(dAtA []byte) ( } return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserRemove) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserRemove) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserRemove != nil { { @@ -1313,12 +1313,12 @@ func (m *ACLChange_ACLContent_Value_UserRemove) MarshalToSizedBuffer(dAtA []byte } return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserPermissionChange) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserPermissionChange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserPermissionChange != nil { { @@ -1334,12 +1334,12 @@ func (m *ACLChange_ACLContent_Value_UserPermissionChange) MarshalToSizedBuffer(d } return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserInvite) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserInvite) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserInvite != nil { { @@ -1355,12 +1355,12 @@ func (m *ACLChange_ACLContent_Value_UserInvite) MarshalToSizedBuffer(dAtA []byte } return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserJoin) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserJoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserJoin != nil { { @@ -1376,12 +1376,12 @@ func (m *ACLChange_ACLContent_Value_UserJoin) MarshalToSizedBuffer(dAtA []byte) } return len(dAtA) - i, nil } -func (m *ACLChange_ACLContent_Value_UserConfirm) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserConfirm) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChange_ACLContent_Value_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLChange_ACLContentValue_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserConfirm != nil { { @@ -2039,7 +2039,7 @@ func (m *ACLChange_ACLContentValue) Size() (n int) { return n } -func (m *ACLChange_ACLContent_Value_UserAdd) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserAdd) Size() (n int) { if m == nil { return 0 } @@ -2051,7 +2051,7 @@ func (m *ACLChange_ACLContent_Value_UserAdd) Size() (n int) { } return n } -func (m *ACLChange_ACLContent_Value_UserRemove) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserRemove) Size() (n int) { if m == nil { return 0 } @@ -2063,7 +2063,7 @@ func (m *ACLChange_ACLContent_Value_UserRemove) Size() (n int) { } return n } -func (m *ACLChange_ACLContent_Value_UserPermissionChange) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserPermissionChange) Size() (n int) { if m == nil { return 0 } @@ -2075,7 +2075,7 @@ func (m *ACLChange_ACLContent_Value_UserPermissionChange) Size() (n int) { } return n } -func (m *ACLChange_ACLContent_Value_UserInvite) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserInvite) Size() (n int) { if m == nil { return 0 } @@ -2087,7 +2087,7 @@ func (m *ACLChange_ACLContent_Value_UserInvite) Size() (n int) { } return n } -func (m *ACLChange_ACLContent_Value_UserJoin) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserJoin) Size() (n int) { if m == nil { return 0 } @@ -2099,7 +2099,7 @@ func (m *ACLChange_ACLContent_Value_UserJoin) Size() (n int) { } return n } -func (m *ACLChange_ACLContent_Value_UserConfirm) Size() (n int) { +func (m *ACLChange_ACLContentValue_UserConfirm) Size() (n int) { if m == nil { return 0 } @@ -2871,7 +2871,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserAdd{v} + m.Value = &ACLChange_ACLContentValue_UserAdd{v} iNdEx = postIndex case 2: if wireType != 2 { @@ -2906,7 +2906,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserRemove{v} + m.Value = &ACLChange_ACLContentValue_UserRemove{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -2941,7 +2941,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserPermissionChange{v} + m.Value = &ACLChange_ACLContentValue_UserPermissionChange{v} iNdEx = postIndex case 4: if wireType != 2 { @@ -2976,7 +2976,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserInvite{v} + m.Value = &ACLChange_ACLContentValue_UserInvite{v} iNdEx = postIndex case 5: if wireType != 2 { @@ -3011,7 +3011,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserJoin{v} + m.Value = &ACLChange_ACLContentValue_UserJoin{v} iNdEx = postIndex case 6: if wireType != 2 { @@ -3046,7 +3046,7 @@ func (m *ACLChange_ACLContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChange_ACLContent_Value_UserConfirm{v} + m.Value = &ACLChange_ACLContentValue_UserConfirm{v} iNdEx = postIndex default: iNdEx = preIndex diff --git a/pkg/ocache/ocache.go b/pkg/ocache/ocache.go index b0460ca6..5e10508a 100644 --- a/pkg/ocache/ocache.go +++ b/pkg/ocache/ocache.go @@ -69,10 +69,13 @@ type Object interface { } type ObjectLocker interface { - Object Locked() bool } +type ObjectLastUsage interface { + LastUsage() time.Time +} + type entry struct { id string lastUsage time.Time @@ -99,7 +102,7 @@ type OCache interface { // When 'loadFunc' returns a non-nil error, an object will not be stored to cache Get(ctx context.Context, id string) (value Object, err error) // Pick returns value if it's presents in cache (will not call loadFunc) - Pick(id string) (value Object, err error) + Pick(ctx context.Context, id string) (value Object, err error) // Add adds new object to cache // Returns error when object exists Add(id string, value Object) (err error) @@ -166,13 +169,18 @@ func (c *oCache) Get(ctx context.Context, id string) (value Object, err error) { return e.value, e.loadErr } -func (c *oCache) Pick(id string) (value Object, err error) { +func (c *oCache) Pick(ctx context.Context, id string) (value Object, err error) { c.mu.Lock() val, ok := c.data[id] c.mu.Unlock() if !ok { return nil, ErrNotExists } + select { + case <-ctx.Done(): + return nil, ctx.Err() + case <-val.load: + } <-val.load return val.value, val.loadErr } @@ -307,7 +315,11 @@ func (c *oCache) GC() { deadline := c.timeNow().Add(-c.ttl) var toClose []*entry for k, e := range c.data { - if !e.locked() && e.refCount <= 0 && e.lastUsage.Before(deadline) { + lu := e.lastUsage + if lug, ok := e.value.(ObjectLastUsage); ok { + lu = lug.LastUsage() + } + if !e.locked() && e.refCount <= 0 && lu.Before(deadline) { delete(c.data, k) toClose = append(toClose, e) } diff --git a/service/configuration/configuration.go b/service/configuration/configuration.go index 5701eca6..c242d79d 100644 --- a/service/configuration/configuration.go +++ b/service/configuration/configuration.go @@ -40,7 +40,7 @@ func (c *configuration) AllPeers(ctx context.Context, spaceId string) (peers []p nodeIds := c.NodeIds(spaceId) peers = make([]peer.Peer, 0, len(nodeIds)) for _, id := range nodeIds { - p, e := c.pool.DialAndAddPeer(ctx, id) + p, e := c.pool.Get(ctx, id) if e == nil { peers = append(peers, p) } @@ -53,7 +53,7 @@ func (c *configuration) AllPeers(ctx context.Context, spaceId string) (peers []p func (c *configuration) OnePeer(ctx context.Context, spaceId string) (p peer.Peer, err error) { nodeIds := c.NodeIds(spaceId) - return c.pool.GetOrDialOneOf(ctx, nodeIds) + return c.pool.GetOneOf(ctx, nodeIds) } func (c *configuration) NodeIds(spaceId string) []string { diff --git a/service/net/dialer/dialer.go b/service/net/dialer/dialer.go index b90bf872..ade01444 100644 --- a/service/net/dialer/dialer.go +++ b/service/net/dialer/dialer.go @@ -7,7 +7,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" "github.com/libp2p/go-libp2p-core/sec" "go.uber.org/zap" @@ -60,7 +59,7 @@ func (d *dialer) UpdateAddrs(addrs map[string][]string) { d.mu.Unlock() } -func (d *dialer) Dial(ctx context.Context, peerId string) (peer peer.Peer, err error) { +func (d *dialer) Dial(ctx context.Context, peerId string) (p peer.Peer, err error) { d.mu.RLock() defer d.mu.RUnlock() addrs, ok := d.peerAddrs[peerId] @@ -68,11 +67,11 @@ func (d *dialer) Dial(ctx context.Context, peerId string) (peer peer.Peer, err e return nil, ErrArrdsNotFound } var ( - stream drpc.Stream - sc sec.SecureConn + conn drpc.Conn + sc sec.SecureConn ) for _, addr := range addrs { - stream, sc, err = d.makeStream(ctx, addr) + conn, sc, err = d.handshake(ctx, addr) if err != nil { log.Info("can't connect to host", zap.String("addr", addr)) } else { @@ -83,10 +82,10 @@ func (d *dialer) Dial(ctx context.Context, peerId string) (peer peer.Peer, err e if err != nil { return } - return rpc.PeerFromStream(sc, stream, false), nil + return peer.NewPeer(sc, conn), nil } -func (d *dialer) makeStream(ctx context.Context, addr string) (stream drpc.Stream, sc sec.SecureConn, err error) { +func (d *dialer) handshake(ctx context.Context, addr string) (conn drpc.Conn, sc sec.SecureConn, err error) { tcpConn, err := net.Dial("tcp", addr) if err != nil { return @@ -96,9 +95,6 @@ func (d *dialer) makeStream(ctx context.Context, addr string) (stream drpc.Strea return } log.Info("connected with remote host", zap.String("serverPeer", sc.RemotePeer().String()), zap.String("per", sc.LocalPeer().String())) - stream, err = drpcconn.New(sc).NewStream(ctx, "", rpc.Encoding) - if err != nil { - return - } - return stream, sc, err + conn = drpcconn.New(sc) + return conn, sc, err } diff --git a/service/net/peer/peer.go b/service/net/peer/peer.go index 331b0982..d73dc596 100644 --- a/service/net/peer/peer.go +++ b/service/net/peer/peer.go @@ -2,34 +2,58 @@ package peer import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" + "github.com/libp2p/go-libp2p-core/sec" + "storj.io/drpc" + "sync/atomic" "time" ) -type Dir uint - -const ( - // DirInbound indicates peer created connection - DirInbound Dir = iota - // DirOutbound indicates that our host created connection - DirOutbound -) - -type Info struct { - Id string - Dir Dir - LastActiveUnix int64 -} - -func (i Info) LastActive() time.Time { - return time.Unix(i.LastActiveUnix, 0) +func NewPeer(sc sec.SecureConn, conn drpc.Conn) Peer { + return &peer{ + id: sc.RemotePeer().String(), + lastUsage: time.Now().Unix(), + sc: sc, + Conn: conn, + } } type Peer interface { Id() string - Info() Info - Recv() (*syncproto.Message, error) - Send(msg *syncproto.Message) (err error) - Context() context.Context - Close() error + LastUsage() time.Time + UpdateLastUsage() + drpc.Conn +} + +type peer struct { + id string + lastUsage int64 + sc sec.SecureConn + drpc.Conn +} + +func (p *peer) Id() string { + return p.id +} + +func (p *peer) LastUsage() time.Time { + select { + case <-p.Closed(): + return time.Unix(0, 0) + default: + } + return time.Unix(atomic.LoadInt64(&p.lastUsage), 0) +} + +func (p *peer) Invoke(ctx context.Context, rpc string, enc drpc.Encoding, in, out drpc.Message) error { + defer p.UpdateLastUsage() + return p.Conn.Invoke(ctx, rpc, enc, in, out) +} + +func (p *peer) NewStream(ctx context.Context, rpc string, enc drpc.Encoding) (drpc.Stream, error) { + defer p.UpdateLastUsage() + return p.Conn.NewStream(ctx, rpc, enc) +} + +func (p *peer) UpdateLastUsage() { + atomic.StoreInt64(&p.lastUsage, time.Now().Unix()) } diff --git a/service/net/pool/handler/reply.go b/service/net/pool/handler/reply.go deleted file mode 100644 index 21dda1dd..00000000 --- a/service/net/pool/handler/reply.go +++ /dev/null @@ -1,32 +0,0 @@ -package handler - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/gogo/protobuf/proto" - "go.uber.org/zap" -) - -var log = logger.NewNamed("replyHandler") - -type ReplyHandler interface { - Handle(ctx context.Context, req []byte) (rep proto.Marshaler, err error) -} - -type Reply struct { - ReplyHandler -} - -func (r Reply) Handle(ctx context.Context, msg *pool.Message) error { - rep, e := r.ReplyHandler.Handle(ctx, msg.GetData()) - if msg.GetHeader().RequestId == 0 { - if e != nil { - log.Error("handler returned error", zap.Error(e)) - } else if rep != nil { - log.Debug("sender didn't expect a reply, but the handler made") - } - return nil - } - return msg.ReplyType(msg.GetHeader().GetType(), rep) -} diff --git a/service/net/pool/message.go b/service/net/pool/message.go deleted file mode 100644 index 15a76f2e..00000000 --- a/service/net/pool/message.go +++ /dev/null @@ -1,136 +0,0 @@ -package pool - -import ( - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/gogo/protobuf/proto" - "go.uber.org/zap" - "gopkg.in/mgo.v2/bson" -) - -type Message struct { - *syncproto.Message - peer peer.Peer -} - -func (m *Message) Peer() peer.Peer { - return m.peer -} - -func (m *Message) Reply(data []byte) (err error) { - rep := &syncproto.Message{ - Header: &syncproto.Header{ - TraceId: m.GetHeader().TraceId, - ReplyId: m.GetHeader().RequestId, - Type: syncproto.MessageType_MessageTypeSync, - }, - Data: data, - } - return m.peer.Send(rep) -} - -func (m *Message) ReplyType(tp syncproto.MessageType, data proto.Marshaler) (err error) { - dataBytes, err := data.Marshal() - if err != nil { - return err - } - rep := &syncproto.Message{ - Header: &syncproto.Header{ - TraceId: m.GetHeader().TraceId, - ReplyId: m.GetHeader().RequestId, - Type: tp, - }, - Data: dataBytes, - } - return m.peer.Send(rep) -} - -func (m *Message) Ack() (err error) { - ack := &syncproto.System{ - Ack: &syncproto.System_Ack{}, - } - data, err := ack.Marshal() - if err != nil { - return - } - rep := &syncproto.Message{ - Header: &syncproto.Header{ - TraceId: m.GetHeader().TraceId, - ReplyId: m.GetHeader().RequestId, - Type: syncproto.MessageType_MessageTypeSystem, - DebugInfo: "Ack", - }, - Data: data, - } - err = m.peer.Send(rep) - if err != nil { - log.With( - zap.String("peerId", m.peer.Id()), - zap.String("header", rep.GetHeader().String())). - Error("failed sending ack to peer", zap.Error(err)) - } else { - log.With( - zap.String("peerId", m.peer.Id()), - zap.String("header", rep.GetHeader().String())). - Debug("sent ack to peer") - } - return -} - -func (m *Message) AckError(code syncproto.System_Error_Code, description string) (err error) { - ack := &syncproto.System{ - Ack: &syncproto.System_Ack{ - Error: &syncproto.System_Error{ - Code: code, - Description: description, - }, - }, - } - data, err := ack.Marshal() - if err != nil { - return - } - rep := &syncproto.Message{ - Header: &syncproto.Header{ - TraceId: []byte(bson.NewObjectId()), - ReplyId: m.GetHeader().RequestId, - Type: syncproto.MessageType_MessageTypeSystem, - DebugInfo: "AckError", - }, - Data: data, - } - if err != nil { - log.With( - zap.String("peerId", m.peer.Id()), - zap.String("header", rep.GetHeader().String())). - Error("failed sending ackError to peer", zap.Error(err)) - } else { - log.With( - zap.String("peerId", m.peer.Id()), - zap.String("header", rep.GetHeader().String())). - Debug("sent ackError to peer") - } - return m.peer.Send(rep) -} - -func (m *Message) IsAck() (err error) { - if tp := m.GetHeader().GetType(); tp != syncproto.MessageType_MessageTypeSystem { - return fmt.Errorf("unexpected message type in response: %v, want System", tp) - } - sys := &syncproto.System{} - if err = sys.Unmarshal(m.GetData()); err != nil { - return - } - if ack := sys.Ack; ack != nil { - if ack.Error != nil { - return fmt.Errorf("response error: code=%d; descriptipon=%s", ack.Error.Code, ack.Error.Description) - } - return nil - } - return fmt.Errorf("received not ack response") -} - -func (m *Message) UnmarshalData(msg proto.Unmarshaler) error { - return msg.Unmarshal(m.Data) -} diff --git a/service/net/pool/peer.go b/service/net/pool/peer.go deleted file mode 100644 index 6a7a96d0..00000000 --- a/service/net/pool/peer.go +++ /dev/null @@ -1,28 +0,0 @@ -package pool - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" -) - -type peerEntry struct { - peer peer.Peer - groupIds []string - ready chan struct{} -} - -func (pe *peerEntry) addGroup(groupId string) (ok bool) { - if slice.FindPos(pe.groupIds, groupId) != -1 { - return false - } - pe.groupIds = append(pe.groupIds, groupId) - return true -} - -func (pe *peerEntry) removeGroup(groupId string) (ok bool) { - if slice.FindPos(pe.groupIds, groupId) == -1 { - return false - } - pe.groupIds = slice.Remove(pe.groupIds, groupId) - return true -} diff --git a/service/net/pool/pool.go b/service/net/pool/pool.go index 97a7dcc1..cbd0973a 100644 --- a/service/net/pool/pool.go +++ b/service/net/pool/pool.go @@ -3,72 +3,47 @@ package pool import ( "context" "errors" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" - "go.uber.org/zap" "math/rand" - "sync" - "sync/atomic" ) const ( - CName = "sync/peerPool" - maxSimultaneousOperationsPerStream = 10 + CName = "net.pool" ) -var log = logger.NewNamed("peerPool") +var log = logger.NewNamed(CName) var ( - ErrPoolClosed = errors.New("peer pool is closed") - ErrPeerNotFound = errors.New("peer not found") + ErrUnableToConnect = errors.New("unable to connect") ) -func NewPool() Pool { - return &pool{closed: true} +func New() Pool { + return &pool{} } -type Handler func(ctx context.Context, msg *Message) (err error) - +// Pool creates and caches outgoing connection type Pool interface { - AddAndReadPeer(peer peer.Peer) (err error) - AddHandler(msgType syncproto.MessageType, h Handler) - AddPeerIdToGroup(peerId, groupId string) (err error) - RemovePeerIdFromGroup(peerId, groupId string) (err error) - DialAndAddPeer(ctx context.Context, id string) (peer.Peer, error) - GetOrDialOneOf(ctx context.Context, peerIds []string) (peer.Peer, error) - - SendAndWait(ctx context.Context, peerId string, msg *syncproto.Message) (err error) - SendAndWaitResponse(ctx context.Context, id string, s *syncproto.Message) (resp *Message, err error) - Broadcast(ctx context.Context, groupId string, msg *syncproto.Message) (err error) + // Get lookups to peer in existing connections or creates and cache new one + Get(ctx context.Context, id string) (peer.Peer, error) + // GetOneOf searches at least one existing connection in cache or creates a new one from a randomly selected id from given list + GetOneOf(ctx context.Context, peerIds []string) (peer.Peer, error) app.ComponentRunnable } type pool struct { - peersById map[string]*peerEntry - waiters *waiters - handlers map[syncproto.MessageType][]Handler - peersIdsByGroup map[string][]string - - dialer dialer.Dialer - - closed bool - mu sync.RWMutex - wg *sync.WaitGroup + cache ocache.OCache } func (p *pool) Init(ctx context.Context, a *app.App) (err error) { - p.peersById = map[string]*peerEntry{} - p.handlers = map[syncproto.MessageType][]Handler{} - p.peersIdsByGroup = map[string][]string{} - p.waiters = &waiters{waiters: map[uint64]*waiter{}} - p.dialer = a.MustComponent(dialer.CName).(dialer.Dialer) - p.wg = &sync.WaitGroup{} + dialer := a.MustComponent(dialer.CName).(dialer.Dialer) + p.cache = ocache.New(func(ctx context.Context, id string) (value ocache.Object, err error) { + return dialer.Dial(ctx, id) + }) return nil } @@ -77,321 +52,49 @@ func (p *pool) Name() (name string) { } func (p *pool) Run(ctx context.Context) (err error) { - p.closed = false return nil } -func (p *pool) AddHandler(msgType syncproto.MessageType, h Handler) { - p.mu.Lock() - defer p.mu.Unlock() - if !p.closed { - // unable to add handler after Run - return - } - p.handlers[msgType] = append(p.handlers[msgType], h) -} - -func (p *pool) DialAndAddPeer(ctx context.Context, peerId string) (peer.Peer, error) { - p.mu.Lock() - defer p.mu.Unlock() - if p.closed { - return nil, ErrPoolClosed - } - return p.dialAndAdd(ctx, peerId) -} - -func (p *pool) dialAndAdd(ctx context.Context, peerId string) (peer.Peer, error) { - if peer, ok := p.peersById[peerId]; ok { - return peer.peer, nil - } - peer, err := p.dialer.Dial(ctx, peerId) +func (p *pool) Get(ctx context.Context, id string) (peer.Peer, error) { + v, err := p.cache.Get(ctx, id) if err != nil { return nil, err } - p.peersById[peer.Id()] = &peerEntry{ - peer: peer, - } - p.wg.Add(1) - go p.readPeerLoop(peer) - return peer, nil -} - -func (p *pool) AddAndReadPeer(peer peer.Peer) (err error) { - p.mu.Lock() - if p.closed { - p.mu.Unlock() - return ErrPoolClosed - } - p.peersById[peer.Id()] = &peerEntry{ - peer: peer, - } - p.wg.Add(1) - p.mu.Unlock() - return p.readPeerLoop(peer) -} - -func (p *pool) AddPeerIdToGroup(peerId, groupId string) (err error) { - p.mu.Lock() - defer p.mu.Unlock() - peer, ok := p.peersById[peerId] - if !ok { - return ErrPeerNotFound - } - if slice.FindPos(peer.groupIds, groupId) != -1 { - return nil - } - peer.addGroup(groupId) - p.peersIdsByGroup[groupId] = append(p.peersIdsByGroup[groupId], peerId) - return -} - -func (p *pool) RemovePeerIdFromGroup(peerId, groupId string) (err error) { - p.mu.Lock() - defer p.mu.Unlock() - peer, ok := p.peersById[peerId] - if !ok { - return ErrPeerNotFound - } - if slice.FindPos(peer.groupIds, groupId) == -1 { - return nil - } - peer.removeGroup(groupId) - p.peersIdsByGroup[groupId] = slice.Remove(p.peersIdsByGroup[groupId], peerId) - return -} - -func (p *pool) SendAndWait(ctx context.Context, peerId string, msg *syncproto.Message) (err error) { - resp, err := p.SendAndWaitResponse(ctx, peerId, msg) - if err != nil { - return - } - return resp.IsAck() -} - -func (p *pool) SendAndWaitResponse(ctx context.Context, peerId string, msg *syncproto.Message) (resp *Message, err error) { - defer func() { - if err != nil { - log.With( - zap.String("peerId", peerId), - zap.String("header", msg.GetHeader().String())). - Error("failed sending message to peer", zap.Error(err)) - } else { - log.With( - zap.String("peerId", peerId), - zap.String("header", msg.GetHeader().String())). - Debug("sent message to peer") - } - }() - - p.mu.RLock() - peer := p.peersById[peerId] - p.mu.RUnlock() - if peer == nil { - err = ErrPeerNotFound - return - } - - repId := p.waiters.NewReplyId() - msg.GetHeader().RequestId = repId - ch := make(chan Reply, 1) - - log.With(zap.Uint64("reply id", repId)).Debug("adding waiter for reply id") - p.waiters.Add(repId, &waiter{ch: ch}) - defer p.waiters.Remove(repId) - - if err = peer.peer.Send(msg); err != nil { - return - } + pr := v.(peer.Peer) select { - case rep := <-ch: - if rep.Error != nil { - err = rep.Error - return - } - resp = rep.Message - return - case <-ctx.Done(): - log.Debug("context done in SendAndWait") - err = ctx.Err() + case <-pr.Closed(): + default: + return pr, nil } - return + p.cache.Remove(id) + return p.Get(ctx, id) } -func (p *pool) GetOrDialOneOf(ctx context.Context, peerIds []string) (peer.Peer, error) { - p.mu.RLock() - if p.closed { - p.mu.RUnlock() - return nil, ErrPoolClosed - } +func (p *pool) GetOneOf(ctx context.Context, peerIds []string) (peer.Peer, error) { + // finding existing connection for _, peerId := range peerIds { - peer, ok := p.peersById[peerId] - if ok { - p.mu.RUnlock() - return peer.peer, nil + if v, err := p.cache.Pick(ctx, peerId); err == nil { + pr := v.(peer.Peer) + select { + case <-pr.Closed(): + default: + return pr, nil + } } } - p.mu.RUnlock() + // shuffle ids for better consistency rand.Shuffle(len(peerIds), func(i, j int) { peerIds[i], peerIds[j] = peerIds[j], peerIds[i] }) - p.mu.Lock() - defer p.mu.Unlock() - var lastErr error + // connecting for _, peerId := range peerIds { - peer, err := p.dialAndAdd(ctx, peerId) - if err != nil { - lastErr = err - continue - } else { - return peer, nil - } - } - return nil, lastErr -} - -func (p *pool) Broadcast(ctx context.Context, groupId string, msg *syncproto.Message) (err error) { - //TODO implement me - panic("implement me") -} - -func (p *pool) readPeerLoop(peer peer.Peer) (err error) { - defer p.wg.Done() - - limiter := make(chan struct{}, maxSimultaneousOperationsPerStream) - for i := 0; i < maxSimultaneousOperationsPerStream; i++ { - limiter <- struct{}{} - } -Loop: - for { - msg, err := peer.Recv() - if err != nil { - log.Debug("peer receive error", zap.Error(err), zap.String("peerId", peer.Id())) - break - } - select { - case <-limiter: - case <-peer.Context().Done(): - break Loop - } - go func() { - defer func() { - limiter <- struct{}{} - }() - p.handleMessage(peer, msg) - }() - } - if err = p.removePeer(peer.Id()); err != nil { - log.Error("remove peer error", zap.String("peerId", peer.Id()), zap.Error(err)) - } - return -} - -func (p *pool) removePeer(peerId string) (err error) { - p.mu.Lock() - defer p.mu.Unlock() - _, ok := p.peersById[peerId] - if !ok { - return ErrPeerNotFound - } - delete(p.peersById, peerId) - return -} - -func (p *pool) handleMessage(peer peer.Peer, msg *syncproto.Message) { - log.With(zap.String("peerId", peer.Id()), zap.String("header", msg.GetHeader().String())). - Debug("received message from peer") - replyId := msg.GetHeader().GetReplyId() - if replyId != 0 { - if !p.waiters.Send(replyId, Reply{ - PeerInfo: peer.Info(), - Message: &Message{ - Message: msg, - peer: peer, - }, - }) { - log.Debug("received reply with unknown (or expired) replyId", zap.Uint64("replyId", replyId), zap.String("header", msg.GetHeader().String())) - } - return - } - handlers := p.handlers[msg.GetHeader().GetType()] - if len(handlers) == 0 { - log.With(zap.String("peerId", peer.Id())).Debug("no handlers for such message") - return - } - - message := &Message{Message: msg, peer: peer} - - for _, h := range handlers { - if err := h(peer.Context(), message); err != nil { - log.Error("handle message error", zap.Error(err)) + if v, err := p.cache.Get(ctx, peerId); err == nil { + return v.(peer.Peer), nil } } + return nil, ErrUnableToConnect } func (p *pool) Close(ctx context.Context) (err error) { - p.mu.Lock() - for _, peer := range p.peersById { - peer.peer.Close() - } - wg := p.wg - p.mu.Unlock() - if wg != nil { - wg.Wait() - } - return nil -} - -type waiter struct { - sent int - ch chan<- Reply -} - -type waiters struct { - waiters map[uint64]*waiter - replySeq uint64 - mu sync.Mutex -} - -func (w *waiters) Send(replyId uint64, r Reply) (ok bool) { - w.mu.Lock() - wait := w.waiters[replyId] - if wait == nil { - w.mu.Unlock() - return false - } - wait.sent++ - var lastMessage = wait.sent == cap(wait.ch) - if lastMessage { - delete(w.waiters, replyId) - } - w.mu.Unlock() - wait.ch <- r - if lastMessage { - close(wait.ch) - } - return true -} - -func (w *waiters) Add(replyId uint64, wait *waiter) { - w.mu.Lock() - w.waiters[replyId] = wait - w.mu.Unlock() -} - -func (w *waiters) Remove(id uint64) error { - w.mu.Lock() - defer w.mu.Unlock() - if _, ok := w.waiters[id]; ok { - delete(w.waiters, id) - return nil - } - return fmt.Errorf("waiter not found") -} - -func (w *waiters) NewReplyId() uint64 { - res := atomic.AddUint64(&w.replySeq, 1) - if res == 0 { - return w.NewReplyId() - } - return res + return p.cache.Close() } diff --git a/service/net/pool/pool_test.go b/service/net/pool/pool_test.go new file mode 100644 index 00000000..efc51d38 --- /dev/null +++ b/service/net/pool/pool_test.go @@ -0,0 +1,213 @@ +package pool + +import ( + "context" + "errors" + "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "storj.io/drpc" + "testing" + "time" +) + +var ctx = context.Background() + +func TestPool_Get(t *testing.T) { + t.Run("dial error", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + var expErr = errors.New("dial error") + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return nil, expErr + } + p, err := fx.Get(ctx, "1") + assert.Nil(t, p) + assert.EqualError(t, err, expErr.Error()) + }) + t.Run("dial and cached", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return newTestPeer("1"), nil + } + p, err := fx.Get(ctx, "1") + assert.NoError(t, err) + assert.NotNil(t, p) + fx.Dialer.dial = nil + p, err = fx.Get(ctx, "1") + assert.NoError(t, err) + assert.NotNil(t, p) + }) + t.Run("retry for closed", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + tp := newTestPeer("1") + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return tp, nil + } + p, err := fx.Get(ctx, "1") + assert.NoError(t, err) + assert.NotNil(t, p) + p.Close() + tp2 := newTestPeer("1") + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return tp2, nil + } + p, err = fx.Get(ctx, "1") + assert.NoError(t, err) + assert.Equal(t, p, tp2) + }) +} + +func TestPool_GetOneOf(t *testing.T) { + addToCache := func(t *testing.T, fx *fixture, tp *testPeer) { + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return tp, nil + } + gp, err := fx.Get(ctx, tp.Id()) + require.NoError(t, err) + require.Equal(t, gp, tp) + } + + t.Run("from cache", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + tp1 := newTestPeer("1") + addToCache(t, fx, tp1) + p, err := fx.GetOneOf(ctx, []string{"3", "2", "1"}) + require.NoError(t, err) + assert.Equal(t, tp1, p) + }) + t.Run("from cache - skip closed", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + tp2 := newTestPeer("2") + addToCache(t, fx, tp2) + tp2.Close() + tp1 := newTestPeer("1") + addToCache(t, fx, tp1) + p, err := fx.GetOneOf(ctx, []string{"3", "2", "1"}) + require.NoError(t, err) + assert.Equal(t, tp1, p) + }) + t.Run("dial", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + var called bool + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + if called { + return nil, fmt.Errorf("not expected call") + } + called = true + return newTestPeer(peerId), nil + } + p, err := fx.GetOneOf(ctx, []string{"3", "2", "1"}) + require.NoError(t, err) + assert.NotNil(t, p) + }) + t.Run("unable to connect", func(t *testing.T) { + fx := newFixture(t) + defer fx.Finish() + fx.Dialer.dial = func(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return nil, fmt.Errorf("persistent error") + } + p, err := fx.GetOneOf(ctx, []string{"3", "2", "1"}) + assert.Equal(t, ErrUnableToConnect, err) + assert.Nil(t, p) + }) +} + +func newFixture(t *testing.T) *fixture { + fx := &fixture{ + Pool: New(), + Dialer: &dialerMock{}, + } + a := new(app.App) + a.Register(fx.Pool) + a.Register(fx.Dialer) + require.NoError(t, a.Start(context.Background())) + fx.a = a + fx.t = t + return fx +} + +func (fx *fixture) Finish() { + require.NoError(fx.t, fx.a.Close(context.Background())) +} + +type fixture struct { + Pool + Dialer *dialerMock + a *app.App + t *testing.T +} + +var _ dialer.Dialer = (*dialerMock)(nil) + +type dialerMock struct { + dial func(ctx context.Context, peerId string) (peer peer.Peer, err error) +} + +func (d *dialerMock) Dial(ctx context.Context, peerId string) (peer peer.Peer, err error) { + return d.dial(ctx, peerId) +} + +func (d *dialerMock) UpdateAddrs(addrs map[string][]string) { + return +} + +func (d *dialerMock) Init(ctx context.Context, a *app.App) (err error) { + return +} + +func (d *dialerMock) Name() (name string) { + return dialer.CName +} + +func newTestPeer(id string) *testPeer { + return &testPeer{ + id: id, + closed: make(chan struct{}), + } +} + +type testPeer struct { + id string + closed chan struct{} +} + +func (t *testPeer) Id() string { + return t.id +} + +func (t *testPeer) LastUsage() time.Time { + return time.Now() +} + +func (t *testPeer) UpdateLastUsage() {} + +func (t *testPeer) Close() error { + select { + case <-t.closed: + return fmt.Errorf("already closed") + default: + close(t.closed) + } + return nil +} + +func (t *testPeer) Closed() <-chan struct{} { + return t.closed +} + +func (t *testPeer) Invoke(ctx context.Context, rpc string, enc drpc.Encoding, in, out drpc.Message) error { + return fmt.Errorf("call Invoke on test peer") +} + +func (t *testPeer) NewStream(ctx context.Context, rpc string, enc drpc.Encoding) (drpc.Stream, error) { + return nil, fmt.Errorf("call NewStream on test peer") +} diff --git a/service/net/pool/request.go b/service/net/pool/request.go deleted file mode 100644 index 8584f0dd..00000000 --- a/service/net/pool/request.go +++ /dev/null @@ -1,45 +0,0 @@ -package pool - -import "context" - -// 1. message for one peerId with ack -// pool.SendAndWait(ctx context,.C -// 2. message for many peers without ack (or group) - -type Request struct { - groupId string - oneOf []string - all []string - tryDial bool - needReply bool - pool *pool -} - -func (r *Request) GroupId(groupId string) *Request { - r.groupId = groupId - return r -} - -func (r *Request) All(peerIds ...string) *Request { - r.all = peerIds - return r -} - -func (r *Request) OneOf(peerIds ...string) *Request { - r.oneOf = peerIds - return r -} - -func (r *Request) TryDial(is bool) *Request { - r.tryDial = is - return r -} - -func (r *Request) NeedReply(is bool) *Request { - r.needReply = is - return r -} - -func (r *Request) Exec(ctx context.Context, msg *Message) *Results { - return nil -} diff --git a/service/net/pool/result.go b/service/net/pool/result.go deleted file mode 100644 index 94f1ac93..00000000 --- a/service/net/pool/result.go +++ /dev/null @@ -1,53 +0,0 @@ -package pool - -import ( - "context" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" -) - -// Results of request collects replies and errors -// Must be closed after usage r.Close() -type Results struct { - ctx context.Context - cancel func() - waiterId uint64 - ch chan Reply - pool *pool -} - -// Iterate iterates over replies -// if callback will return a non-nil error then iteration stops -func (r *Results) Iterate(callback func(r Reply) (err error)) (err error) { - if r.ctx == nil || r.ch == nil { - return fmt.Errorf("results not initialized") - } - for { - select { - case <-r.ctx.Done(): - return r.ctx.Err() - case m, ok := <-r.ch: - if ok { - if err = callback(m); err != nil { - return err - } - } else { - return - } - } - } -} - -// Close cancels iteration and unregister reply handler in the pool -// Required to call to avoid memory leaks -func (r *Results) Close() (err error) { - r.cancel() - return r.pool.waiters.Remove(r.waiterId) -} - -// Reply presents the result of request executing can be error or result message -type Reply struct { - PeerInfo peer.Info - Error error - Message *Message -} diff --git a/service/net/rpc/encoding.go b/service/net/rpc/encoding.go deleted file mode 100644 index eb983b9d..00000000 --- a/service/net/rpc/encoding.go +++ /dev/null @@ -1,18 +0,0 @@ -package rpc - -import ( - "github.com/gogo/protobuf/proto" - "storj.io/drpc" -) - -var Encoding = enc{} - -type enc struct{} - -func (e enc) Marshal(msg drpc.Message) ([]byte, error) { - return msg.(proto.Marshaler).Marshal() -} - -func (e enc) Unmarshal(buf []byte, msg drpc.Message) error { - return msg.(proto.Unmarshaler).Unmarshal(buf) -} diff --git a/service/net/rpc/server/drpcserver.go b/service/net/rpc/server/drpcserver.go index dcdf2156..1af9af7b 100644 --- a/service/net/rpc/server/drpcserver.go +++ b/service/net/rpc/server/drpcserver.go @@ -6,11 +6,11 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" "go.uber.org/zap" "net" "storj.io/drpc" + "storj.io/drpc/drpcmux" "storj.io/drpc/drpcserver" "strings" "time" @@ -21,11 +21,12 @@ const CName = "net/drpcserver" var log = logger.NewNamed(CName) func New() DRPCServer { - return &drpcServer{} + return &drpcServer{Mux: drpcmux.New()} } type DRPCServer interface { app.ComponentRunnable + drpc.Mux } type drpcServer struct { @@ -35,6 +36,7 @@ type drpcServer struct { listeners []secure.ContextListener pool pool.Pool cancel func() + *drpcmux.Mux } func (s *drpcServer) Init(ctx context.Context, a *app.App) (err error) { @@ -49,7 +51,7 @@ func (s *drpcServer) Name() (name string) { } func (s *drpcServer) Run(ctx context.Context) (err error) { - s.drpcServer = drpcserver.New(s) + s.drpcServer = drpcserver.New(s.Mux) ctx, s.cancel = context.WithCancel(ctx) for _, addr := range s.config.ListenAddrs { tcpList, err := net.Listen("tcp", addr) @@ -109,16 +111,6 @@ func (s *drpcServer) serveConn(ctx context.Context, conn net.Conn) { } } -func (s *drpcServer) HandleRPC(stream drpc.Stream, _ string) (err error) { - ctx := stream.Context() - sc, err := secure.CtxSecureConn(ctx) - if err != nil { - return - } - log.With(zap.String("peer", sc.RemotePeer().String())).Debug("stream opened") - return s.pool.AddAndReadPeer(rpc.PeerFromStream(sc, stream, true)) -} - func (s *drpcServer) Close(ctx context.Context) (err error) { if s.cancel != nil { s.cancel() diff --git a/service/net/rpc/stream.go b/service/net/rpc/stream.go deleted file mode 100644 index c05691da..00000000 --- a/service/net/rpc/stream.go +++ /dev/null @@ -1,55 +0,0 @@ -package rpc - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/libp2p/go-libp2p-core/sec" - "storj.io/drpc" - "sync/atomic" - "time" -) - -func PeerFromStream(sc sec.SecureConn, stream drpc.Stream, incoming bool) peer.Peer { - dp := &drpcPeer{ - sc: sc, - Stream: stream, - } - dp.info.Id = sc.RemotePeer().String() - if incoming { - dp.info.Dir = peer.DirInbound - } else { - dp.info.Dir = peer.DirOutbound - } - return dp -} - -type drpcPeer struct { - sc sec.SecureConn - info peer.Info - drpc.Stream -} - -func (d *drpcPeer) Id() string { - return d.info.Id -} - -func (d *drpcPeer) Info() peer.Info { - return d.info -} - -func (d *drpcPeer) Recv() (msg *syncproto.Message, err error) { - msg = &syncproto.Message{} - if err = d.Stream.MsgRecv(msg, Encoding); err != nil { - return - } - atomic.StoreInt64(&d.info.LastActiveUnix, time.Now().Unix()) - return -} - -func (d *drpcPeer) Send(msg *syncproto.Message) (err error) { - if err = d.Stream.MsgSend(msg, Encoding); err != nil { - return - } - atomic.StoreInt64(&d.info.LastActiveUnix, time.Now().Unix()) - return -} diff --git a/service/space/service.go b/service/space/service.go index 5e61366d..183b5425 100644 --- a/service/space/service.go +++ b/service/space/service.go @@ -9,10 +9,9 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool/handler" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/gogo/protobuf/proto" + "storj.io/drpc/drpcerr" "time" ) @@ -25,7 +24,7 @@ func New() Service { } type Service interface { - handler.ReplyHandler + spacesync.DRPCSpaceServer app.ComponentRunnable } @@ -42,7 +41,7 @@ func (s *service) Init(ctx context.Context, a *app.App) (err error) { s.confService = a.MustComponent(configuration.CName).(configuration.Service) ttlSec := time.Second * time.Duration(s.conf.GCTTL) s.cache = ocache.New(s.loadSpace, ocache.WithTTL(ttlSec), ocache.WithGCPeriod(time.Minute)) - s.pool.AddHandler(syncproto.MessageType_MessageTypeSpace, handler.Reply{ReplyHandler: s}.Handle) + spacesync.DRPCRegisterSpace(a.MustComponent(server.CName).(server.DRPCServer), s) return nil } @@ -72,19 +71,8 @@ func (s *service) get(ctx context.Context, id string) (Space, error) { return obj.(Space), nil } -func (s *service) Handle(ctx context.Context, data []byte) (resp proto.Marshaler, err error) { - var spaceReq = &spacesync.Space{} - if err = spaceReq.Unmarshal(data); err != nil { - return - } - if spaceReq.SpaceId != "" { - sp, e := s.get(ctx, spaceReq.SpaceId) - if e != nil { - return nil, e - } - return sp.Handle(ctx, spaceReq) - } - return nil, fmt.Errorf("unexpected space message") +func (s *service) HeadSync(ctx context.Context, request *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { + return nil, drpcerr.WithCode(fmt.Errorf("check"), 42) } func (s *service) Close(ctx context.Context) (err error) { diff --git a/service/space/space.go b/service/space/space.go index 59f04932..169fd408 100644 --- a/service/space/space.go +++ b/service/space/space.go @@ -6,7 +6,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/remotediff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" "go.uber.org/zap" "math/rand" "sync" @@ -15,7 +14,6 @@ import ( type Space interface { Id() string - Handle(ctx context.Context, msg *spacesync.Space) (repl *spacesync.Space, err error) Close() error } @@ -66,22 +64,6 @@ func (s *space) testFill() { s.diff.Set(els...) } -func (s *space) Handle(ctx context.Context, msg *spacesync.Space) (repl *spacesync.Space, err error) { - if diffRange := msg.GetMessage().GetDiffRange(); diffRange != nil { - resp, er := remotediff.HandlerRangeRequest(ctx, s.diff, diffRange) - if er != nil { - return nil, er - } - return &spacesync.Space{SpaceId: s.id, Message: &spacesync.Space_Content{ - Value: &spacesync.Space_Content_DiffRange{ - DiffRange: resp, - }, - }}, nil - } - - return nil, fmt.Errorf("unexpected request") -} - func (s *space) syncLoop() { defer close(s.syncLoopDone) doSync := func() { diff --git a/service/space/spacesync/protos/spacesync.proto b/service/space/spacesync/protos/spacesync.proto index b0b9cf0e..f0b68b11 100644 --- a/service/space/spacesync/protos/spacesync.proto +++ b/service/space/spacesync/protos/spacesync.proto @@ -1,41 +1,44 @@ syntax = "proto3"; -package anytype; +package anySpace; option go_package = "service/space/spacesync"; -message Space { - string spaceId = 1; - - Content message = 2; - - message Content { - oneof value { - DiffRange diffRange = 1; - } - } +enum ErrCodes { + Unexpected = 0; } -message DiffRange { - Request request = 1; - Response response = 2; +service Space { + // HeadSync compares all objects and their hashes in a space + rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse); +} - message Request { - repeated Range ranges = 1; - message Range { - uint64 from = 1; - uint64 to = 2; - uint32 limit = 3; - } - } - message Response { - repeated Result results = 1; - message Result { - bytes hash = 1; - repeated Element elements = 2; - uint32 count = 3; - message Element { - string id = 1; - string head = 2; - } - } - } -} \ No newline at end of file + +// HeadSyncRange presenting a request for one range +message HeadSyncRange { + uint64 from = 1; + uint64 to = 2; + uint32 limit = 3; +} + +// HeadSyncResult presenting a response for one range +message HeadSyncResult { + bytes hash = 1; + repeated HeadSyncResultElement elements = 2; + uint32 count = 3; +} + +// HeadSyncResultElement presenting state of one object +message HeadSyncResultElement { + string id = 1; + string head = 2; +} + +// HeadSyncRequest is a request for HeadSync +message HeadSyncRequest { + string spaceId = 1; + repeated HeadSyncRange ranges = 2; +} + +// HeadSyncResponse is a response for HeadSync +message HeadSyncResponse { + repeated HeadSyncResult results = 1; +} diff --git a/service/space/spacesync/spacesync.pb.go b/service/space/spacesync/spacesync.pb.go index af6fd478..92772dc4 100644 --- a/service/space/spacesync/spacesync.pb.go +++ b/service/space/spacesync/spacesync.pb.go @@ -22,245 +22,47 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type Space struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Message *Space_Content `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` +type ErrCodes int32 + +const ( + ErrCodes_Unexpected ErrCodes = 0 +) + +var ErrCodes_name = map[int32]string{ + 0: "Unexpected", } -func (m *Space) Reset() { *m = Space{} } -func (m *Space) String() string { return proto.CompactTextString(m) } -func (*Space) ProtoMessage() {} -func (*Space) Descriptor() ([]byte, []int) { +var ErrCodes_value = map[string]int32{ + "Unexpected": 0, +} + +func (x ErrCodes) String() string { + return proto.EnumName(ErrCodes_name, int32(x)) +} + +func (ErrCodes) EnumDescriptor() ([]byte, []int) { return fileDescriptor_11d78c2fb7c80384, []int{0} } -func (m *Space) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Space) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Space.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 *Space) XXX_Merge(src proto.Message) { - xxx_messageInfo_Space.Merge(m, src) -} -func (m *Space) XXX_Size() int { - return m.Size() -} -func (m *Space) XXX_DiscardUnknown() { - xxx_messageInfo_Space.DiscardUnknown(m) -} -var xxx_messageInfo_Space proto.InternalMessageInfo - -func (m *Space) GetSpaceId() string { - if m != nil { - return m.SpaceId - } - return "" -} - -func (m *Space) GetMessage() *Space_Content { - if m != nil { - return m.Message - } - return nil -} - -type Space_Content struct { - // Types that are valid to be assigned to Value: - // - // *Space_Content_DiffRange - Value isSpace_Content_Value `protobuf_oneof:"value"` -} - -func (m *Space_Content) Reset() { *m = Space_Content{} } -func (m *Space_Content) String() string { return proto.CompactTextString(m) } -func (*Space_Content) ProtoMessage() {} -func (*Space_Content) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{0, 0} -} -func (m *Space_Content) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Space_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Space_Content.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 *Space_Content) XXX_Merge(src proto.Message) { - xxx_messageInfo_Space_Content.Merge(m, src) -} -func (m *Space_Content) XXX_Size() int { - return m.Size() -} -func (m *Space_Content) XXX_DiscardUnknown() { - xxx_messageInfo_Space_Content.DiscardUnknown(m) -} - -var xxx_messageInfo_Space_Content proto.InternalMessageInfo - -type isSpace_Content_Value interface { - isSpace_Content_Value() - MarshalTo([]byte) (int, error) - Size() int -} - -type Space_Content_DiffRange struct { - DiffRange *DiffRange `protobuf:"bytes,1,opt,name=diffRange,proto3,oneof" json:"diffRange,omitempty"` -} - -func (*Space_Content_DiffRange) isSpace_Content_Value() {} - -func (m *Space_Content) GetValue() isSpace_Content_Value { - if m != nil { - return m.Value - } - return nil -} - -func (m *Space_Content) GetDiffRange() *DiffRange { - if x, ok := m.GetValue().(*Space_Content_DiffRange); ok { - return x.DiffRange - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*Space_Content) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*Space_Content_DiffRange)(nil), - } -} - -type DiffRange struct { - Request *DiffRange_Request `protobuf:"bytes,1,opt,name=request,proto3" json:"request,omitempty"` - Response *DiffRange_Response `protobuf:"bytes,2,opt,name=response,proto3" json:"response,omitempty"` -} - -func (m *DiffRange) Reset() { *m = DiffRange{} } -func (m *DiffRange) String() string { return proto.CompactTextString(m) } -func (*DiffRange) ProtoMessage() {} -func (*DiffRange) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1} -} -func (m *DiffRange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DiffRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DiffRange.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 *DiffRange) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange.Merge(m, src) -} -func (m *DiffRange) XXX_Size() int { - return m.Size() -} -func (m *DiffRange) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange.DiscardUnknown(m) -} - -var xxx_messageInfo_DiffRange proto.InternalMessageInfo - -func (m *DiffRange) GetRequest() *DiffRange_Request { - if m != nil { - return m.Request - } - return nil -} - -func (m *DiffRange) GetResponse() *DiffRange_Response { - if m != nil { - return m.Response - } - return nil -} - -type DiffRange_Request struct { - Ranges []*DiffRange_Request_Range `protobuf:"bytes,1,rep,name=ranges,proto3" json:"ranges,omitempty"` -} - -func (m *DiffRange_Request) Reset() { *m = DiffRange_Request{} } -func (m *DiffRange_Request) String() string { return proto.CompactTextString(m) } -func (*DiffRange_Request) ProtoMessage() {} -func (*DiffRange_Request) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1, 0} -} -func (m *DiffRange_Request) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DiffRange_Request) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DiffRange_Request.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 *DiffRange_Request) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange_Request.Merge(m, src) -} -func (m *DiffRange_Request) XXX_Size() int { - return m.Size() -} -func (m *DiffRange_Request) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange_Request.DiscardUnknown(m) -} - -var xxx_messageInfo_DiffRange_Request proto.InternalMessageInfo - -func (m *DiffRange_Request) GetRanges() []*DiffRange_Request_Range { - if m != nil { - return m.Ranges - } - return nil -} - -type DiffRange_Request_Range struct { +// HeadSyncRange presenting a request for one range +type HeadSyncRange struct { From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` To uint64 `protobuf:"varint,2,opt,name=to,proto3" json:"to,omitempty"` Limit uint32 `protobuf:"varint,3,opt,name=limit,proto3" json:"limit,omitempty"` } -func (m *DiffRange_Request_Range) Reset() { *m = DiffRange_Request_Range{} } -func (m *DiffRange_Request_Range) String() string { return proto.CompactTextString(m) } -func (*DiffRange_Request_Range) ProtoMessage() {} -func (*DiffRange_Request_Range) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1, 0, 0} +func (m *HeadSyncRange) Reset() { *m = HeadSyncRange{} } +func (m *HeadSyncRange) String() string { return proto.CompactTextString(m) } +func (*HeadSyncRange) ProtoMessage() {} +func (*HeadSyncRange) Descriptor() ([]byte, []int) { + return fileDescriptor_11d78c2fb7c80384, []int{0} } -func (m *DiffRange_Request_Range) XXX_Unmarshal(b []byte) error { +func (m *HeadSyncRange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRange_Request_Range) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HeadSyncRange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRange_Request_Range.Marshal(b, m, deterministic) + return xxx_messageInfo_HeadSyncRange.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -270,55 +72,58 @@ func (m *DiffRange_Request_Range) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *DiffRange_Request_Range) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange_Request_Range.Merge(m, src) +func (m *HeadSyncRange) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeadSyncRange.Merge(m, src) } -func (m *DiffRange_Request_Range) XXX_Size() int { +func (m *HeadSyncRange) XXX_Size() int { return m.Size() } -func (m *DiffRange_Request_Range) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange_Request_Range.DiscardUnknown(m) +func (m *HeadSyncRange) XXX_DiscardUnknown() { + xxx_messageInfo_HeadSyncRange.DiscardUnknown(m) } -var xxx_messageInfo_DiffRange_Request_Range proto.InternalMessageInfo +var xxx_messageInfo_HeadSyncRange proto.InternalMessageInfo -func (m *DiffRange_Request_Range) GetFrom() uint64 { +func (m *HeadSyncRange) GetFrom() uint64 { if m != nil { return m.From } return 0 } -func (m *DiffRange_Request_Range) GetTo() uint64 { +func (m *HeadSyncRange) GetTo() uint64 { if m != nil { return m.To } return 0 } -func (m *DiffRange_Request_Range) GetLimit() uint32 { +func (m *HeadSyncRange) GetLimit() uint32 { if m != nil { return m.Limit } return 0 } -type DiffRange_Response struct { - Results []*DiffRange_Response_Result `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +// HeadSyncResult presenting a response for one range +type HeadSyncResult struct { + Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` + Elements []*HeadSyncResultElement `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"` + Count uint32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"` } -func (m *DiffRange_Response) Reset() { *m = DiffRange_Response{} } -func (m *DiffRange_Response) String() string { return proto.CompactTextString(m) } -func (*DiffRange_Response) ProtoMessage() {} -func (*DiffRange_Response) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1, 1} +func (m *HeadSyncResult) Reset() { *m = HeadSyncResult{} } +func (m *HeadSyncResult) String() string { return proto.CompactTextString(m) } +func (*HeadSyncResult) ProtoMessage() {} +func (*HeadSyncResult) Descriptor() ([]byte, []int) { + return fileDescriptor_11d78c2fb7c80384, []int{1} } -func (m *DiffRange_Response) XXX_Unmarshal(b []byte) error { +func (m *HeadSyncResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRange_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HeadSyncResult) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRange_Response.Marshal(b, m, deterministic) + return xxx_messageInfo_HeadSyncResult.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -328,102 +133,57 @@ func (m *DiffRange_Response) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *DiffRange_Response) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange_Response.Merge(m, src) +func (m *HeadSyncResult) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeadSyncResult.Merge(m, src) } -func (m *DiffRange_Response) XXX_Size() int { +func (m *HeadSyncResult) XXX_Size() int { return m.Size() } -func (m *DiffRange_Response) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange_Response.DiscardUnknown(m) +func (m *HeadSyncResult) XXX_DiscardUnknown() { + xxx_messageInfo_HeadSyncResult.DiscardUnknown(m) } -var xxx_messageInfo_DiffRange_Response proto.InternalMessageInfo +var xxx_messageInfo_HeadSyncResult proto.InternalMessageInfo -func (m *DiffRange_Response) GetResults() []*DiffRange_Response_Result { - if m != nil { - return m.Results - } - return nil -} - -type DiffRange_Response_Result struct { - Hash []byte `protobuf:"bytes,1,opt,name=hash,proto3" json:"hash,omitempty"` - Elements []*DiffRange_Response_Result_Element `protobuf:"bytes,2,rep,name=elements,proto3" json:"elements,omitempty"` - Count uint32 `protobuf:"varint,3,opt,name=count,proto3" json:"count,omitempty"` -} - -func (m *DiffRange_Response_Result) Reset() { *m = DiffRange_Response_Result{} } -func (m *DiffRange_Response_Result) String() string { return proto.CompactTextString(m) } -func (*DiffRange_Response_Result) ProtoMessage() {} -func (*DiffRange_Response_Result) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0} -} -func (m *DiffRange_Response_Result) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *DiffRange_Response_Result) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_DiffRange_Response_Result.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 *DiffRange_Response_Result) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange_Response_Result.Merge(m, src) -} -func (m *DiffRange_Response_Result) XXX_Size() int { - return m.Size() -} -func (m *DiffRange_Response_Result) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange_Response_Result.DiscardUnknown(m) -} - -var xxx_messageInfo_DiffRange_Response_Result proto.InternalMessageInfo - -func (m *DiffRange_Response_Result) GetHash() []byte { +func (m *HeadSyncResult) GetHash() []byte { if m != nil { return m.Hash } return nil } -func (m *DiffRange_Response_Result) GetElements() []*DiffRange_Response_Result_Element { +func (m *HeadSyncResult) GetElements() []*HeadSyncResultElement { if m != nil { return m.Elements } return nil } -func (m *DiffRange_Response_Result) GetCount() uint32 { +func (m *HeadSyncResult) GetCount() uint32 { if m != nil { return m.Count } return 0 } -type DiffRange_Response_Result_Element struct { +// HeadSyncResultElement presenting state of one object +type HeadSyncResultElement struct { Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"` Head string `protobuf:"bytes,2,opt,name=head,proto3" json:"head,omitempty"` } -func (m *DiffRange_Response_Result_Element) Reset() { *m = DiffRange_Response_Result_Element{} } -func (m *DiffRange_Response_Result_Element) String() string { return proto.CompactTextString(m) } -func (*DiffRange_Response_Result_Element) ProtoMessage() {} -func (*DiffRange_Response_Result_Element) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1, 1, 0, 0} +func (m *HeadSyncResultElement) Reset() { *m = HeadSyncResultElement{} } +func (m *HeadSyncResultElement) String() string { return proto.CompactTextString(m) } +func (*HeadSyncResultElement) ProtoMessage() {} +func (*HeadSyncResultElement) Descriptor() ([]byte, []int) { + return fileDescriptor_11d78c2fb7c80384, []int{2} } -func (m *DiffRange_Response_Result_Element) XXX_Unmarshal(b []byte) error { +func (m *HeadSyncResultElement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *DiffRange_Response_Result_Element) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *HeadSyncResultElement) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_DiffRange_Response_Result_Element.Marshal(b, m, deterministic) + return xxx_messageInfo_HeadSyncResultElement.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -433,41 +193,137 @@ func (m *DiffRange_Response_Result_Element) XXX_Marshal(b []byte, deterministic return b[:n], nil } } -func (m *DiffRange_Response_Result_Element) XXX_Merge(src proto.Message) { - xxx_messageInfo_DiffRange_Response_Result_Element.Merge(m, src) +func (m *HeadSyncResultElement) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeadSyncResultElement.Merge(m, src) } -func (m *DiffRange_Response_Result_Element) XXX_Size() int { +func (m *HeadSyncResultElement) XXX_Size() int { return m.Size() } -func (m *DiffRange_Response_Result_Element) XXX_DiscardUnknown() { - xxx_messageInfo_DiffRange_Response_Result_Element.DiscardUnknown(m) +func (m *HeadSyncResultElement) XXX_DiscardUnknown() { + xxx_messageInfo_HeadSyncResultElement.DiscardUnknown(m) } -var xxx_messageInfo_DiffRange_Response_Result_Element proto.InternalMessageInfo +var xxx_messageInfo_HeadSyncResultElement proto.InternalMessageInfo -func (m *DiffRange_Response_Result_Element) GetId() string { +func (m *HeadSyncResultElement) GetId() string { if m != nil { return m.Id } return "" } -func (m *DiffRange_Response_Result_Element) GetHead() string { +func (m *HeadSyncResultElement) GetHead() string { if m != nil { return m.Head } return "" } +// HeadSyncRequest is a request for HeadSync +type HeadSyncRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Ranges []*HeadSyncRange `protobuf:"bytes,2,rep,name=ranges,proto3" json:"ranges,omitempty"` +} + +func (m *HeadSyncRequest) Reset() { *m = HeadSyncRequest{} } +func (m *HeadSyncRequest) String() string { return proto.CompactTextString(m) } +func (*HeadSyncRequest) ProtoMessage() {} +func (*HeadSyncRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_11d78c2fb7c80384, []int{3} +} +func (m *HeadSyncRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeadSyncRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeadSyncRequest.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 *HeadSyncRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeadSyncRequest.Merge(m, src) +} +func (m *HeadSyncRequest) XXX_Size() int { + return m.Size() +} +func (m *HeadSyncRequest) XXX_DiscardUnknown() { + xxx_messageInfo_HeadSyncRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_HeadSyncRequest proto.InternalMessageInfo + +func (m *HeadSyncRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *HeadSyncRequest) GetRanges() []*HeadSyncRange { + if m != nil { + return m.Ranges + } + return nil +} + +// HeadSyncResponse is a response for HeadSync +type HeadSyncResponse struct { + Results []*HeadSyncResult `protobuf:"bytes,1,rep,name=results,proto3" json:"results,omitempty"` +} + +func (m *HeadSyncResponse) Reset() { *m = HeadSyncResponse{} } +func (m *HeadSyncResponse) String() string { return proto.CompactTextString(m) } +func (*HeadSyncResponse) ProtoMessage() {} +func (*HeadSyncResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_11d78c2fb7c80384, []int{4} +} +func (m *HeadSyncResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *HeadSyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_HeadSyncResponse.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 *HeadSyncResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_HeadSyncResponse.Merge(m, src) +} +func (m *HeadSyncResponse) XXX_Size() int { + return m.Size() +} +func (m *HeadSyncResponse) XXX_DiscardUnknown() { + xxx_messageInfo_HeadSyncResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_HeadSyncResponse proto.InternalMessageInfo + +func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { + if m != nil { + return m.Results + } + return nil +} + func init() { - proto.RegisterType((*Space)(nil), "anytype.Space") - proto.RegisterType((*Space_Content)(nil), "anytype.Space.Content") - proto.RegisterType((*DiffRange)(nil), "anytype.DiffRange") - proto.RegisterType((*DiffRange_Request)(nil), "anytype.DiffRange.Request") - proto.RegisterType((*DiffRange_Request_Range)(nil), "anytype.DiffRange.Request.Range") - proto.RegisterType((*DiffRange_Response)(nil), "anytype.DiffRange.Response") - proto.RegisterType((*DiffRange_Response_Result)(nil), "anytype.DiffRange.Response.Result") - proto.RegisterType((*DiffRange_Response_Result_Element)(nil), "anytype.DiffRange.Response.Result.Element") + proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) + proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") + proto.RegisterType((*HeadSyncResult)(nil), "anySpace.HeadSyncResult") + proto.RegisterType((*HeadSyncResultElement)(nil), "anySpace.HeadSyncResultElement") + proto.RegisterType((*HeadSyncRequest)(nil), "anySpace.HeadSyncRequest") + proto.RegisterType((*HeadSyncResponse)(nil), "anySpace.HeadSyncResponse") } func init() { @@ -475,37 +331,34 @@ func init() { } var fileDescriptor_11d78c2fb7c80384 = []byte{ - // 428 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x92, 0xbf, 0x8e, 0xd4, 0x30, - 0x10, 0xc6, 0xd7, 0xd9, 0x3f, 0xde, 0xcc, 0x02, 0x85, 0x85, 0x20, 0x0a, 0x52, 0x14, 0x6d, 0x15, - 0x21, 0xe1, 0x83, 0x80, 0x04, 0x05, 0x0d, 0x07, 0x9c, 0xa0, 0x35, 0x1d, 0x5d, 0xd8, 0x78, 0xef, - 0x22, 0x25, 0x76, 0x88, 0x9d, 0x93, 0xf6, 0x05, 0xa8, 0xe9, 0x79, 0x02, 0xde, 0x84, 0xf2, 0x4a, - 0x4a, 0xb4, 0xfb, 0x0a, 0x54, 0x54, 0x28, 0x93, 0x38, 0x57, 0xc0, 0x42, 0x13, 0xcd, 0x8c, 0x7f, - 0xdf, 0x97, 0x6f, 0x2c, 0x03, 0x37, 0xb2, 0xb9, 0x2c, 0x36, 0xf2, 0xc4, 0xd4, 0x99, 0xfb, 0x9a, - 0x9d, 0xda, 0x9c, 0xd4, 0x8d, 0xb6, 0xda, 0x5c, 0x0f, 0x38, 0x0e, 0x18, 0xcd, 0xd4, 0xce, 0xee, - 0x6a, 0xb9, 0xfe, 0x42, 0x60, 0xfe, 0xae, 0x3b, 0x64, 0x01, 0x50, 0xa4, 0xde, 0xe6, 0x01, 0x89, - 0x49, 0xe2, 0x0b, 0xd7, 0xb2, 0x87, 0x40, 0x2b, 0x69, 0x4c, 0x76, 0x2e, 0x03, 0x2f, 0x26, 0xc9, - 0x2a, 0xbd, 0xc3, 0x07, 0x39, 0x47, 0x29, 0x7f, 0xa9, 0x95, 0x95, 0xca, 0x0a, 0x87, 0x85, 0x67, - 0x40, 0x87, 0x19, 0x4b, 0xc1, 0xcf, 0x8b, 0xed, 0x56, 0x64, 0xea, 0x5c, 0xa2, 0xf1, 0x2a, 0x65, - 0xa3, 0xfc, 0x95, 0x3b, 0x79, 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 0x76, 0x8b, 0x17, - 0xee, 0x9d, 0x79, 0x45, 0x8e, 0x61, 0x64, 0x96, 0xe3, 0x55, 0xf8, 0x02, 0xeb, 0xd3, 0x47, 0xdf, - 0xf6, 0x11, 0xb9, 0xda, 0x47, 0xe4, 0xc7, 0x3e, 0x22, 0x9f, 0x0f, 0xd1, 0xe4, 0xea, 0x10, 0x4d, - 0xbe, 0x1f, 0xa2, 0xc9, 0xfb, 0xbb, 0x47, 0x5e, 0xfb, 0x87, 0x05, 0xbe, 0xee, 0xc7, 0xbf, 0x03, - 0x00, 0x00, 0xff, 0xff, 0x12, 0x5a, 0x4f, 0xd6, 0x0f, 0x03, 0x00, 0x00, + // 369 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xbf, 0x6e, 0xe2, 0x40, + 0x10, 0xc6, 0x6d, 0xf3, 0xcf, 0xcc, 0x1d, 0x1c, 0x5a, 0xdd, 0x09, 0x1f, 0x85, 0x0f, 0xb9, 0x42, + 0x57, 0x18, 0x85, 0x94, 0x54, 0x49, 0x44, 0x14, 0x52, 0x2e, 0x4a, 0x13, 0xa5, 0x71, 0xec, 0x49, + 0xb0, 0x04, 0xbb, 0x8e, 0x77, 0x49, 0xc2, 0x5b, 0xe4, 0xb1, 0x52, 0x52, 0xa6, 0x8c, 0xe0, 0x45, + 0x22, 0x0f, 0x31, 0x24, 0x92, 0x69, 0xac, 0x99, 0xf1, 0x7c, 0xdf, 0xfc, 0x76, 0x34, 0xe0, 0x2b, + 0x4c, 0x1f, 0xe3, 0x10, 0xfb, 0x2a, 0x09, 0xf2, 0xaf, 0x5a, 0x8a, 0xb0, 0x9f, 0xa4, 0x52, 0x4b, + 0xb5, 0x2f, 0xf8, 0x54, 0x60, 0x76, 0x20, 0x96, 0x93, 0xac, 0xe6, 0x8d, 0xa1, 0x71, 0x81, 0x41, + 0x34, 0x59, 0x8a, 0x90, 0x07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x04, 0x43, 0x8d, 0x51, 0xcb, 0x18, + 0x5c, 0x42, 0x85, 0xc4, 0xec, 0x04, 0xec, 0x5c, 0xcf, 0xfe, 0x16, 0x79, 0xd2, 0xf3, 0x3a, 0x9d, + 0xc2, 0x71, 0xc4, 0x76, 0x7a, 0xf4, 0xba, 0x76, 0xcd, 0xd5, 0xda, 0x35, 0xdf, 0xd7, 0xae, 0xf9, + 0xb2, 0x71, 0x8d, 0xd5, 0xc6, 0x35, 0xde, 0x36, 0xae, 0x71, 0xdd, 0x3e, 0x70, 0x62, 0xb7, 0x55, + 0x3a, 0xa9, 0xe3, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x09, 0x7e, 0xc8, 0x77, 0x84, 0x02, 0x00, + 0x00, } -func (m *Space) Marshal() (dAtA []byte, err error) { +func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -515,191 +368,12 @@ func (m *Space) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Space) MarshalTo(dAtA []byte) (int, error) { +func (m *HeadSyncRange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Space) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Message != nil { - { - size, err := m.Message.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSpacesync(dAtA, i, uint64(size)) - } - i-- - 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 -} - -func (m *Space_Content) 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 *Space_Content) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Space_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *Space_Content_DiffRange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Space_Content_DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.DiffRange != nil { - { - size, err := m.DiffRange.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 *DiffRange) 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 *DiffRange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DiffRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Response != nil { - { - size, err := m.Response.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSpacesync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Request != nil { - { - size, err := m.Request.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 *DiffRange_Request) 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 *DiffRange_Request) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DiffRange_Request) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Ranges) > 0 { - for iNdEx := len(m.Ranges) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Ranges[iNdEx].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 *DiffRange_Request_Range) 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 *DiffRange_Request_Range) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DiffRange_Request_Range) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeadSyncRange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -722,7 +396,7 @@ func (m *DiffRange_Request_Range) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *DiffRange_Response) Marshal() (dAtA []byte, err error) { +func (m *HeadSyncResult) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -732,49 +406,12 @@ func (m *DiffRange_Response) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRange_Response) MarshalTo(dAtA []byte) (int, error) { +func (m *HeadSyncResult) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRange_Response) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Results) > 0 { - for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Results[iNdEx].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 *DiffRange_Response_Result) 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 *DiffRange_Response_Result) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *DiffRange_Response_Result) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeadSyncResult) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -808,7 +445,7 @@ func (m *DiffRange_Response_Result) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *DiffRange_Response_Result_Element) Marshal() (dAtA []byte, err error) { +func (m *HeadSyncResultElement) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -818,12 +455,12 @@ func (m *DiffRange_Response_Result_Element) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *DiffRange_Response_Result_Element) MarshalTo(dAtA []byte) (int, error) { +func (m *HeadSyncResultElement) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *DiffRange_Response_Result_Element) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *HeadSyncResultElement) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -845,6 +482,87 @@ func (m *DiffRange_Response_Result_Element) MarshalToSizedBuffer(dAtA []byte) (i return len(dAtA) - i, nil } +func (m *HeadSyncRequest) 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 *HeadSyncRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeadSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Ranges) > 0 { + for iNdEx := len(m.Ranges) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Ranges[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + 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 +} + +func (m *HeadSyncResponse) 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 *HeadSyncResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *HeadSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Results) > 0 { + for iNdEx := len(m.Results) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Results[iNdEx].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 encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -856,80 +574,7 @@ func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Space) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SpaceId) - if l > 0 { - n += 1 + l + sovSpacesync(uint64(l)) - } - if m.Message != nil { - l = m.Message.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - return n -} - -func (m *Space_Content) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != nil { - n += m.Value.Size() - } - return n -} - -func (m *Space_Content_DiffRange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.DiffRange != nil { - l = m.DiffRange.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - return n -} -func (m *DiffRange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Request != nil { - l = m.Request.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - if m.Response != nil { - l = m.Response.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - return n -} - -func (m *DiffRange_Request) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Ranges) > 0 { - for _, e := range m.Ranges { - l = e.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - } - return n -} - -func (m *DiffRange_Request_Range) Size() (n int) { +func (m *HeadSyncRange) Size() (n int) { if m == nil { return 0 } @@ -947,22 +592,7 @@ func (m *DiffRange_Request_Range) Size() (n int) { return n } -func (m *DiffRange_Response) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Results) > 0 { - for _, e := range m.Results { - l = e.Size() - n += 1 + l + sovSpacesync(uint64(l)) - } - } - return n -} - -func (m *DiffRange_Response_Result) Size() (n int) { +func (m *HeadSyncResult) Size() (n int) { if m == nil { return 0 } @@ -984,7 +614,7 @@ func (m *DiffRange_Response_Result) Size() (n int) { return n } -func (m *DiffRange_Response_Result_Element) Size() (n int) { +func (m *HeadSyncResultElement) Size() (n int) { if m == nil { return 0 } @@ -1001,13 +631,47 @@ func (m *DiffRange_Response_Result_Element) Size() (n int) { return n } +func (m *HeadSyncRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if len(m.Ranges) > 0 { + for _, e := range m.Ranges { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + +func (m *HeadSyncResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Results) > 0 { + for _, e := range m.Results { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } func sozSpacesync(x uint64) (n int) { return sovSpacesync(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Space) Unmarshal(dAtA []byte) error { +func (m *HeadSyncRange) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1030,419 +694,10 @@ func (m *Space) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Space: wiretype end group for non-group") + return fmt.Errorf("proto: HeadSyncRange: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Space: illegal tag %d (wire type %d)", fieldNum, wire) - } - 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: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", 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.Message == nil { - m.Message = &Space_Content{} - } - if err := m.Message.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 *Space_Content) 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: Content: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Content: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DiffRange", 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 - } - v := &DiffRange{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &Space_Content_DiffRange{v} - 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 *DiffRange) 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: DiffRange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: DiffRange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Request", 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.Request == nil { - m.Request = &DiffRange_Request{} - } - if err := m.Request.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Response", 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.Response == nil { - m.Response = &DiffRange_Response{} - } - if err := m.Response.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 *DiffRange_Request) 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: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ranges", 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 - } - m.Ranges = append(m.Ranges, &DiffRange_Request_Range{}) - if err := m.Ranges[len(m.Ranges)-1].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 *DiffRange_Request_Range) 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: Range: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Range: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeadSyncRange: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1523,7 +778,7 @@ func (m *DiffRange_Request_Range) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRange_Response) Unmarshal(dAtA []byte) error { +func (m *HeadSyncResult) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1546,94 +801,10 @@ func (m *DiffRange_Response) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Response: wiretype end group for non-group") + return fmt.Errorf("proto: HeadSyncResult: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Results", 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 - } - m.Results = append(m.Results, &DiffRange_Response_Result{}) - if err := m.Results[len(m.Results)-1].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 *DiffRange_Response_Result) 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: Result: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Result: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeadSyncResult: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1699,7 +870,7 @@ func (m *DiffRange_Response_Result) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Elements = append(m.Elements, &DiffRange_Response_Result_Element{}) + m.Elements = append(m.Elements, &HeadSyncResultElement{}) if err := m.Elements[len(m.Elements)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -1744,7 +915,7 @@ func (m *DiffRange_Response_Result) Unmarshal(dAtA []byte) error { } return nil } -func (m *DiffRange_Response_Result_Element) Unmarshal(dAtA []byte) error { +func (m *HeadSyncResultElement) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -1767,10 +938,10 @@ func (m *DiffRange_Response_Result_Element) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Element: wiretype end group for non-group") + return fmt.Errorf("proto: HeadSyncResultElement: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Element: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: HeadSyncResultElement: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -1858,6 +1029,206 @@ func (m *DiffRange_Response_Result_Element) Unmarshal(dAtA []byte) error { } return nil } +func (m *HeadSyncRequest) 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: HeadSyncRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HeadSyncRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + 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: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Ranges", 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 + } + m.Ranges = append(m.Ranges, &HeadSyncRange{}) + if err := m.Ranges[len(m.Ranges)-1].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 *HeadSyncResponse) 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: HeadSyncResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: HeadSyncResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Results", 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 + } + m.Results = append(m.Results, &HeadSyncResult{}) + if err := m.Results[len(m.Results)-1].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 skipSpacesync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/service/space/spacesync/spacesync_drpc.pb.go b/service/space/spacesync/spacesync_drpc.pb.go new file mode 100644 index 00000000..a083c7e3 --- /dev/null +++ b/service/space/spacesync/spacesync_drpc.pb.go @@ -0,0 +1,113 @@ +// Code generated by protoc-gen-go-drpc. DO NOT EDIT. +// protoc-gen-go-drpc version: v0.0.32 +// source: service/space/spacesync/protos/spacesync.proto + +package spacesync + +import ( + bytes "bytes" + context "context" + errors "errors" + jsonpb "github.com/gogo/protobuf/jsonpb" + proto "github.com/gogo/protobuf/proto" + drpc "storj.io/drpc" + drpcerr "storj.io/drpc/drpcerr" +) + +type drpcEncoding_File_service_space_spacesync_protos_spacesync_proto struct{} + +func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) Marshal(msg drpc.Message) ([]byte, error) { + return proto.Marshal(msg.(proto.Message)) +} + +func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) Unmarshal(buf []byte, msg drpc.Message) error { + return proto.Unmarshal(buf, msg.(proto.Message)) +} + +func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) JSONMarshal(msg drpc.Message) ([]byte, error) { + var buf bytes.Buffer + err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message)) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error { + return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message)) +} + +type DRPCSpaceClient interface { + DRPCConn() drpc.Conn + + HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) +} + +type drpcSpaceClient struct { + cc drpc.Conn +} + +func NewDRPCSpaceClient(cc drpc.Conn) DRPCSpaceClient { + return &drpcSpaceClient{cc} +} + +func (c *drpcSpaceClient) DRPCConn() drpc.Conn { return c.cc } + +func (c *drpcSpaceClient) HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) { + out := new(HeadSyncResponse) + err := c.cc.Invoke(ctx, "/anySpace.Space/HeadSync", drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +type DRPCSpaceServer interface { + HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) +} + +type DRPCSpaceUnimplementedServer struct{} + +func (s *DRPCSpaceUnimplementedServer) HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +type DRPCSpaceDescription struct{} + +func (DRPCSpaceDescription) NumMethods() int { return 1 } + +func (DRPCSpaceDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { + switch n { + case 0: + return "/anySpace.Space/HeadSync", drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCSpaceServer). + HeadSync( + ctx, + in1.(*HeadSyncRequest), + ) + }, DRPCSpaceServer.HeadSync, true + default: + return "", nil, nil, nil, false + } +} + +func DRPCRegisterSpace(mux drpc.Mux, impl DRPCSpaceServer) error { + return mux.Register(impl, DRPCSpaceDescription{}) +} + +type DRPCSpace_HeadSyncStream interface { + drpc.Stream + SendAndClose(*HeadSyncResponse) error +} + +type drpcSpace_HeadSyncStream struct { + drpc.Stream +} + +func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}); err != nil { + return err + } + return x.CloseSend() +} diff --git a/syncproto/sync.pb.go b/syncproto/sync.pb.go index e8df4661..8fe415ab 100644 --- a/syncproto/sync.pb.go +++ b/syncproto/sync.pb.go @@ -503,10 +503,10 @@ func (m *Sync) GetMessage() *Sync_ContentValue { type Sync_ContentValue struct { // Types that are valid to be assigned to Value: - // *Sync_Content_Value_HeadUpdate - // *Sync_Content_Value_FullSyncRequest - // *Sync_Content_Value_FullSyncResponse - Value isSync_Content_Value_Value `protobuf_oneof:"value"` + // *Sync_ContentValue_HeadUpdate + // *Sync_ContentValue_FullSyncRequest + // *Sync_ContentValue_FullSyncResponse + Value isSync_ContentValue_Value `protobuf_oneof:"value"` } func (m *Sync_ContentValue) Reset() { *m = Sync_ContentValue{} } @@ -542,27 +542,27 @@ func (m *Sync_ContentValue) XXX_DiscardUnknown() { var xxx_messageInfo_Sync_ContentValue proto.InternalMessageInfo -type isSync_Content_Value_Value interface { - isSync_Content_Value_Value() +type isSync_ContentValue_Value interface { + isSync_ContentValue_Value() MarshalTo([]byte) (int, error) Size() int } -type Sync_Content_Value_HeadUpdate struct { +type Sync_ContentValue_HeadUpdate struct { HeadUpdate *Sync_HeadUpdate `protobuf:"bytes,1,opt,name=headUpdate,proto3,oneof" json:"headUpdate,omitempty"` } -type Sync_Content_Value_FullSyncRequest struct { +type Sync_ContentValue_FullSyncRequest struct { FullSyncRequest *Sync_Full_Request `protobuf:"bytes,2,opt,name=fullSyncRequest,proto3,oneof" json:"fullSyncRequest,omitempty"` } -type Sync_Content_Value_FullSyncResponse struct { +type Sync_ContentValue_FullSyncResponse struct { FullSyncResponse *Sync_Full_Response `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` } -func (*Sync_Content_Value_HeadUpdate) isSync_Content_Value_Value() {} -func (*Sync_Content_Value_FullSyncRequest) isSync_Content_Value_Value() {} -func (*Sync_Content_Value_FullSyncResponse) isSync_Content_Value_Value() {} +func (*Sync_ContentValue_HeadUpdate) isSync_ContentValue_Value() {} +func (*Sync_ContentValue_FullSyncRequest) isSync_ContentValue_Value() {} +func (*Sync_ContentValue_FullSyncResponse) isSync_ContentValue_Value() {} -func (m *Sync_ContentValue) GetValue() isSync_Content_Value_Value { +func (m *Sync_ContentValue) GetValue() isSync_ContentValue_Value { if m != nil { return m.Value } @@ -570,21 +570,21 @@ func (m *Sync_ContentValue) GetValue() isSync_Content_Value_Value { } func (m *Sync_ContentValue) GetHeadUpdate() *Sync_HeadUpdate { - if x, ok := m.GetValue().(*Sync_Content_Value_HeadUpdate); ok { + if x, ok := m.GetValue().(*Sync_ContentValue_HeadUpdate); ok { return x.HeadUpdate } return nil } func (m *Sync_ContentValue) GetFullSyncRequest() *Sync_Full_Request { - if x, ok := m.GetValue().(*Sync_Content_Value_FullSyncRequest); ok { + if x, ok := m.GetValue().(*Sync_ContentValue_FullSyncRequest); ok { return x.FullSyncRequest } return nil } func (m *Sync_ContentValue) GetFullSyncResponse() *Sync_Full_Response { - if x, ok := m.GetValue().(*Sync_Content_Value_FullSyncResponse); ok { + if x, ok := m.GetValue().(*Sync_ContentValue_FullSyncResponse); ok { return x.FullSyncResponse } return nil @@ -593,9 +593,9 @@ func (m *Sync_ContentValue) GetFullSyncResponse() *Sync_Full_Response { // XXX_OneofWrappers is for the internal use of the proto package. func (*Sync_ContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*Sync_Content_Value_HeadUpdate)(nil), - (*Sync_Content_Value_FullSyncRequest)(nil), - (*Sync_Content_Value_FullSyncResponse)(nil), + (*Sync_ContentValue_HeadUpdate)(nil), + (*Sync_ContentValue_FullSyncRequest)(nil), + (*Sync_ContentValue_FullSyncResponse)(nil), } } @@ -1293,12 +1293,12 @@ func (m *Sync_ContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Sync_Content_Value_HeadUpdate) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_HeadUpdate) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Sync_Content_Value_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.HeadUpdate != nil { { @@ -1314,12 +1314,12 @@ func (m *Sync_Content_Value_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, } return len(dAtA) - i, nil } -func (m *Sync_Content_Value_FullSyncRequest) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_FullSyncRequest) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Sync_Content_Value_FullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_FullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.FullSyncRequest != nil { { @@ -1335,12 +1335,12 @@ func (m *Sync_Content_Value_FullSyncRequest) MarshalToSizedBuffer(dAtA []byte) ( } return len(dAtA) - i, nil } -func (m *Sync_Content_Value_FullSyncResponse) MarshalTo(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_FullSyncResponse) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Sync_Content_Value_FullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *Sync_ContentValue_FullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.FullSyncResponse != nil { { @@ -1759,7 +1759,7 @@ func (m *Sync_ContentValue) Size() (n int) { return n } -func (m *Sync_Content_Value_HeadUpdate) Size() (n int) { +func (m *Sync_ContentValue_HeadUpdate) Size() (n int) { if m == nil { return 0 } @@ -1771,7 +1771,7 @@ func (m *Sync_Content_Value_HeadUpdate) Size() (n int) { } return n } -func (m *Sync_Content_Value_FullSyncRequest) Size() (n int) { +func (m *Sync_ContentValue_FullSyncRequest) Size() (n int) { if m == nil { return 0 } @@ -1783,7 +1783,7 @@ func (m *Sync_Content_Value_FullSyncRequest) Size() (n int) { } return n } -func (m *Sync_Content_Value_FullSyncResponse) Size() (n int) { +func (m *Sync_ContentValue_FullSyncResponse) Size() (n int) { if m == nil { return 0 } @@ -2884,7 +2884,7 @@ func (m *Sync_ContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &Sync_Content_Value_HeadUpdate{v} + m.Value = &Sync_ContentValue_HeadUpdate{v} iNdEx = postIndex case 2: if wireType != 2 { @@ -2919,7 +2919,7 @@ func (m *Sync_ContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &Sync_Content_Value_FullSyncRequest{v} + m.Value = &Sync_ContentValue_FullSyncRequest{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -2954,7 +2954,7 @@ func (m *Sync_ContentValue) Unmarshal(dAtA []byte) error { if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &Sync_Content_Value_FullSyncResponse{v} + m.Value = &Sync_ContentValue_FullSyncResponse{v} iNdEx = postIndex default: iNdEx = preIndex From 698acad3bd6d3929e1da66fc28f2bfbc92532844 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 8 Sep 2022 00:24:19 +0300 Subject: [PATCH 04/44] remotediff test --- service/space/remotediff/remotediff.go | 81 +++++++-------------- service/space/remotediff/remotediff_test.go | 41 +++++++++++ 2 files changed, 68 insertions(+), 54 deletions(-) create mode 100644 service/space/remotediff/remotediff_test.go diff --git a/service/space/remotediff/remotediff.go b/service/space/remotediff/remotediff.go index 0bab5350..df10aec6 100644 --- a/service/space/remotediff/remotediff.go +++ b/service/space/remotediff/remotediff.go @@ -2,75 +2,55 @@ package remotediff import ( "context" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" ) -func NewRemoteDiff(p pool.Pool, peerId, spaceId string) ldiff.Remote { +type Client interface { + HeadSync(ctx context.Context, in *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) +} + +func NewRemoteDiff(spaceId string, client Client) ldiff.Remote { return remote{ - pool: p, - peerId: peerId, spaceId: spaceId, + client: client, } } type remote struct { - pool pool.Pool - peerId string spaceId string + client Client } func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff.RangeResult) (results []ldiff.RangeResult, err error) { results = resBuf[:0] - pbRanges := make([]*spacesync.DiffRange_Request_Range, 0, len(ranges)) + pbRanges := make([]*spacesync.HeadSyncRange, 0, len(ranges)) for _, rg := range ranges { - pbRanges = append(pbRanges, &spacesync.DiffRange_Request_Range{ + pbRanges = append(pbRanges, &spacesync.HeadSyncRange{ From: rg.From, To: rg.To, Limit: uint32(rg.Limit), }) } - req := &spacesync.Space{ + req := &spacesync.HeadSyncRequest{ SpaceId: r.spaceId, - Message: &spacesync.Space_Content{ - Value: &spacesync.Space_Content_DiffRange{ - DiffRange: &spacesync.DiffRange{ - Request: &spacesync.DiffRange_Request{ - Ranges: pbRanges, - }, - }, - }, - }, + Ranges: pbRanges, } - msg, err := req.Marshal() + resp, err := r.client.HeadSync(ctx, req) if err != nil { return } - resp, err := r.pool.SendAndWaitResponse(ctx, r.peerId, &syncproto.Message{ - Header: &syncproto.Header{ - Type: syncproto.MessageType_MessageTypeSpace, - }, - Data: msg, - }) - if err != nil { - return - } - var spaceResp = &spacesync.Space{} - if err = resp.UnmarshalData(spaceResp); err != nil { - return - } - rangeResp := spaceResp.GetMessage().GetDiffRange().GetResponse() - if rangeResp != nil { - return nil, fmt.Errorf("got nil response") - } - for _, rr := range rangeResp.Results { + for _, rr := range resp.Results { var elms []ldiff.Element if len(rr.Elements) > 0 { elms = make([]ldiff.Element, 0, len(rr.Elements)) } + for _, e := range rr.Elements { + elms = append(elms, ldiff.Element{ + Id: e.Id, + Head: e.Head, + }) + } results = append(results, ldiff.RangeResult{ Hash: rr.Hash, Elements: elms, @@ -80,12 +60,7 @@ func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff return } -func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, diffRange *spacesync.DiffRange) (resp *spacesync.DiffRange, err error) { - req := diffRange.GetRequest() - if req != nil { - return nil, fmt.Errorf("received nil request") - } - +func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesync.HeadSyncRequest) (resp *spacesync.HeadSyncResponse, err error) { ranges := make([]ldiff.Range, 0, len(req.Ranges)) for _, reqRange := range req.Ranges { ranges = append(ranges, ldiff.Range{ @@ -99,27 +74,25 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, diffRange *spacesync return } - var rangeResp = &spacesync.DiffRange_Response{ - Results: make([]*spacesync.DiffRange_Response_Result, len(res)), + var rangeResp = &spacesync.HeadSyncResponse{ + Results: make([]*spacesync.HeadSyncResult, 0, len(res)), } for _, rangeRes := range res { - var elements []*spacesync.DiffRange_Response_Result_Element + var elements []*spacesync.HeadSyncResultElement if len(rangeRes.Elements) > 0 { - elements = make([]*spacesync.DiffRange_Response_Result_Element, 0, len(rangeRes.Elements)) + elements = make([]*spacesync.HeadSyncResultElement, 0, len(rangeRes.Elements)) for _, el := range rangeRes.Elements { - elements = append(elements, &spacesync.DiffRange_Response_Result_Element{ + elements = append(elements, &spacesync.HeadSyncResultElement{ Id: el.Id, Head: el.Head, }) } } - rangeResp.Results = append(rangeResp.Results, &spacesync.DiffRange_Response_Result{ + rangeResp.Results = append(rangeResp.Results, &spacesync.HeadSyncResult{ Hash: rangeRes.Hash, Elements: elements, Count: uint32(rangeRes.Count), }) } - return &spacesync.DiffRange{ - Response: rangeResp, - }, nil + return rangeResp, nil } diff --git a/service/space/remotediff/remotediff_test.go b/service/space/remotediff/remotediff_test.go new file mode 100644 index 00000000..e1cf96ed --- /dev/null +++ b/service/space/remotediff/remotediff_test.go @@ -0,0 +1,41 @@ +package remotediff + +import ( + "context" + "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" + "testing" +) + +func TestRemote(t *testing.T) { + ldLocal := ldiff.New(8, 8) + ldRemote := ldiff.New(8, 8) + for i := 0; i < 100; i++ { + el := ldiff.Element{ + Id: fmt.Sprint(i), + Head: fmt.Sprint(i), + } + ldRemote.Set(el) + if i%10 != 0 { + ldLocal.Set(el) + } + } + + rd := NewRemoteDiff("1", &mockClient{l: ldRemote}) + newIds, changedIds, removedIds, err := ldLocal.Diff(context.Background(), rd) + require.NoError(t, err) + assert.Len(t, newIds, 10) + assert.Len(t, changedIds, 0) + assert.Len(t, removedIds, 0) +} + +type mockClient struct { + l ldiff.Diff +} + +func (m *mockClient) HeadSync(ctx context.Context, in *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { + return HandlerRangeRequest(ctx, m.l, in) +} From bee067ad7667d25214f2b148325d0634b05f92ef Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 8 Sep 2022 12:05:30 +0300 Subject: [PATCH 05/44] space service periodic sync --- cmd/node/node.go | 22 ++++---- config/config.go | 2 +- config/space.go | 4 +- etc/config.yml | 3 ++ ...K2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml | 3 ++ ...zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml | 3 ++ pkg/ocache/ocache.go | 4 +- service/net/pool/pool.go | 3 +- service/net/rpc/server/drpcserver.go | 5 +- service/space/remotediff/remotediff.go | 6 +-- service/space/rpc.go | 18 +++++++ service/space/service.go | 16 +++--- service/space/space.go | 50 +++++++++++-------- 13 files changed, 84 insertions(+), 55 deletions(-) create mode 100644 service/space/rpc.go diff --git a/cmd/node/node.go b/cmd/node/node.go index d6ded226..c73a164c 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -8,17 +8,13 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/api" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/document" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/message" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/requesthandler" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space" "go.uber.org/zap" "net/http" _ "net/http/pprof" @@ -94,14 +90,16 @@ func main() { func Bootstrap(a *app.App) { a.Register(account.New()). Register(node.New()). + Register(configuration.New()). Register(secure.New()). - Register(server.New()). Register(dialer.New()). Register(pool.New()). - Register(configuration.New()). - Register(document.New()). - Register(message.New()). - Register(requesthandler.New()). - Register(treecache.New()). - Register(api.New()) + Register(space.New()). + Register(server.New()) + + //Register(document.New()). + //Register(message.New()). + //Register(requesthandler.New()). + //Register(treecache.New()). + //Register(api.New()) } diff --git a/config/config.go b/config/config.go index 4c1e8aa9..4f5ed612 100644 --- a/config/config.go +++ b/config/config.go @@ -33,7 +33,7 @@ type Config struct { } func (c *Config) Init(ctx context.Context, a *app.App) (err error) { - logger.NewNamed("config").Info(fmt.Sprint(*c)) + logger.NewNamed("config").Info(fmt.Sprint(c.Space)) return } diff --git a/config/space.go b/config/space.go index 4de7cde0..5b603715 100644 --- a/config/space.go +++ b/config/space.go @@ -1,6 +1,6 @@ package config type Space struct { - GCTTL int `json:"gcTTL"` - SyncPeriod int `json:"syncPeriod"` + GCTTL int `yaml:"gcTTL"` + SyncPeriod int `yaml:"syncPeriod"` } diff --git a/etc/config.yml b/etc/config.yml index 79754d42..09b13d54 100644 --- a/etc/config.yml +++ b/etc/config.yml @@ -11,6 +11,9 @@ account: encryptionKey: JgG4CcCbae1qEpe7mKpBzsHjZhXUmDSNVNX2B1gxFZsJyMX4V6kBQUott9zRWyeXaW1ZmpzuxDXnwSQpAnNurhXyGa9iQaAPqzY9A9VWBPD33Yy1eW7TRuVemzToh8jJQKQKnZNbF8ucTWV9qahusKzyvN8uyhrqoW2tAPfA9S3E3ognCuqbLSW6yjE2rBKayvyS1BVwzjSd6FZK4DDyjfU3pbEVjut3wytGEAn9af6sNMmyCnf2MX5vLovWs9rU8av61wD4z7HTsXyGFx4K75N4Go249Hpe9SKAT6HxhRc3yvj63krPLiQV5yMuH2UeMUXBDekUQyNmBEdn9wrur7mLqB67Bc6tcc2PP8XApBCdWJHvHjN4FktSpaG5vbCqoZbLD1oCbk36q2x9s6XM8pydVqD1J9P3nTbfgMb5pJCTFjNtgKeuKv6wjfJeA9jF1VhcJQisfsahgv9MvZ9M8FJpZTq1zKUhYDCRnZxUkraoMS5yNNVdDzaUckKEDthqik7BMWCWT79vq7uVgMwEvGwGi76gtoMg1159bbPMLZ4bdPVfhH2S9QjPrzQfwZSrzB2YeVPjWpaXDeLDity5H8n1NK2oniAQR6gE71n81neSptsuhV6o6QpQ89AU8y57XmEsou4VEryn8vUxBHhULLxrLNUouxyWamCeFiDjk5cSN6koQsf9BYKSNTPFTrwjTKForDokMhcPdMtFktKwjv7u9UEGcY4MKvNzZZkc77gHiP8bqVtdNNoLpTFUC5SZ9i7bKdHvK12HpSy7yzzPeMXJ9UwhLxkok1g81ngTbN1yxRhvYXyHZFtguCR9kvGojDjka91MTBtk551qDw9eCn2xZT9U8jqzBCjdpvSg3mRWKMPnYAGB7m7u1ye165wyGFvzcHAx3vtXjxAqLUeKYZCjv2m6V9D2Y4qH1TQNddWqH14T1JVMis971UCH9Ddpj6a3387oUnufD1P6HZN2ieJCvptrmbGVvxJYYSvmVf1dkwbtqurDRNWD7TJ7gf6iqSP549C9bxP4GpLt3ygjHmMtcuUzstBuztvunJUnQhfnJxqU6LjRdsFzm53wGWgXNxab7ZvQcPyLwsevn1b98FGPnVpS5iY4LjmqW4ugrC6HgrbsjrXiKzR1yZKhLQkCbLzPoaHb8iB5iBnCr7d4yf5CtfpFRqgoqMFdK5LNZYmDX4HzUKN6A7wC3gGiSRFTLcgGZeSMkB5Pa61CZBU7WCQgFxykycE9HRA7PiQa496GWDCV15teToCpFRsAa6jDmR1MGXPeLRqQgve49VXnQN5FL7c1VuEv5SWjeTuCnMB47DJKBaP7eKJNKgLwETALzSCMF3nRiRgeb15kfoS4BbrJ5yupjrvwmbmvNg1AYFFS5sYNWft7K8v87wQvBakRtGP71Kp8NX77XFtu6xdB7sR6jpfC6qJPyB9akWNXgCrWy9kE4ih42gwAZdUugNZ9YtEsgRM3pwb6qJhkAPyEJtrxrja859PCAgqPSQiPQN33PaMkgQ6HJknu8CrjKRiXAycZ16KLUkHV64TNhEjPTcX1a7rqpD131AYMWX8d7CCdc9Ys7RUb6BwguuNSh8rJK3x4AkMDSUsaE8ynKvpC7RXZpJ9Nxfhd apiServer: port: "8080" +space: + gcTTL: 60 + syncPeriod: 10 nodes: - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 address: 127.0.0.1:4430 diff --git a/etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml b/etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml index 2e552e35..dcea6558 100755 --- a/etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml +++ b/etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml @@ -11,6 +11,9 @@ account: encryptionKey: JgG4CcCbae1qEpe7mKpBzsHjZhXUmDSNVNX2B1gxFZsJyMX4V6kBQUott9zRWyeXaW1ZmpzuxDXnwSQpAnNurhXyGa9iQaAPqzY9A9VWBPD33Yy1eW7TRuVemzToh8jJQKQKnZNbF8ucTWV9qahusKzyvN8uyhrqoW2tAPfA9S3E3ognCuqbLSW6yjE2rBKayvyS1BVwzjSd6FZK4DDyjfU3pbEVjut3wytGEAn9af6sNMmyCnf2MX5vLovWs9rU8av61wD4z7HTsXyGFx4K75N4Go249Hpe9SKAT6HxhRc3yvj63krPLiQV5yMuH2UeMUXBDekUQyNmBEdn9wrur7mLqB67Bc6tcc2PP8XApBCdWJHvHjN4FktSpaG5vbCqoZbLD1oCbk36q2x9s6XM8pydVqD1J9P3nTbfgMb5pJCTFjNtgKeuKv6wjfJeA9jF1VhcJQisfsahgv9MvZ9M8FJpZTq1zKUhYDCRnZxUkraoMS5yNNVdDzaUckKEDthqik7BMWCWT79vq7uVgMwEvGwGi76gtoMg1159bbPMLZ4bdPVfhH2S9QjPrzQfwZSrzB2YeVPjWpaXDeLDity5H8n1NK2oniAQR6gE71n81neSptsuhV6o6QpQ89AU8y57XmEsou4VEryn8vUxBHhULLxrLNUouxyWamCeFiDjk5cSN6koQsf9BYKSNTPFTrwjTKForDokMhcPdMtFktKwjv7u9UEGcY4MKvNzZZkc77gHiP8bqVtdNNoLpTFUC5SZ9i7bKdHvK12HpSy7yzzPeMXJ9UwhLxkok1g81ngTbN1yxRhvYXyHZFtguCR9kvGojDjka91MTBtk551qDw9eCn2xZT9U8jqzBCjdpvSg3mRWKMPnYAGB7m7u1ye165wyGFvzcHAx3vtXjxAqLUeKYZCjv2m6V9D2Y4qH1TQNddWqH14T1JVMis971UCH9Ddpj6a3387oUnufD1P6HZN2ieJCvptrmbGVvxJYYSvmVf1dkwbtqurDRNWD7TJ7gf6iqSP549C9bxP4GpLt3ygjHmMtcuUzstBuztvunJUnQhfnJxqU6LjRdsFzm53wGWgXNxab7ZvQcPyLwsevn1b98FGPnVpS5iY4LjmqW4ugrC6HgrbsjrXiKzR1yZKhLQkCbLzPoaHb8iB5iBnCr7d4yf5CtfpFRqgoqMFdK5LNZYmDX4HzUKN6A7wC3gGiSRFTLcgGZeSMkB5Pa61CZBU7WCQgFxykycE9HRA7PiQa496GWDCV15teToCpFRsAa6jDmR1MGXPeLRqQgve49VXnQN5FL7c1VuEv5SWjeTuCnMB47DJKBaP7eKJNKgLwETALzSCMF3nRiRgeb15kfoS4BbrJ5yupjrvwmbmvNg1AYFFS5sYNWft7K8v87wQvBakRtGP71Kp8NX77XFtu6xdB7sR6jpfC6qJPyB9akWNXgCrWy9kE4ih42gwAZdUugNZ9YtEsgRM3pwb6qJhkAPyEJtrxrja859PCAgqPSQiPQN33PaMkgQ6HJknu8CrjKRiXAycZ16KLUkHV64TNhEjPTcX1a7rqpD131AYMWX8d7CCdc9Ys7RUb6BwguuNSh8rJK3x4AkMDSUsaE8ynKvpC7RXZpJ9Nxfhd apiServer: port: "8080" +space: + gcTTL: 60 + syncPeriod: 10 nodes: - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 address: 127.0.0.1:4430 diff --git a/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml b/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml index 10a49044..eb88a19b 100755 --- a/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JH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He7gjqvYgULdE1ubRCRSd7DuLjEN2Vd6obzV2c3MRet7ZSf4Sp88WM5AuTyW7BjArBc4S3gUQ8rYaiZ8Tu7NCxkEzbFwWRaemZkwfvcsX3XxqjyF37tFSGkEqE5kuBvpZW72675LkDffj7kH1zA8yE6dVujJjWsNYVFJWndUtz5Vy2KCdZAbBgq19q4AtsxWPodU2N3yZXzFAFAzTrxS6V4P7Scpdau1avgRvHLcBQPunA37xaYMy8YMifJwtmRY25mnAQwZAk3eANk7tXwZd58SDnciLNvARJvwKzTQBXcshkwyy52SX8XmXDJsPnRLaHmiYBJ63Yzr5XpZuuAtxb9qrWG2NHCNxfomHokWacV1hjZPPd6ZxT1FuRozB6Qt2NLcyqY7bnTcQJb1jPUaTAGXXCR8WVmmmYo2fDQe8CdBmgyPvbzNTEJUyScBz4RdycB5PZap4SurJCWtHbuMyQbQUB6jJgURDstfXS5Akfe4oruNq9rnYcNtnsDJPtrhXHBqzDizmf1BDxR5FB2RCxzCgeAfg8WQ1Ug9PVAGTzob6ZqCrGXzWXEUniZnf1vjr7QhGKBYXEX9SWDoSMUpP4FreVDTnx15ijRZTV3p8xG5fE9e36TnugRVvTyq7XzmyPBjW2r66f1bior apiServer: port: "8081" +space: + gcTTL: 60 + syncPeriod: 10 nodes: - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 address: 127.0.0.1:4430 diff --git a/pkg/ocache/ocache.go b/pkg/ocache/ocache.go index 5e10508a..4f0cf0ba 100644 --- a/pkg/ocache/ocache.go +++ b/pkg/ocache/ocache.go @@ -27,9 +27,9 @@ type LoadFunc func(ctx context.Context, id string) (value Object, err error) type Option func(*oCache) -var WithLogServiceName = func(name string) Option { +var WithLogger = func(l *zap.SugaredLogger) Option { return func(cache *oCache) { - cache.log = cache.log.With("service_name", name) + cache.log = l } } diff --git a/service/net/pool/pool.go b/service/net/pool/pool.go index cbd0973a..6b7cfa67 100644 --- a/service/net/pool/pool.go +++ b/service/net/pool/pool.go @@ -9,6 +9,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" "math/rand" + "time" ) const ( @@ -43,7 +44,7 @@ func (p *pool) Init(ctx context.Context, a *app.App) (err error) { dialer := a.MustComponent(dialer.CName).(dialer.Dialer) p.cache = ocache.New(func(ctx context.Context, id string) (value ocache.Object, err error) { return dialer.Dial(ctx, id) - }) + }, ocache.WithLogger(log.Sugar()), ocache.WithGCPeriod(time.Minute), ocache.WithTTL(time.Minute*5)) return nil } diff --git a/service/net/rpc/server/drpcserver.go b/service/net/rpc/server/drpcserver.go index 1af9af7b..975c270f 100644 --- a/service/net/rpc/server/drpcserver.go +++ b/service/net/rpc/server/drpcserver.go @@ -7,12 +7,13 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" + "github.com/zeebo/errs" "go.uber.org/zap" + "io" "net" "storj.io/drpc" "storj.io/drpc/drpcmux" "storj.io/drpc/drpcserver" - "strings" "time" ) @@ -103,7 +104,7 @@ func (s *drpcServer) serveConn(ctx context.Context, conn net.Conn) { l := log.With(zap.String("remoteAddr", conn.RemoteAddr().String())).With(zap.String("localAddr", conn.LocalAddr().String())) l.Debug("connection opened") if err := s.drpcServer.ServeOne(ctx, conn); err != nil { - if err == context.Canceled || strings.Contains(err.Error(), "EOF") { + if errs.Is(err, context.Canceled) || errs.Is(err, io.EOF) { l.Debug("connection closed") } else { l.Warn("serve connection error", zap.Error(err)) diff --git a/service/space/remotediff/remotediff.go b/service/space/remotediff/remotediff.go index df10aec6..2ba6769a 100644 --- a/service/space/remotediff/remotediff.go +++ b/service/space/remotediff/remotediff.go @@ -74,7 +74,7 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesync.HeadS return } - var rangeResp = &spacesync.HeadSyncResponse{ + resp = &spacesync.HeadSyncResponse{ Results: make([]*spacesync.HeadSyncResult, 0, len(res)), } for _, rangeRes := range res { @@ -88,11 +88,11 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesync.HeadS }) } } - rangeResp.Results = append(rangeResp.Results, &spacesync.HeadSyncResult{ + resp.Results = append(resp.Results, &spacesync.HeadSyncResult{ Hash: rangeRes.Hash, Elements: elements, Count: uint32(rangeRes.Count), }) } - return rangeResp, nil + return } diff --git a/service/space/rpc.go b/service/space/rpc.go new file mode 100644 index 00000000..db056079 --- /dev/null +++ b/service/space/rpc.go @@ -0,0 +1,18 @@ +package space + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" +) + +type rpcServer struct { + s *service +} + +func (r rpcServer) HeadSync(ctx context.Context, request *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { + sp, err := r.s.get(ctx, request.SpaceId) + if err != nil { + return nil, err + } + return sp.HeadSync(ctx, request) +} diff --git a/service/space/service.go b/service/space/service.go index 183b5425..ae9be5a4 100644 --- a/service/space/service.go +++ b/service/space/service.go @@ -2,7 +2,6 @@ package space import ( "context" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" @@ -11,7 +10,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" - "storj.io/drpc/drpcerr" "time" ) @@ -24,7 +22,6 @@ func New() Service { } type Service interface { - spacesync.DRPCSpaceServer app.ComponentRunnable } @@ -40,9 +37,8 @@ func (s *service) Init(ctx context.Context, a *app.App) (err error) { s.pool = a.MustComponent(pool.CName).(pool.Pool) s.confService = a.MustComponent(configuration.CName).(configuration.Service) ttlSec := time.Second * time.Duration(s.conf.GCTTL) - s.cache = ocache.New(s.loadSpace, ocache.WithTTL(ttlSec), ocache.WithGCPeriod(time.Minute)) - spacesync.DRPCRegisterSpace(a.MustComponent(server.CName).(server.DRPCServer), s) - + s.cache = ocache.New(s.loadSpace, ocache.WithTTL(ttlSec), ocache.WithGCPeriod(time.Minute), ocache.WithLogger(log.Sugar())) + spacesync.DRPCRegisterSpace(a.MustComponent(server.CName).(server.DRPCServer), rpcServer{s}) return nil } @@ -51,6 +47,10 @@ func (s *service) Name() (name string) { } func (s *service) Run(ctx context.Context) (err error) { + go func() { + time.Sleep(time.Second * 10) + s.get(ctx, "testSpace") + }() return } @@ -71,10 +71,6 @@ func (s *service) get(ctx context.Context, id string) (Space, error) { return obj.(Space), nil } -func (s *service) HeadSync(ctx context.Context, request *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { - return nil, drpcerr.WithCode(fmt.Errorf("check"), 42) -} - func (s *service) Close(ctx context.Context) (err error) { return s.cache.Close() } diff --git a/service/space/space.go b/service/space/space.go index 169fd408..7be85ef4 100644 --- a/service/space/space.go +++ b/service/space/space.go @@ -5,7 +5,9 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/remotediff" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" "go.uber.org/zap" "math/rand" "sync" @@ -14,6 +16,9 @@ import ( type Space interface { Id() string + + HeadSync(ctx context.Context, req *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) + Close() error } @@ -44,21 +49,26 @@ func (s *space) Run(ctx context.Context) error { return nil } +func (s *space) HeadSync(ctx context.Context, req *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { + return remotediff.HandlerRangeRequest(ctx, s.diff, req) +} + func (s *space) testFill() { var n = 1000 var els = make([]ldiff.Element, 0, n) rand.Seed(time.Now().UnixNano()) for i := 0; i < n; i++ { if rand.Intn(n) > 2 { - id := fmt.Sprintf("%s.%d", s.id, n) + id := fmt.Sprintf("%s.%d", s.id, i) head := "head." + id - if rand.Intn(n) > 2 { + if rand.Intn(n) > n-100 { head += ".modified" } - els = append(els, ldiff.Element{ + el := ldiff.Element{ Id: id, Head: head, - }) + } + els = append(els, el) } } s.diff.Set(els...) @@ -80,6 +90,7 @@ func (s *space) syncLoop() { for { select { case <-s.syncCtx.Done(): + return case <-ticker.C: doSync() } @@ -88,45 +99,40 @@ func (s *space) syncLoop() { } func (s *space) sync(ctx context.Context) error { - peerIds, err := s.peerIds(ctx) + peers, err := s.getPeers(ctx) if err != nil { return err } - for _, peerId := range peerIds { - if err := s.syncWithPeer(ctx, peerId); err != nil { - log.Error("can't sync with peer", zap.String("peer", peerId), zap.Error(err)) + for _, p := range peers { + if err := s.syncWithPeer(ctx, p); err != nil { + log.Error("can't sync with peer", zap.String("peer", p.Id()), zap.Error(err)) } } return nil } -func (s *space) syncWithPeer(ctx context.Context, peerId string) (err error) { - rdiff := remotediff.NewRemoteDiff(s.s.pool, peerId, s.id) +func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { + cl := spacesync.NewDRPCSpaceClient(p) + rdiff := remotediff.NewRemoteDiff(s.id, cl) newIds, changedIds, removedIds, err := s.diff.Diff(ctx, rdiff) if err != nil { return nil } - log.Info("sync done:", zap.Strings("newIds", newIds), zap.Strings("changedIds", changedIds), zap.Strings("removedIds", removedIds)) + log.Info("sync done:", zap.Int("newIds", len(newIds)), zap.Int("changedIds", len(changedIds)), zap.Int("removedIds", len(removedIds))) return } -func (s *space) peerIds(ctx context.Context) (peerIds []string, err error) { +func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { if s.conf.IsResponsible(s.id) { - peers, err := s.conf.AllPeers(ctx, s.id) - if err != nil { - return nil, err - } - for _, p := range peers { - peerIds = append(peerIds, p.Id()) - } + return s.conf.AllPeers(ctx, s.id) } else { - peer, err := s.conf.OnePeer(ctx, s.id) + var p peer.Peer + p, err = s.conf.OnePeer(ctx, s.id) if err != nil { return nil, err } - peerIds = append(peerIds, peer.Id()) + return []peer.Peer{p}, nil } - return } func (s *space) Close() error { From feff4ad8906d4b385d4239b0f9caea967b9bb00d Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 8 Sep 2022 12:15:54 +0300 Subject: [PATCH 06/44] rename protos-go -> protos --- Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8d0d2cb3..c7282f4f 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ endif export PATH=$(GOPATH)/bin:$(shell echo $$PATH) # TODO: folders were changed, so we should update Makefile and protos generation -protos-go: +protos: @echo 'Generating protobuf packages (Go)...' # Uncomment if needed @$(eval ROOT_PKG := pkg) From caa725dc209262ba7307d2a55850c7ada6516b84 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Thu, 8 Sep 2022 21:56:32 +0300 Subject: [PATCH 07/44] package moving + commonaspace and nidespace services --- Makefile | 2 +- app/app.go | 4 +- app/app_test.go | 2 +- cmd/node/node.go | 20 +- {service => common}/account/service.go | 3 +- common/commonspace/periodicsync.go | 58 +++++ .../commonspace}/remotediff/remotediff.go | 24 +- .../remotediff/remotediff_test.go | 4 +- common/commonspace/rpchandler.go | 25 ++ common/commonspace/service.go | 49 ++++ common/commonspace/space.go | 115 +++++++++ .../spacesyncproto}/protos/spacesync.proto | 10 +- .../spacesyncproto}/spacesync.pb.go | 242 +++++++++++++++--- .../spacesyncproto/spacesync_drpc.pb.go | 188 ++++++++++++++ {service => common}/net/dialer/dialer.go | 6 +- {service => common}/net/peer/peer.go | 0 {service => common}/net/pool/pool.go | 18 +- {service => common}/net/pool/pool_test.go | 6 +- .../net/rpc/server/drpcserver.go | 16 +- {service => common}/net/rpc/server/util.go | 0 .../net/rpc/server/util_windows.go | 0 {service => common}/net/secure/context.go | 0 {service => common}/net/secure/listener.go | 0 {service => common}/net/secure/service.go | 2 +- .../nodeconf}/configuration.go | 8 +- .../nodeconf}/service.go | 9 +- config/config.go | 3 +- node/nodespace/rpchandler.go | 30 +++ node/nodespace/service.go | 71 +++++ pkg/ocache/ocache.go | 31 ++- service/api/service.go | 2 +- service/node/service.go | 2 +- service/space/rpc.go | 18 -- service/space/service.go | 76 ------ service/space/space.go | 142 ---------- service/space/spacesync/spacesync_drpc.pb.go | 113 -------- service/sync/document/service.go | 4 +- service/sync/message/service.go | 7 +- service/sync/requesthandler/requesthandler.go | 4 +- service/treecache/service.go | 4 +- 40 files changed, 850 insertions(+), 468 deletions(-) rename {service => common}/account/service.go (95%) create mode 100644 common/commonspace/periodicsync.go rename {service/space => common/commonspace}/remotediff/remotediff.go (66%) rename {service/space => common/commonspace}/remotediff/remotediff_test.go (84%) create mode 100644 common/commonspace/rpchandler.go create mode 100644 common/commonspace/service.go create mode 100644 common/commonspace/space.go rename {service/space/spacesync => common/commonspace/spacesyncproto}/protos/spacesync.proto (83%) rename {service/space/spacesync => common/commonspace/spacesyncproto}/spacesync.pb.go (81%) create mode 100644 common/commonspace/spacesyncproto/spacesync_drpc.pb.go rename {service => common}/net/dialer/dialer.go (90%) rename {service => common}/net/peer/peer.go (100%) rename {service => common}/net/pool/pool.go (81%) rename {service => common}/net/pool/pool_test.go (95%) rename {service => common}/net/rpc/server/drpcserver.go (84%) rename {service => common}/net/rpc/server/util.go (100%) rename {service => common}/net/rpc/server/util_windows.go (100%) rename {service => common}/net/secure/context.go (100%) rename {service => common}/net/secure/listener.go (100%) rename {service => common}/net/secure/service.go (96%) rename {service/configuration => common/nodeconf}/configuration.go (88%) rename {service/configuration => common/nodeconf}/service.go (87%) create mode 100644 node/nodespace/rpchandler.go create mode 100644 node/nodespace/service.go delete mode 100644 service/space/rpc.go delete mode 100644 service/space/service.go delete mode 100644 service/space/space.go delete mode 100644 service/space/spacesync/spacesync_drpc.pb.go diff --git a/Makefile b/Makefile index c7282f4f..2480115f 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ protos: $(GOGO_START) protoc --gogofaster_out=:. $(P_PLAINTEXT_CHANGES_PATH_PB)/protos/*.proto; mv $(P_PLAINTEXT_CHANGES_PATH_PB)/protos/*.go $(P_PLAINTEXT_CHANGES_PATH_PB) $(eval PKGMAP := $$(P_ACL_CHANGES),$$(P_TREE_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. service/space/spacesync/protos/*.proto + protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) diff --git a/app/app.go b/app/app.go index ef0d46bd..718b24b6 100644 --- a/app/app.go +++ b/app/app.go @@ -27,7 +27,7 @@ var ( type Component interface { // Init will be called first // When returned error is not nil - app start will be aborted - Init(ctx context.Context, a *App) (err error) + Init(a *App) (err error) // Name must return unique service name Name() (name string) } @@ -157,7 +157,7 @@ func (app *App) Start(ctx context.Context) (err error) { } for i, s := range app.components { - if err = s.Init(ctx, app); err != nil { + if err = s.Init(app); err != nil { closeServices(i) return fmt.Errorf("can't init service '%s': %v", s.Name(), err) } diff --git a/app/app_test.go b/app/app_test.go index b4a93007..cdc52445 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -131,7 +131,7 @@ type testComponent struct { ids testIds } -func (t *testComponent) Init(ctx context.Context, a *App) error { +func (t *testComponent) Init(a *App) error { t.ids.initId = t.seq.New() return t.err } diff --git a/cmd/node/node.go b/cmd/node/node.go index c73a164c..6f4cdf88 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -6,15 +6,16 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc/server" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" + "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space" "go.uber.org/zap" "net/http" _ "net/http/pprof" @@ -90,11 +91,12 @@ func main() { func Bootstrap(a *app.App) { a.Register(account.New()). Register(node.New()). - Register(configuration.New()). + Register(nodeconf.New()). Register(secure.New()). Register(dialer.New()). Register(pool.New()). - Register(space.New()). + Register(nodespace.New()). + Register(commonspace.New()). Register(server.New()) //Register(document.New()). diff --git a/service/account/service.go b/common/account/service.go similarity index 95% rename from service/account/service.go rename to common/account/service.go index ed66fe1e..06749842 100644 --- a/service/account/service.go +++ b/common/account/service.go @@ -1,7 +1,6 @@ package account import ( - "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" @@ -33,7 +32,7 @@ func New() app.Component { return &service{} } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { cfg := a.MustComponent(config.CName).(*config.Config) // decoding our keys diff --git a/common/commonspace/periodicsync.go b/common/commonspace/periodicsync.go new file mode 100644 index 00000000..219f953e --- /dev/null +++ b/common/commonspace/periodicsync.go @@ -0,0 +1,58 @@ +package commonspace + +import ( + "context" + "go.uber.org/zap" + "time" +) + +func newPeriodicSync(periodSeconds int, sync func(ctx context.Context) error, l *zap.Logger) *periodicSync { + ctx, cancel := context.WithCancel(context.Background()) + ps := &periodicSync{ + log: l, + sync: sync, + syncCtx: ctx, + syncCancel: cancel, + syncLoopDone: make(chan struct{}), + } + go ps.syncLoop(periodSeconds) + return ps +} + +type periodicSync struct { + log *zap.Logger + sync func(ctx context.Context) error + syncCtx context.Context + syncCancel context.CancelFunc + syncLoopDone chan struct{} +} + +func (p *periodicSync) syncLoop(periodSeconds int) { + period := time.Duration(periodSeconds) * time.Second + defer close(p.syncLoopDone) + doSync := func() { + ctx, cancel := context.WithTimeout(p.syncCtx, time.Minute) + defer cancel() + if err := p.sync(ctx); err != nil { + p.log.Warn("periodic sync error", zap.Error(err)) + } + } + doSync() + if period > 0 { + ticker := time.NewTicker(period) + defer ticker.Stop() + for { + select { + case <-p.syncCtx.Done(): + return + case <-ticker.C: + doSync() + } + } + } +} + +func (p *periodicSync) Close() { + p.syncCancel() + <-p.syncLoopDone +} diff --git a/service/space/remotediff/remotediff.go b/common/commonspace/remotediff/remotediff.go similarity index 66% rename from service/space/remotediff/remotediff.go rename to common/commonspace/remotediff/remotediff.go index 2ba6769a..1a01814c 100644 --- a/service/space/remotediff/remotediff.go +++ b/common/commonspace/remotediff/remotediff.go @@ -2,12 +2,12 @@ package remotediff import ( "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" ) type Client interface { - HeadSync(ctx context.Context, in *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) + HeadSync(ctx context.Context, in *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) } func NewRemoteDiff(spaceId string, client Client) ldiff.Remote { @@ -24,15 +24,15 @@ type remote struct { func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff.RangeResult) (results []ldiff.RangeResult, err error) { results = resBuf[:0] - pbRanges := make([]*spacesync.HeadSyncRange, 0, len(ranges)) + pbRanges := make([]*spacesyncproto.HeadSyncRange, 0, len(ranges)) for _, rg := range ranges { - pbRanges = append(pbRanges, &spacesync.HeadSyncRange{ + pbRanges = append(pbRanges, &spacesyncproto.HeadSyncRange{ From: rg.From, To: rg.To, Limit: uint32(rg.Limit), }) } - req := &spacesync.HeadSyncRequest{ + req := &spacesyncproto.HeadSyncRequest{ SpaceId: r.spaceId, Ranges: pbRanges, } @@ -60,7 +60,7 @@ func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff return } -func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesync.HeadSyncRequest) (resp *spacesync.HeadSyncResponse, err error) { +func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) { ranges := make([]ldiff.Range, 0, len(req.Ranges)) for _, reqRange := range req.Ranges { ranges = append(ranges, ldiff.Range{ @@ -74,21 +74,21 @@ func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesync.HeadS return } - resp = &spacesync.HeadSyncResponse{ - Results: make([]*spacesync.HeadSyncResult, 0, len(res)), + resp = &spacesyncproto.HeadSyncResponse{ + Results: make([]*spacesyncproto.HeadSyncResult, 0, len(res)), } for _, rangeRes := range res { - var elements []*spacesync.HeadSyncResultElement + var elements []*spacesyncproto.HeadSyncResultElement if len(rangeRes.Elements) > 0 { - elements = make([]*spacesync.HeadSyncResultElement, 0, len(rangeRes.Elements)) + elements = make([]*spacesyncproto.HeadSyncResultElement, 0, len(rangeRes.Elements)) for _, el := range rangeRes.Elements { - elements = append(elements, &spacesync.HeadSyncResultElement{ + elements = append(elements, &spacesyncproto.HeadSyncResultElement{ Id: el.Id, Head: el.Head, }) } } - resp.Results = append(resp.Results, &spacesync.HeadSyncResult{ + resp.Results = append(resp.Results, &spacesyncproto.HeadSyncResult{ Hash: rangeRes.Hash, Elements: elements, Count: uint32(rangeRes.Count), diff --git a/service/space/remotediff/remotediff_test.go b/common/commonspace/remotediff/remotediff_test.go similarity index 84% rename from service/space/remotediff/remotediff_test.go rename to common/commonspace/remotediff/remotediff_test.go index e1cf96ed..d209b753 100644 --- a/service/space/remotediff/remotediff_test.go +++ b/common/commonspace/remotediff/remotediff_test.go @@ -3,8 +3,8 @@ package remotediff import ( "context" "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" @@ -36,6 +36,6 @@ type mockClient struct { l ldiff.Diff } -func (m *mockClient) HeadSync(ctx context.Context, in *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { +func (m *mockClient) HeadSync(ctx context.Context, in *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { return HandlerRangeRequest(ctx, m.l, in) } diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go new file mode 100644 index 00000000..3ce71e1a --- /dev/null +++ b/common/commonspace/rpchandler.go @@ -0,0 +1,25 @@ +package commonspace + +import ( + "context" + "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" +) + +type RpcHandler interface { + HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) + Stream(stream spacesyncproto.DRPCSpace_StreamStream) error +} + +type rpcHandler struct { + s *space +} + +func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { + return remotediff.HandlerRangeRequest(ctx, r.s.diff, req) +} + +func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error { + return fmt.Errorf("not implemented") +} diff --git a/common/commonspace/service.go b/common/commonspace/service.go new file mode 100644 index 00000000..85dd8ae9 --- /dev/null +++ b/common/commonspace/service.go @@ -0,0 +1,49 @@ +package commonspace + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" + "github.com/anytypeio/go-anytype-infrastructure-experiments/config" +) + +const CName = "common.commonspace" + +var log = logger.NewNamed(CName) + +func New() Service { + return &service{} +} + +type Service interface { + CreateSpace(ctx context.Context, id string) (sp Space, err error) + app.Component +} + +type service struct { + config config.Space + configurationService nodeconf.Service +} + +func (s *service) Init(a *app.App) (err error) { + s.config = a.MustComponent(config.CName).(*config.Config).Space + s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) + return nil +} + +func (s *service) Name() (name string) { + return CName +} + +func (s *service) CreateSpace(ctx context.Context, id string) (Space, error) { + sp := &space{ + id: id, + nconf: s.configurationService.GetLast(), + conf: s.config, + } + if err := sp.Init(ctx); err != nil { + return nil, err + } + return sp, nil +} diff --git a/common/commonspace/space.go b/common/commonspace/space.go new file mode 100644 index 00000000..4f83dd97 --- /dev/null +++ b/common/commonspace/space.go @@ -0,0 +1,115 @@ +package commonspace + +import ( + "context" + "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" + "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" + "go.uber.org/zap" + "math/rand" + "sync" + "time" +) + +type Space interface { + Id() string + + SpaceSyncRpc() RpcHandler + + Close() error +} + +type space struct { + id string + nconf nodeconf.Configuration + conf config.Space + diff ldiff.Diff + rpc *rpcHandler + periodicSync *periodicSync + mu sync.RWMutex +} + +func (s *space) Id() string { + return s.id +} + +func (s *space) Init(ctx context.Context) error { + s.diff = ldiff.New(16, 16) + s.periodicSync = newPeriodicSync(s.conf.SyncPeriod, s.sync, log.With(zap.String("spaceId", s.id))) + s.rpc = &rpcHandler{s: s} + s.testFill() + return nil +} + +func (s *space) SpaceSyncRpc() RpcHandler { + return s.rpc +} + +func (s *space) testFill() { + var n = 1000 + var els = make([]ldiff.Element, 0, n) + rand.Seed(time.Now().UnixNano()) + for i := 0; i < n; i++ { + if rand.Intn(n) > 2 { + id := fmt.Sprintf("%s.%d", s.id, i) + head := "head." + id + if rand.Intn(n) > n-10 { + head += ".modified" + } + el := ldiff.Element{ + Id: id, + Head: head, + } + els = append(els, el) + } + } + s.diff.Set(els...) +} + +func (s *space) sync(ctx context.Context) error { + st := time.Now() + peers, err := s.getPeers(ctx) + if err != nil { + return err + } + for _, p := range peers { + if err := s.syncWithPeer(ctx, p); err != nil { + log.Error("can't sync with peer", zap.String("peer", p.Id()), zap.Error(err)) + } + } + log.Info("synced", zap.String("spaceId", s.id), zap.Duration("dur", time.Since(st))) + return nil +} + +func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { + cl := spacesyncproto.NewDRPCSpaceClient(p) + rdiff := remotediff.NewRemoteDiff(s.id, cl) + newIds, changedIds, removedIds, err := s.diff.Diff(ctx, rdiff) + if err != nil { + return nil + } + log.Info("sync done:", zap.Int("newIds", len(newIds)), zap.Int("changedIds", len(changedIds)), zap.Int("removedIds", len(removedIds))) + return +} + +func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { + if s.nconf.IsResponsible(s.id) { + return s.nconf.AllPeers(ctx, s.id) + } else { + var p peer.Peer + p, err = s.nconf.OnePeer(ctx, s.id) + if err != nil { + return nil, err + } + return []peer.Peer{p}, nil + } +} + +func (s *space) Close() error { + s.periodicSync.Close() + return nil +} diff --git a/service/space/spacesync/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto similarity index 83% rename from service/space/spacesync/protos/spacesync.proto rename to common/commonspace/spacesyncproto/protos/spacesync.proto index f0b68b11..0a1e434d 100644 --- a/service/space/spacesync/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -1,16 +1,24 @@ syntax = "proto3"; package anySpace; -option go_package = "service/space/spacesync"; +option go_package = "common/commonspace/spacesyncproto"; enum ErrCodes { Unexpected = 0; } + service Space { // HeadSync compares all objects and their hashes in a space rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse); + rpc Stream( stream Msg) returns (stream Msg); } +// TODO: temporary mock message +message Msg { + string spaceId = 1; +} + + // HeadSyncRange presenting a request for one range message HeadSyncRange { diff --git a/service/space/spacesync/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go similarity index 81% rename from service/space/spacesync/spacesync.pb.go rename to common/commonspace/spacesyncproto/spacesync.pb.go index 92772dc4..9db560cb 100644 --- a/service/space/spacesync/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: service/space/spacesync/protos/spacesync.proto +// source: common/commonspace/spacesyncproto/protos/spacesync.proto -package spacesync +package spacesyncproto import ( fmt "fmt" @@ -41,7 +41,52 @@ func (x ErrCodes) String() string { } func (ErrCodes) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{0} + return fileDescriptor_5855f4ef9cf24cdb, []int{0} +} + +// TODO: temporary mock message +type Msg struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` +} + +func (m *Msg) Reset() { *m = Msg{} } +func (m *Msg) String() string { return proto.CompactTextString(m) } +func (*Msg) ProtoMessage() {} +func (*Msg) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{0} +} +func (m *Msg) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *Msg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_Msg.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 *Msg) XXX_Merge(src proto.Message) { + xxx_messageInfo_Msg.Merge(m, src) +} +func (m *Msg) XXX_Size() int { + return m.Size() +} +func (m *Msg) XXX_DiscardUnknown() { + xxx_messageInfo_Msg.DiscardUnknown(m) +} + +var xxx_messageInfo_Msg proto.InternalMessageInfo + +func (m *Msg) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" } // HeadSyncRange presenting a request for one range @@ -55,7 +100,7 @@ func (m *HeadSyncRange) Reset() { *m = HeadSyncRange{} } func (m *HeadSyncRange) String() string { return proto.CompactTextString(m) } func (*HeadSyncRange) ProtoMessage() {} func (*HeadSyncRange) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{0} + return fileDescriptor_5855f4ef9cf24cdb, []int{1} } func (m *HeadSyncRange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -116,7 +161,7 @@ func (m *HeadSyncResult) Reset() { *m = HeadSyncResult{} } func (m *HeadSyncResult) String() string { return proto.CompactTextString(m) } func (*HeadSyncResult) ProtoMessage() {} func (*HeadSyncResult) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{1} + return fileDescriptor_5855f4ef9cf24cdb, []int{2} } func (m *HeadSyncResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -176,7 +221,7 @@ func (m *HeadSyncResultElement) Reset() { *m = HeadSyncResultElement{} } func (m *HeadSyncResultElement) String() string { return proto.CompactTextString(m) } func (*HeadSyncResultElement) ProtoMessage() {} func (*HeadSyncResultElement) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{2} + return fileDescriptor_5855f4ef9cf24cdb, []int{3} } func (m *HeadSyncResultElement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -229,7 +274,7 @@ func (m *HeadSyncRequest) Reset() { *m = HeadSyncRequest{} } func (m *HeadSyncRequest) String() string { return proto.CompactTextString(m) } func (*HeadSyncRequest) ProtoMessage() {} func (*HeadSyncRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{3} + return fileDescriptor_5855f4ef9cf24cdb, []int{4} } func (m *HeadSyncRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -281,7 +326,7 @@ func (m *HeadSyncResponse) Reset() { *m = HeadSyncResponse{} } func (m *HeadSyncResponse) String() string { return proto.CompactTextString(m) } func (*HeadSyncResponse) ProtoMessage() {} func (*HeadSyncResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_11d78c2fb7c80384, []int{4} + return fileDescriptor_5855f4ef9cf24cdb, []int{5} } func (m *HeadSyncResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -319,6 +364,7 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) + proto.RegisterType((*Msg)(nil), "anySpace.Msg") proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") proto.RegisterType((*HeadSyncResult)(nil), "anySpace.HeadSyncResult") proto.RegisterType((*HeadSyncResultElement)(nil), "anySpace.HeadSyncResultElement") @@ -327,35 +373,66 @@ func init() { } func init() { - proto.RegisterFile("service/space/spacesync/protos/spacesync.proto", fileDescriptor_11d78c2fb7c80384) + proto.RegisterFile("common/commonspace/spacesyncproto/protos/spacesync.proto", fileDescriptor_5855f4ef9cf24cdb) } -var fileDescriptor_11d78c2fb7c80384 = []byte{ - // 369 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xbf, 0x6e, 0xe2, 0x40, - 0x10, 0xc6, 0x6d, 0xf3, 0xcf, 0xcc, 0x1d, 0x1c, 0x5a, 0xdd, 0x09, 0x1f, 0x85, 0x0f, 0xb9, 0x42, - 0x57, 0x18, 0x85, 0x94, 0x54, 0x49, 0x44, 0x14, 0x52, 0x2e, 0x4a, 0x13, 0xa5, 0x71, 0xec, 0x49, - 0xb0, 0x04, 0xbb, 0x8e, 0x77, 0x49, 0xc2, 0x5b, 0xe4, 0xb1, 0x52, 0x52, 0xa6, 0x8c, 0xe0, 0x45, - 0x22, 0x0f, 0x31, 0x24, 0x92, 0x69, 0xac, 0x99, 0xf1, 0x7c, 0xdf, 0xfc, 0x76, 0x34, 0xe0, 0x2b, - 0x4c, 0x1f, 0xe3, 0x10, 0xfb, 0x2a, 0x09, 0xf2, 0xaf, 0x5a, 0x8a, 0xb0, 0x9f, 0xa4, 0x52, 0x4b, - 0xb5, 0x2f, 0xf8, 0x54, 0x60, 0x76, 0x20, 0x96, 0x93, 0xac, 0xe6, 0x8d, 0xa1, 0x71, 0x81, 0x41, - 0x34, 0x59, 0x8a, 0x90, 0x07, 0xe2, 0x1e, 0x19, 0x83, 0xf2, 0x5d, 0x2a, 0xe7, 0x8e, 0xd9, 0x35, - 0x7b, 0x65, 0x4e, 0x31, 0x6b, 0x82, 0xa5, 0xa5, 0x63, 0x51, 0xc5, 0xd2, 0x92, 0xfd, 0x86, 0xca, - 0x2c, 0x9e, 0xc7, 0xda, 0x29, 0x75,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 0xdf, 0xd7, 0xae, 0xf9, - 0xb2, 0x71, 0x8d, 0xd5, 0xc6, 0x35, 0xde, 0x36, 0xae, 0x71, 0xdd, 0x3e, 0x70, 0x62, 0xb7, 0x55, - 0x3a, 0xa9, 0xe3, 0x8f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x09, 0x7e, 0xc8, 0x77, 0x84, 0x02, 0x00, - 0x00, +var fileDescriptor_5855f4ef9cf24cdb = []byte{ + // 400 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcd, 0xce, 0xd2, 0x40, + 0x14, 0xed, 0x94, 0xbf, 0x72, 0x15, 0x24, 0x13, 0x8d, 0xb5, 0x8b, 0x82, 0x5d, 0x35, 0x2c, 0xa8, + 0xc1, 0x8d, 0x09, 0x2b, 0x35, 0x18, 0x59, 0xb0, 0x19, 0xe2, 0xc6, 0xb8, 0xa9, 0xed, 0x08, 0x4d, + 0xe8, 0x4c, 0xed, 0x0c, 0x2a, 0x6f, 0xe1, 0x63, 0xb9, 0x64, 0xe9, 0xd2, 0xc0, 0x8b, 0x98, 0xde, + 0x7e, 0x85, 0x8f, 0xa4, 0xe4, 0xdb, 0xcc, 0xfd, 0xe9, 0x39, 0xe7, 0x9e, 0x7b, 0x53, 0x78, 0x13, + 0xc9, 0x34, 0x95, 0x22, 0x28, 0x83, 0xca, 0xc2, 0x88, 0x07, 0xf8, 0xaa, 0xbd, 0x88, 0xb2, 0x5c, + 0x6a, 0x19, 0xe0, 0xab, 0x2e, 0xdd, 0x09, 0x36, 0xa8, 0x15, 0x8a, 0xfd, 0xaa, 0xe8, 0x79, 0x43, + 0x68, 0x2c, 0xd5, 0x9a, 0xda, 0xd0, 0x41, 0xcc, 0x22, 0xb6, 0xc9, 0x88, 0xf8, 0x5d, 0x56, 0x95, + 0xde, 0x02, 0x7a, 0x1f, 0x79, 0x18, 0xaf, 0xf6, 0x22, 0x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0x4c, 0xdf, 0x82, 0x55, 0xf1, 0xe9, 0x8b, 0x3a, 0x4d, 0x5c, 0xcf, 0x71, 0x6a, 0xc7, 0x95, 0xde, + 0xc6, 0xd0, 0x5e, 0xe9, 0x9c, 0x87, 0x29, 0xed, 0x5d, 0x50, 0x4b, 0xb5, 0x76, 0xae, 0x4b, 0x9f, + 0xbc, 0x22, 0xef, 0x66, 0x7f, 0x8e, 0x2e, 0x39, 0x1c, 0x5d, 0xf2, 0xef, 0xe8, 0x92, 0xdf, 0x27, + 0xd7, 0x38, 0x9c, 0x5c, 0xe3, 0xef, 0xc9, 0x35, 0x3e, 0xbf, 0x7c, 0xf0, 0xcf, 0xfd, 0xda, 0xc6, + 0xf0, 0xfa, 0x7f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x5a, 0xf6, 0x94, 0x21, 0xe5, 0x02, 0x00, 0x00, +} + +func (m *Msg) 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 *Msg) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *Msg) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + 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 } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -574,6 +651,19 @@ func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } +func (m *Msg) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func (m *HeadSyncRange) Size() (n int) { if m == nil { return 0 @@ -671,6 +761,88 @@ func sovSpacesync(x uint64) (n int) { func sozSpacesync(x uint64) (n int) { return sovSpacesync(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } +func (m *Msg) 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: Msg: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Msg: illegal tag %d (wire type %d)", fieldNum, wire) + } + 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 + 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 *HeadSyncRange) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/spacesyncproto/spacesync_drpc.pb.go b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go new file mode 100644 index 00000000..b17dc589 --- /dev/null +++ b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go @@ -0,0 +1,188 @@ +// Code generated by protoc-gen-go-drpc. DO NOT EDIT. +// protoc-gen-go-drpc version: v0.0.32 +// source: common/commonspace/spacesyncproto/protos/spacesync.proto + +package spacesyncproto + +import ( + bytes "bytes" + context "context" + errors "errors" + jsonpb "github.com/gogo/protobuf/jsonpb" + proto "github.com/gogo/protobuf/proto" + drpc "storj.io/drpc" + drpcerr "storj.io/drpc/drpcerr" +) + +type drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto struct{} + +func (drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto) Marshal(msg drpc.Message) ([]byte, error) { + return proto.Marshal(msg.(proto.Message)) +} + +func (drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto) Unmarshal(buf []byte, msg drpc.Message) error { + return proto.Unmarshal(buf, msg.(proto.Message)) +} + +func (drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto) JSONMarshal(msg drpc.Message) ([]byte, error) { + var buf bytes.Buffer + err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message)) + if err != nil { + return nil, err + } + return buf.Bytes(), nil +} + +func (drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error { + return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message)) +} + +type DRPCSpaceClient interface { + DRPCConn() drpc.Conn + + HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) + Stream(ctx context.Context) (DRPCSpace_StreamClient, error) +} + +type drpcSpaceClient struct { + cc drpc.Conn +} + +func NewDRPCSpaceClient(cc drpc.Conn) DRPCSpaceClient { + return &drpcSpaceClient{cc} +} + +func (c *drpcSpaceClient) DRPCConn() drpc.Conn { return c.cc } + +func (c *drpcSpaceClient) HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) { + out := new(HeadSyncResponse) + err := c.cc.Invoke(ctx, "/anySpace.Space/HeadSync", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + +func (c *drpcSpaceClient) Stream(ctx context.Context) (DRPCSpace_StreamClient, error) { + stream, err := c.cc.NewStream(ctx, "/anySpace.Space/Stream", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) + if err != nil { + return nil, err + } + x := &drpcSpace_StreamClient{stream} + return x, nil +} + +type DRPCSpace_StreamClient interface { + drpc.Stream + Send(*Msg) error + Recv() (*Msg, error) +} + +type drpcSpace_StreamClient struct { + drpc.Stream +} + +func (x *drpcSpace_StreamClient) Send(m *Msg) error { + return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + +func (x *drpcSpace_StreamClient) Recv() (*Msg, error) { + m := new(Msg) + if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcSpace_StreamClient) RecvMsg(m *Msg) error { + return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + +type DRPCSpaceServer interface { + HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) + Stream(DRPCSpace_StreamStream) error +} + +type DRPCSpaceUnimplementedServer struct{} + +func (s *DRPCSpaceUnimplementedServer) HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +func (s *DRPCSpaceUnimplementedServer) Stream(DRPCSpace_StreamStream) error { + return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + +type DRPCSpaceDescription struct{} + +func (DRPCSpaceDescription) NumMethods() int { return 2 } + +func (DRPCSpaceDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { + switch n { + case 0: + return "/anySpace.Space/HeadSync", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCSpaceServer). + HeadSync( + ctx, + in1.(*HeadSyncRequest), + ) + }, DRPCSpaceServer.HeadSync, true + case 1: + return "/anySpace.Space/Stream", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return nil, srv.(DRPCSpaceServer). + Stream( + &drpcSpace_StreamStream{in1.(drpc.Stream)}, + ) + }, DRPCSpaceServer.Stream, true + default: + return "", nil, nil, nil, false + } +} + +func DRPCRegisterSpace(mux drpc.Mux, impl DRPCSpaceServer) error { + return mux.Register(impl, DRPCSpaceDescription{}) +} + +type DRPCSpace_HeadSyncStream interface { + drpc.Stream + SendAndClose(*HeadSyncResponse) error +} + +type drpcSpace_HeadSyncStream struct { + drpc.Stream +} + +func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return err + } + return x.CloseSend() +} + +type DRPCSpace_StreamStream interface { + drpc.Stream + Send(*Msg) error + Recv() (*Msg, error) +} + +type drpcSpace_StreamStream struct { + drpc.Stream +} + +func (x *drpcSpace_StreamStream) Send(m *Msg) error { + return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) +} + +func (x *drpcSpace_StreamStream) Recv() (*Msg, error) { + m := new(Msg) + if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return nil, err + } + return m, nil +} + +func (x *drpcSpace_StreamStream) RecvMsg(m *Msg) error { + return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) +} diff --git a/service/net/dialer/dialer.go b/common/net/dialer/dialer.go similarity index 90% rename from service/net/dialer/dialer.go rename to common/net/dialer/dialer.go index ade01444..80d0d6f2 100644 --- a/service/net/dialer/dialer.go +++ b/common/net/dialer/dialer.go @@ -5,9 +5,9 @@ import ( "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" "github.com/libp2p/go-libp2p-core/sec" "go.uber.org/zap" "net" @@ -39,7 +39,7 @@ type dialer struct { mu sync.RWMutex } -func (d *dialer) Init(ctx context.Context, a *app.App) (err error) { +func (d *dialer) Init(a *app.App) (err error) { d.transport = a.MustComponent(secure.CName).(secure.Service) nodes := a.MustComponent(config.CName).(*config.Config).Nodes d.peerAddrs = map[string][]string{} diff --git a/service/net/peer/peer.go b/common/net/peer/peer.go similarity index 100% rename from service/net/peer/peer.go rename to common/net/peer/peer.go diff --git a/service/net/pool/pool.go b/common/net/pool/pool.go similarity index 81% rename from service/net/pool/pool.go rename to common/net/pool/pool.go index 6b7cfa67..d4e21bf4 100644 --- a/service/net/pool/pool.go +++ b/common/net/pool/pool.go @@ -5,9 +5,9 @@ import ( "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" "math/rand" "time" ) @@ -40,11 +40,17 @@ type pool struct { cache ocache.OCache } -func (p *pool) Init(ctx context.Context, a *app.App) (err error) { +func (p *pool) Init(a *app.App) (err error) { dialer := a.MustComponent(dialer.CName).(dialer.Dialer) - p.cache = ocache.New(func(ctx context.Context, id string) (value ocache.Object, err error) { - return dialer.Dial(ctx, id) - }, ocache.WithLogger(log.Sugar()), ocache.WithGCPeriod(time.Minute), ocache.WithTTL(time.Minute*5)) + p.cache = ocache.New( + func(ctx context.Context, id string) (value ocache.Object, err error) { + return dialer.Dial(ctx, id) + }, + ocache.WithLogger(log.Sugar()), + ocache.WithGCPeriod(time.Minute), + ocache.WithTTL(time.Minute*5), + ocache.WithRefCounter(false), + ) return nil } diff --git a/service/net/pool/pool_test.go b/common/net/pool/pool_test.go similarity index 95% rename from service/net/pool/pool_test.go rename to common/net/pool/pool_test.go index efc51d38..a7f4a528 100644 --- a/service/net/pool/pool_test.go +++ b/common/net/pool/pool_test.go @@ -5,8 +5,8 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/dialer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "storj.io/drpc" @@ -160,7 +160,7 @@ func (d *dialerMock) UpdateAddrs(addrs map[string][]string) { return } -func (d *dialerMock) Init(ctx context.Context, a *app.App) (err error) { +func (d *dialerMock) Init(a *app.App) (err error) { return } diff --git a/service/net/rpc/server/drpcserver.go b/common/net/rpc/server/drpcserver.go similarity index 84% rename from service/net/rpc/server/drpcserver.go rename to common/net/rpc/server/drpcserver.go index 975c270f..5e6078ff 100644 --- a/service/net/rpc/server/drpcserver.go +++ b/common/net/rpc/server/drpcserver.go @@ -4,9 +4,9 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" + secure2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/secure" "github.com/zeebo/errs" "go.uber.org/zap" "io" @@ -33,16 +33,16 @@ type DRPCServer interface { type drpcServer struct { config config.GrpcServer drpcServer *drpcserver.Server - transport secure.Service - listeners []secure.ContextListener + transport secure2.Service + listeners []secure2.ContextListener pool pool.Pool cancel func() *drpcmux.Mux } -func (s *drpcServer) Init(ctx context.Context, a *app.App) (err error) { +func (s *drpcServer) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(*config.Config).GrpcServer - s.transport = a.MustComponent(secure.CName).(secure.Service) + s.transport = a.MustComponent(secure2.CName).(secure2.Service) s.pool = a.MustComponent(pool.CName).(pool.Pool) return nil } @@ -65,7 +65,7 @@ func (s *drpcServer) Run(ctx context.Context) (err error) { return } -func (s *drpcServer) serve(ctx context.Context, lis secure.ContextListener) { +func (s *drpcServer) serve(ctx context.Context, lis secure2.ContextListener) { l := log.With(zap.String("localAddr", lis.Addr().String())) l.Info("drpc listener started") defer func() { @@ -89,7 +89,7 @@ func (s *drpcServer) serve(ctx context.Context, lis secure.ContextListener) { } continue } - if _, ok := err.(secure.HandshakeError); ok { + if _, ok := err.(secure2.HandshakeError); ok { l.Warn("listener handshake error", zap.Error(err)) continue } diff --git a/service/net/rpc/server/util.go b/common/net/rpc/server/util.go similarity index 100% rename from service/net/rpc/server/util.go rename to common/net/rpc/server/util.go diff --git a/service/net/rpc/server/util_windows.go b/common/net/rpc/server/util_windows.go similarity index 100% rename from service/net/rpc/server/util_windows.go rename to common/net/rpc/server/util_windows.go diff --git a/service/net/secure/context.go b/common/net/secure/context.go similarity index 100% rename from service/net/secure/context.go rename to common/net/secure/context.go diff --git a/service/net/secure/listener.go b/common/net/secure/listener.go similarity index 100% rename from service/net/secure/listener.go rename to common/net/secure/listener.go diff --git a/service/net/secure/service.go b/common/net/secure/service.go similarity index 96% rename from service/net/secure/service.go rename to common/net/secure/service.go index 5c93862b..40a30f8c 100644 --- a/service/net/secure/service.go +++ b/common/net/secure/service.go @@ -35,7 +35,7 @@ type service struct { key crypto.PrivKey } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { account := a.MustComponent(config.CName).(*config.Config).Account decoder := signingkey.NewEDPrivKeyDecoder() pkb, err := decoder.DecodeFromStringIntoBytes(account.SigningKey) diff --git a/service/configuration/configuration.go b/common/nodeconf/configuration.go similarity index 88% rename from service/configuration/configuration.go rename to common/nodeconf/configuration.go index c242d79d..5c055bbb 100644 --- a/service/configuration/configuration.go +++ b/common/nodeconf/configuration.go @@ -1,10 +1,10 @@ -package configuration +package nodeconf import ( "context" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" "github.com/anytypeio/go-chash" ) @@ -13,7 +13,7 @@ func New() Service { } type Configuration interface { - // Id returns current configuration id + // Id returns current nodeconf id Id() string // AllPeers returns all peers by spaceId except current account AllPeers(ctx context.Context, spaceId string) (peers []peer.Peer, err error) diff --git a/service/configuration/service.go b/common/nodeconf/service.go similarity index 87% rename from service/configuration/service.go rename to common/nodeconf/service.go index 9cd920f7..870223cb 100644 --- a/service/configuration/service.go +++ b/common/nodeconf/service.go @@ -1,16 +1,15 @@ -package configuration +package nodeconf import ( - "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" "github.com/anytypeio/go-chash" ) -const CName = "configuration" +const CName = "common.nodeconf" const ( partitionCount = 3000 @@ -32,7 +31,7 @@ type service struct { last Configuration } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { conf := a.MustComponent(config.CName).(*config.Config) s.accountId = conf.Account.PeerId s.pool = a.MustComponent(pool.CName).(pool.Pool) diff --git a/config/config.go b/config/config.go index 4f5ed612..b8a84e34 100644 --- a/config/config.go +++ b/config/config.go @@ -1,7 +1,6 @@ package config import ( - "context" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" @@ -32,7 +31,7 @@ type Config struct { Space Space `yaml:"space"` } -func (c *Config) Init(ctx context.Context, a *app.App) (err error) { +func (c *Config) Init(a *app.App) (err error) { logger.NewNamed("config").Info(fmt.Sprint(c.Space)) return } diff --git a/node/nodespace/rpchandler.go b/node/nodespace/rpchandler.go new file mode 100644 index 00000000..082e7b90 --- /dev/null +++ b/node/nodespace/rpchandler.go @@ -0,0 +1,30 @@ +package nodespace + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" +) + +type rpcHandler struct { + s *service +} + +func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { + sp, err := r.s.GetSpace(ctx, req.SpaceId) + if err != nil { + return nil, err + } + return sp.SpaceSyncRpc().HeadSync(ctx, req) +} + +func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error { + msg, err := stream.Recv() + if err != nil { + return err + } + sp, err := r.s.GetSpace(stream.Context(), msg.SpaceId) + if err != nil { + return err + } + return sp.SpaceSyncRpc().Stream(stream) +} diff --git a/node/nodespace/service.go b/node/nodespace/service.go new file mode 100644 index 00000000..27226bc2 --- /dev/null +++ b/node/nodespace/service.go @@ -0,0 +1,71 @@ +package nodespace + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server" + "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" + "time" +) + +const CName = "node.nodespace" + +var log = logger.NewNamed(CName) + +func New() Service { + return &service{} +} + +type Service interface { + GetSpace(ctx context.Context, id string) (commonspace.Space, error) + app.ComponentRunnable +} + +type service struct { + conf config.Space + cache ocache.OCache + commonSpace commonspace.Service +} + +func (s *service) Init(a *app.App) (err error) { + s.conf = a.MustComponent(config.CName).(*config.Config).Space + s.commonSpace = a.MustComponent(commonspace.CName).(commonspace.Service) + s.cache = ocache.New( + func(ctx context.Context, id string) (value ocache.Object, err error) { + return s.commonSpace.CreateSpace(ctx, id) + }, + ocache.WithLogger(log.Sugar()), + ocache.WithGCPeriod(time.Minute), + ocache.WithTTL(time.Duration(s.conf.GCTTL)*time.Second), + ocache.WithRefCounter(false), + ) + return spacesyncproto.DRPCRegisterSpace(a.MustComponent(server.CName).(server.DRPCServer), &rpcHandler{s}) +} + +func (s *service) Name() (name string) { + return CName +} + +func (s *service) Run(ctx context.Context) (err error) { + go func() { + time.Sleep(time.Second * 5) + _, _ = s.GetSpace(ctx, "testDSpace") + }() + return +} + +func (s *service) GetSpace(ctx context.Context, id string) (commonspace.Space, error) { + v, err := s.cache.Get(ctx, id) + if err != nil { + return nil, err + } + return v.(commonspace.Space), nil +} + +func (s *service) Close(ctx context.Context) (err error) { + return s.cache.Close() +} diff --git a/pkg/ocache/ocache.go b/pkg/ocache/ocache.go index 4f0cf0ba..44dc9d42 100644 --- a/pkg/ocache/ocache.go +++ b/pkg/ocache/ocache.go @@ -45,6 +45,12 @@ var WithGCPeriod = func(gcPeriod time.Duration) Option { } } +var WithRefCounter = func(enable bool) Option { + return func(cache *oCache) { + cache.noRefCounter = !enable + } +} + func New(loadFunc LoadFunc, opts ...Option) OCache { c := &oCache{ data: make(map[string]*entry), @@ -124,15 +130,16 @@ type OCache interface { } type oCache struct { - mu sync.Mutex - data map[string]*entry - loadFunc LoadFunc - timeNow func() time.Time - ttl time.Duration - gc time.Duration - closed bool - closeCh chan struct{} - log *zap.SugaredLogger + mu sync.Mutex + data map[string]*entry + loadFunc LoadFunc + timeNow func() time.Time + ttl time.Duration + gc time.Duration + closed bool + closeCh chan struct{} + log *zap.SugaredLogger + noRefCounter bool } func (c *oCache) Get(ctx context.Context, id string) (value Object, err error) { @@ -155,7 +162,9 @@ func (c *oCache) Get(ctx context.Context, id string) (value Object, err error) { c.data[id] = e } e.lastUsage = c.timeNow() - e.refCount++ + if !c.noRefCounter { + e.refCount++ + } c.mu.Unlock() if load { @@ -206,7 +215,7 @@ func (c *oCache) Release(id string) bool { return false } if e, ok := c.data[id]; ok { - if e.refCount > 0 { + if !c.noRefCounter && e.refCount > 0 { e.refCount-- return true } diff --git a/service/api/service.go b/service/api/service.go index 8ab7eb26..e1b60b04 100644 --- a/service/api/service.go +++ b/service/api/service.go @@ -30,7 +30,7 @@ type service struct { cfg *config.Config } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { s.treeCache = a.MustComponent(treecache.CName).(treecache.Service) s.documentService = a.MustComponent(document.CName).(document.Service) s.cfg = a.MustComponent(config.CName).(*config.Config) diff --git a/service/node/service.go b/service/node/service.go index 877c8860..8b86fa9f 100644 --- a/service/node/service.go +++ b/service/node/service.go @@ -44,7 +44,7 @@ type service struct { nodes []*Node } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { cfg := a.MustComponent(config.CName).(*config.Config) signDecoder := signingkey.NewEDPrivKeyDecoder() rsaDecoder := encryptionkey.NewRSAPrivKeyDecoder() diff --git a/service/space/rpc.go b/service/space/rpc.go deleted file mode 100644 index db056079..00000000 --- a/service/space/rpc.go +++ /dev/null @@ -1,18 +0,0 @@ -package space - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" -) - -type rpcServer struct { - s *service -} - -func (r rpcServer) HeadSync(ctx context.Context, request *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { - sp, err := r.s.get(ctx, request.SpaceId) - if err != nil { - return nil, err - } - return sp.HeadSync(ctx, request) -} diff --git a/service/space/service.go b/service/space/service.go deleted file mode 100644 index ae9be5a4..00000000 --- a/service/space/service.go +++ /dev/null @@ -1,76 +0,0 @@ -package space - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/rpc/server" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" - "time" -) - -const CName = "space" - -var log = logger.NewNamed(CName) - -func New() Service { - return new(service) -} - -type Service interface { - app.ComponentRunnable -} - -type service struct { - conf config.Space - cache ocache.OCache - pool pool.Pool - confService configuration.Service -} - -func (s *service) Init(ctx context.Context, a *app.App) (err error) { - s.conf = a.MustComponent(config.CName).(*config.Config).Space - s.pool = a.MustComponent(pool.CName).(pool.Pool) - s.confService = a.MustComponent(configuration.CName).(configuration.Service) - ttlSec := time.Second * time.Duration(s.conf.GCTTL) - s.cache = ocache.New(s.loadSpace, ocache.WithTTL(ttlSec), ocache.WithGCPeriod(time.Minute), ocache.WithLogger(log.Sugar())) - spacesync.DRPCRegisterSpace(a.MustComponent(server.CName).(server.DRPCServer), rpcServer{s}) - return nil -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) Run(ctx context.Context) (err error) { - go func() { - time.Sleep(time.Second * 10) - s.get(ctx, "testSpace") - }() - return -} - -func (s *service) loadSpace(ctx context.Context, id string) (value ocache.Object, err error) { - // TODO: load from database here - sp := &space{s: s, id: id, conf: s.confService.GetLast()} - if err = sp.Run(ctx); err != nil { - return nil, err - } - return sp, nil -} - -func (s *service) get(ctx context.Context, id string) (Space, error) { - obj, err := s.cache.Get(ctx, id) - if err != nil { - return nil, err - } - return obj.(Space), nil -} - -func (s *service) Close(ctx context.Context) (err error) { - return s.cache.Close() -} diff --git a/service/space/space.go b/service/space/space.go deleted file mode 100644 index 7be85ef4..00000000 --- a/service/space/space.go +++ /dev/null @@ -1,142 +0,0 @@ -package space - -import ( - "context" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/configuration" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/remotediff" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/space/spacesync" - "go.uber.org/zap" - "math/rand" - "sync" - "time" -) - -type Space interface { - Id() string - - HeadSync(ctx context.Context, req *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) - - Close() error -} - -// - -type space struct { - id string - conf configuration.Configuration - diff ldiff.Diff - diffHandler func() - syncCtx context.Context - syncCancel func() - syncLoopDone chan struct{} - s *service - mu sync.RWMutex -} - -func (s *space) Id() string { - return s.id -} - -func (s *space) Run(ctx context.Context) error { - s.diff = ldiff.New(16, 16) - s.syncCtx, s.syncCancel = context.WithCancel(context.Background()) - s.syncLoopDone = make(chan struct{}) - s.testFill() - go s.syncLoop() - return nil -} - -func (s *space) HeadSync(ctx context.Context, req *spacesync.HeadSyncRequest) (*spacesync.HeadSyncResponse, error) { - return remotediff.HandlerRangeRequest(ctx, s.diff, req) -} - -func (s *space) testFill() { - var n = 1000 - var els = make([]ldiff.Element, 0, n) - rand.Seed(time.Now().UnixNano()) - for i := 0; i < n; i++ { - if rand.Intn(n) > 2 { - id := fmt.Sprintf("%s.%d", s.id, i) - head := "head." + id - if rand.Intn(n) > n-100 { - head += ".modified" - } - el := ldiff.Element{ - Id: id, - Head: head, - } - els = append(els, el) - } - } - s.diff.Set(els...) -} - -func (s *space) syncLoop() { - defer close(s.syncLoopDone) - doSync := func() { - ctx, cancel := context.WithTimeout(s.syncCtx, time.Minute) - defer cancel() - if err := s.sync(ctx); err != nil { - log.Error("periodic sync error", zap.Error(err), zap.String("spaceId", s.id)) - } - } - doSync() - if s.s.conf.SyncPeriod > 0 { - ticker := time.NewTicker(time.Second * time.Duration(s.s.conf.SyncPeriod)) - defer ticker.Stop() - for { - select { - case <-s.syncCtx.Done(): - return - case <-ticker.C: - doSync() - } - } - } -} - -func (s *space) sync(ctx context.Context) error { - peers, err := s.getPeers(ctx) - if err != nil { - return err - } - for _, p := range peers { - if err := s.syncWithPeer(ctx, p); err != nil { - log.Error("can't sync with peer", zap.String("peer", p.Id()), zap.Error(err)) - } - } - return nil -} - -func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { - cl := spacesync.NewDRPCSpaceClient(p) - rdiff := remotediff.NewRemoteDiff(s.id, cl) - newIds, changedIds, removedIds, err := s.diff.Diff(ctx, rdiff) - if err != nil { - return nil - } - log.Info("sync done:", zap.Int("newIds", len(newIds)), zap.Int("changedIds", len(changedIds)), zap.Int("removedIds", len(removedIds))) - return -} - -func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { - if s.conf.IsResponsible(s.id) { - return s.conf.AllPeers(ctx, s.id) - } else { - var p peer.Peer - p, err = s.conf.OnePeer(ctx, s.id) - if err != nil { - return nil, err - } - return []peer.Peer{p}, nil - } -} - -func (s *space) Close() error { - s.syncCancel() - <-s.syncLoopDone - return nil -} diff --git a/service/space/spacesync/spacesync_drpc.pb.go b/service/space/spacesync/spacesync_drpc.pb.go deleted file mode 100644 index a083c7e3..00000000 --- a/service/space/spacesync/spacesync_drpc.pb.go +++ /dev/null @@ -1,113 +0,0 @@ -// Code generated by protoc-gen-go-drpc. DO NOT EDIT. -// protoc-gen-go-drpc version: v0.0.32 -// source: service/space/spacesync/protos/spacesync.proto - -package spacesync - -import ( - bytes "bytes" - context "context" - errors "errors" - jsonpb "github.com/gogo/protobuf/jsonpb" - proto "github.com/gogo/protobuf/proto" - drpc "storj.io/drpc" - drpcerr "storj.io/drpc/drpcerr" -) - -type drpcEncoding_File_service_space_spacesync_protos_spacesync_proto struct{} - -func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) Marshal(msg drpc.Message) ([]byte, error) { - return proto.Marshal(msg.(proto.Message)) -} - -func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) Unmarshal(buf []byte, msg drpc.Message) error { - return proto.Unmarshal(buf, msg.(proto.Message)) -} - -func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) JSONMarshal(msg drpc.Message) ([]byte, error) { - var buf bytes.Buffer - err := new(jsonpb.Marshaler).Marshal(&buf, msg.(proto.Message)) - if err != nil { - return nil, err - } - return buf.Bytes(), nil -} - -func (drpcEncoding_File_service_space_spacesync_protos_spacesync_proto) JSONUnmarshal(buf []byte, msg drpc.Message) error { - return jsonpb.Unmarshal(bytes.NewReader(buf), msg.(proto.Message)) -} - -type DRPCSpaceClient interface { - DRPCConn() drpc.Conn - - HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) -} - -type drpcSpaceClient struct { - cc drpc.Conn -} - -func NewDRPCSpaceClient(cc drpc.Conn) DRPCSpaceClient { - return &drpcSpaceClient{cc} -} - -func (c *drpcSpaceClient) DRPCConn() drpc.Conn { return c.cc } - -func (c *drpcSpaceClient) HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) { - out := new(HeadSyncResponse) - err := c.cc.Invoke(ctx, "/anySpace.Space/HeadSync", drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}, in, out) - if err != nil { - return nil, err - } - return out, nil -} - -type DRPCSpaceServer interface { - HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) -} - -type DRPCSpaceUnimplementedServer struct{} - -func (s *DRPCSpaceUnimplementedServer) HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) { - return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) -} - -type DRPCSpaceDescription struct{} - -func (DRPCSpaceDescription) NumMethods() int { return 1 } - -func (DRPCSpaceDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { - switch n { - case 0: - return "/anySpace.Space/HeadSync", drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}, - func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { - return srv.(DRPCSpaceServer). - HeadSync( - ctx, - in1.(*HeadSyncRequest), - ) - }, DRPCSpaceServer.HeadSync, true - default: - return "", nil, nil, nil, false - } -} - -func DRPCRegisterSpace(mux drpc.Mux, impl DRPCSpaceServer) error { - return mux.Register(impl, DRPCSpaceDescription{}) -} - -type DRPCSpace_HeadSyncStream interface { - drpc.Stream - SendAndClose(*HeadSyncResponse) error -} - -type drpcSpace_HeadSyncStream struct { - drpc.Stream -} - -func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { - if err := x.MsgSend(m, drpcEncoding_File_service_space_spacesync_protos_spacesync_proto{}); err != nil { - return err - } - return x.CloseSend() -} diff --git a/service/sync/document/service.go b/service/sync/document/service.go index 03799c09..b1856b5f 100644 --- a/service/sync/document/service.go +++ b/service/sync/document/service.go @@ -4,11 +4,11 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/testchangepb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/message" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" @@ -38,7 +38,7 @@ func New() app.Component { return &service{} } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { s.account = a.MustComponent(account.CName).(account.Service) s.messageService = a.MustComponent(message.CName).(message.Service) s.treeCache = a.MustComponent(treecache.CName).(treecache.Service) diff --git a/service/sync/message/service.go b/service/sync/message/service.go index 7207a302..b402a1c4 100644 --- a/service/sync/message/service.go +++ b/service/sync/message/service.go @@ -4,6 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + pool2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/requesthandler" @@ -20,7 +21,7 @@ const CName = "MessageService" type service struct { nodes []*node.Node requestHandler requesthandler.RequestHandler - pool pool.Pool + pool pool2.Pool sync.RWMutex } @@ -33,10 +34,10 @@ type Service interface { SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { s.requestHandler = a.MustComponent(requesthandler.CName).(requesthandler.RequestHandler) s.nodes = a.MustComponent(node.CName).(node.Service).Nodes() - s.pool = a.MustComponent(pool.CName).(pool.Pool) + s.pool = a.MustComponent(pool2.CName).(pool2.Pool) s.pool.AddHandler(syncproto.MessageType_MessageTypeSync, s.HandleMessage) return nil } diff --git a/service/sync/requesthandler/requesthandler.go b/service/sync/requesthandler/requesthandler.go index 2a960104..f7d992e0 100644 --- a/service/sync/requesthandler/requesthandler.go +++ b/service/sync/requesthandler/requesthandler.go @@ -4,11 +4,11 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" @@ -38,7 +38,7 @@ type MessageSender interface { const CName = "SyncRequestHandler" -func (r *requestHandler) Init(ctx context.Context, a *app.App) (err error) { +func (r *requestHandler) Init(a *app.App) (err error) { r.treeCache = a.MustComponent(treecache.CName).(treecache.Service) r.account = a.MustComponent(account.CName).(account.Service) r.messageService = a.MustComponent("MessageService").(MessageSender) diff --git a/service/treecache/service.go b/service/treecache/service.go index 687300f0..0a422049 100644 --- a/service/treecache/service.go +++ b/service/treecache/service.go @@ -4,12 +4,12 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treestorage/treepb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/account" "go.uber.org/zap" ) @@ -80,7 +80,7 @@ func (s *service) Add(ctx context.Context, treeId string, header *treepb.TreeHea return s.Do(ctx, treeId, f) } -func (s *service) Init(ctx context.Context, a *app.App) (err error) { +func (s *service) Init(a *app.App) (err error) { s.cache = ocache.New(s.loadTree) s.account = a.MustComponent(account.CName).(account.Service) s.treeProvider = treestorage.NewInMemoryTreeStorageProvider() From 9976a84d42280b653e27ee1a24d08f8353c90a17 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 12 Sep 2022 21:06:20 +0200 Subject: [PATCH 08/44] WIP proto refactoring --- Makefile | 2 +- .../spacesyncproto/protos/spacesync.proto | 44 +- .../spacesyncproto/spacesync.pb.go | 1625 ++++++- pkg/acl/account/accountdata.go | 2 +- pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 3857 ++++++++--------- .../aclchanges/aclpb/protos/aclchanges.proto | 249 +- pkg/acl/list/aclstate.go | 104 +- pkg/acl/list/aclstatebuilder.go | 4 +- pkg/acl/list/changebuilder.go | 20 +- pkg/acl/list/list.go | 28 +- pkg/acl/list/list_test.go | 8 +- pkg/acl/list/record.go | 33 +- pkg/acl/storage/inmemory.go | 32 +- pkg/acl/storage/liststorage.go | 6 +- pkg/acl/storage/provider.go | 8 +- pkg/acl/storage/treestorage.go | 4 +- .../acllistbuilder/liststoragebuilder.go | 40 +- .../liststoragebuildergraph_nix.go | 4 +- .../testutils/testchanges/proto/test.pb.go | 210 +- pkg/acl/tree/change.go | 10 +- pkg/acl/tree/changebuilder.go | 142 +- pkg/acl/tree/changevalidator.go | 2 +- pkg/acl/tree/objecttree.go | 101 +- pkg/acl/tree/objecttree_test.go | 21 +- pkg/acl/tree/objecttreefactory.go | 161 + pkg/acl/tree/rawloader.go | 16 +- pkg/acl/tree/signablecontent.go | 5 +- pkg/acl/tree/tests/benches_test.go | 91 + pkg/acl/tree/treebuilder.go | 2 +- pkg/acl/tree/treestorage.go | 91 - service/storage/service.go | 2 +- syncproto/proto/sync.proto | 41 - syncproto/sync.pb.go | 2300 +--------- 33 files changed, 4328 insertions(+), 4937 deletions(-) create mode 100644 pkg/acl/tree/objecttreefactory.go create mode 100644 pkg/acl/tree/tests/benches_test.go delete mode 100644 pkg/acl/tree/treestorage.go diff --git a/Makefile b/Makefile index f7c161d1..b004f35e 100644 --- a/Makefile +++ b/Makefile @@ -30,7 +30,7 @@ proto: $(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto $(eval PKGMAP := $$(P_ACL_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. service/space/spacesync/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. common/commonspace/spacesyncproto/protos/*.proto build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 0a1e434d..16fbdd14 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -1,16 +1,17 @@ syntax = "proto3"; package anySpace; + option go_package = "common/commonspace/spacesyncproto"; +import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto"; enum ErrCodes { Unexpected = 0; } - service Space { // HeadSync compares all objects and their hashes in a space rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse); - rpc Stream( stream Msg) returns (stream Msg); + rpc Stream(stream ObjectSyncMessage) returns (stream ObjectSyncMessage); } // TODO: temporary mock message @@ -18,8 +19,6 @@ message Msg { string spaceId = 1; } - - // HeadSyncRange presenting a request for one range message HeadSyncRange { uint64 from = 1; @@ -50,3 +49,40 @@ message HeadSyncRequest { message HeadSyncResponse { repeated HeadSyncResult results = 1; } + +// ObjectSyncMessage is a message sent on object sync +message ObjectSyncMessage { + string spaceId = 1; + ObjectSyncContentValue content = 2; + acl.TreeHeader treeHeader = 3; + string treeId = 4; +} + +// ObjectSyncContentValue provides different types for object sync +message ObjectSyncContentValue { + oneof value { + ObjectHeadUpdate headUpdate = 1; + ObjectFullSyncRequest fullSyncRequest = 2; + ObjectFullSyncResponse fullSyncResponse = 3; + } +} + +// ObjectHeadUpdate is a message sent on document head update +message ObjectHeadUpdate { + repeated string heads = 1; + repeated acl.RawTreeChangeWithId changes = 2; + repeated string snapshotPath = 3; +} + +// ObjectHeadUpdate is a message sent when document needs full sync +message ObjectFullSyncRequest { + repeated string heads = 1; + repeated string snapshotPath = 2; +} + +// ObjectFullSyncResponse is a message sent as a response for a specific full sync +message ObjectFullSyncResponse { + repeated string heads = 1; + repeated acl.RawTreeChangeWithId changes = 2; + repeated string snapshotPath = 3; +} diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 9db560cb..a3299fee 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -5,6 +5,7 @@ package spacesyncproto import ( fmt "fmt" + aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -362,6 +363,349 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { return nil } +// ObjectSyncMessage is a message sent on object sync +type ObjectSyncMessage struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` +} + +func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } +func (m *ObjectSyncMessage) String() string { return proto.CompactTextString(m) } +func (*ObjectSyncMessage) ProtoMessage() {} +func (*ObjectSyncMessage) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{6} +} +func (m *ObjectSyncMessage) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectSyncMessage) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectSyncMessage.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 *ObjectSyncMessage) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectSyncMessage.Merge(m, src) +} +func (m *ObjectSyncMessage) XXX_Size() int { + return m.Size() +} +func (m *ObjectSyncMessage) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectSyncMessage.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectSyncMessage proto.InternalMessageInfo + +func (m *ObjectSyncMessage) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *ObjectSyncMessage) GetContent() *ObjectSyncContentValue { + if m != nil { + return m.Content + } + return nil +} + +func (m *ObjectSyncMessage) GetTreeHeader() *aclpb.TreeHeader { + if m != nil { + return m.TreeHeader + } + return nil +} + +func (m *ObjectSyncMessage) GetTreeId() string { + if m != nil { + return m.TreeId + } + return "" +} + +// ObjectSyncContentValue provides different types for object sync +type ObjectSyncContentValue struct { + // Types that are valid to be assigned to Value: + // *ObjectSyncContentValue_HeadUpdate + // *ObjectSyncContentValue_FullSyncRequest + // *ObjectSyncContentValue_FullSyncResponse + Value isObjectSyncContentValue_Value `protobuf_oneof:"value"` +} + +func (m *ObjectSyncContentValue) Reset() { *m = ObjectSyncContentValue{} } +func (m *ObjectSyncContentValue) String() string { return proto.CompactTextString(m) } +func (*ObjectSyncContentValue) ProtoMessage() {} +func (*ObjectSyncContentValue) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{7} +} +func (m *ObjectSyncContentValue) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectSyncContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectSyncContentValue.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 *ObjectSyncContentValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectSyncContentValue.Merge(m, src) +} +func (m *ObjectSyncContentValue) XXX_Size() int { + return m.Size() +} +func (m *ObjectSyncContentValue) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectSyncContentValue.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectSyncContentValue proto.InternalMessageInfo + +type isObjectSyncContentValue_Value interface { + isObjectSyncContentValue_Value() + MarshalTo([]byte) (int, error) + Size() int +} + +type ObjectSyncContentValue_HeadUpdate struct { + HeadUpdate *ObjectHeadUpdate `protobuf:"bytes,1,opt,name=headUpdate,proto3,oneof" json:"headUpdate,omitempty"` +} +type ObjectSyncContentValue_FullSyncRequest struct { + FullSyncRequest *ObjectFullSyncRequest `protobuf:"bytes,2,opt,name=fullSyncRequest,proto3,oneof" json:"fullSyncRequest,omitempty"` +} +type ObjectSyncContentValue_FullSyncResponse struct { + FullSyncResponse *ObjectFullSyncResponse `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` +} + +func (*ObjectSyncContentValue_HeadUpdate) isObjectSyncContentValue_Value() {} +func (*ObjectSyncContentValue_FullSyncRequest) isObjectSyncContentValue_Value() {} +func (*ObjectSyncContentValue_FullSyncResponse) isObjectSyncContentValue_Value() {} + +func (m *ObjectSyncContentValue) GetValue() isObjectSyncContentValue_Value { + if m != nil { + return m.Value + } + return nil +} + +func (m *ObjectSyncContentValue) GetHeadUpdate() *ObjectHeadUpdate { + if x, ok := m.GetValue().(*ObjectSyncContentValue_HeadUpdate); ok { + return x.HeadUpdate + } + return nil +} + +func (m *ObjectSyncContentValue) GetFullSyncRequest() *ObjectFullSyncRequest { + if x, ok := m.GetValue().(*ObjectSyncContentValue_FullSyncRequest); ok { + return x.FullSyncRequest + } + return nil +} + +func (m *ObjectSyncContentValue) GetFullSyncResponse() *ObjectFullSyncResponse { + if x, ok := m.GetValue().(*ObjectSyncContentValue_FullSyncResponse); ok { + return x.FullSyncResponse + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*ObjectSyncContentValue) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*ObjectSyncContentValue_HeadUpdate)(nil), + (*ObjectSyncContentValue_FullSyncRequest)(nil), + (*ObjectSyncContentValue_FullSyncResponse)(nil), + } +} + +// ObjectHeadUpdate is a message sent on document head update +type ObjectHeadUpdate struct { + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` +} + +func (m *ObjectHeadUpdate) Reset() { *m = ObjectHeadUpdate{} } +func (m *ObjectHeadUpdate) String() string { return proto.CompactTextString(m) } +func (*ObjectHeadUpdate) ProtoMessage() {} +func (*ObjectHeadUpdate) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{8} +} +func (m *ObjectHeadUpdate) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectHeadUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectHeadUpdate.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 *ObjectHeadUpdate) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectHeadUpdate.Merge(m, src) +} +func (m *ObjectHeadUpdate) XXX_Size() int { + return m.Size() +} +func (m *ObjectHeadUpdate) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectHeadUpdate.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectHeadUpdate proto.InternalMessageInfo + +func (m *ObjectHeadUpdate) GetHeads() []string { + if m != nil { + return m.Heads + } + return nil +} + +func (m *ObjectHeadUpdate) GetChanges() []*aclpb.RawTreeChangeWithId { + if m != nil { + return m.Changes + } + return nil +} + +func (m *ObjectHeadUpdate) GetSnapshotPath() []string { + if m != nil { + return m.SnapshotPath + } + return nil +} + +// ObjectHeadUpdate is a message sent when document needs full sync +type ObjectFullSyncRequest struct { + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + SnapshotPath []string `protobuf:"bytes,2,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` +} + +func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} } +func (m *ObjectFullSyncRequest) String() string { return proto.CompactTextString(m) } +func (*ObjectFullSyncRequest) ProtoMessage() {} +func (*ObjectFullSyncRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{9} +} +func (m *ObjectFullSyncRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectFullSyncRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectFullSyncRequest.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 *ObjectFullSyncRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectFullSyncRequest.Merge(m, src) +} +func (m *ObjectFullSyncRequest) XXX_Size() int { + return m.Size() +} +func (m *ObjectFullSyncRequest) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectFullSyncRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectFullSyncRequest proto.InternalMessageInfo + +func (m *ObjectFullSyncRequest) GetHeads() []string { + if m != nil { + return m.Heads + } + return nil +} + +func (m *ObjectFullSyncRequest) GetSnapshotPath() []string { + if m != nil { + return m.SnapshotPath + } + return nil +} + +// ObjectFullSyncResponse is a message sent as a response for a specific full sync +type ObjectFullSyncResponse struct { + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` +} + +func (m *ObjectFullSyncResponse) Reset() { *m = ObjectFullSyncResponse{} } +func (m *ObjectFullSyncResponse) String() string { return proto.CompactTextString(m) } +func (*ObjectFullSyncResponse) ProtoMessage() {} +func (*ObjectFullSyncResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{10} +} +func (m *ObjectFullSyncResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectFullSyncResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectFullSyncResponse.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 *ObjectFullSyncResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectFullSyncResponse.Merge(m, src) +} +func (m *ObjectFullSyncResponse) XXX_Size() int { + return m.Size() +} +func (m *ObjectFullSyncResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectFullSyncResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectFullSyncResponse proto.InternalMessageInfo + +func (m *ObjectFullSyncResponse) GetHeads() []string { + if m != nil { + return m.Heads + } + return nil +} + +func (m *ObjectFullSyncResponse) GetChanges() []*aclpb.RawTreeChangeWithId { + if m != nil { + return m.Changes + } + return nil +} + +func (m *ObjectFullSyncResponse) GetSnapshotPath() []string { + if m != nil { + return m.SnapshotPath + } + return nil +} + func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterType((*Msg)(nil), "anySpace.Msg") @@ -370,6 +714,11 @@ func init() { proto.RegisterType((*HeadSyncResultElement)(nil), "anySpace.HeadSyncResultElement") proto.RegisterType((*HeadSyncRequest)(nil), "anySpace.HeadSyncRequest") proto.RegisterType((*HeadSyncResponse)(nil), "anySpace.HeadSyncResponse") + proto.RegisterType((*ObjectSyncMessage)(nil), "anySpace.ObjectSyncMessage") + proto.RegisterType((*ObjectSyncContentValue)(nil), "anySpace.ObjectSyncContentValue") + proto.RegisterType((*ObjectHeadUpdate)(nil), "anySpace.ObjectHeadUpdate") + proto.RegisterType((*ObjectFullSyncRequest)(nil), "anySpace.ObjectFullSyncRequest") + proto.RegisterType((*ObjectFullSyncResponse)(nil), "anySpace.ObjectFullSyncResponse") } func init() { @@ -377,32 +726,50 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 400 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x84, 0x52, 0xcd, 0xce, 0xd2, 0x40, - 0x14, 0xed, 0x94, 0xbf, 0x72, 0x15, 0x24, 0x13, 0x8d, 0xb5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0x00, 0xff, 0xff, 0x5a, 0xf6, 0x94, 0x21, 0xe5, 0x02, 0x00, 0x00, + // 674 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0xd3, 0x40, + 0x10, 0xf5, 0x26, 0x6d, 0x92, 0x4e, 0xfa, 0x11, 0x56, 0xb4, 0x98, 0x20, 0xa5, 0xc1, 0xa7, 0x88, + 0x43, 0x52, 0x85, 0x0b, 0xa2, 0x5c, 0x68, 0xd5, 0x2a, 0x11, 0x2a, 0x1f, 0x5b, 0x0a, 0x12, 0xe2, + 0xb2, 0xb5, 0xb7, 0x49, 0xc0, 0xf1, 0x1a, 0xef, 0x86, 0xd2, 0x1b, 0x27, 0xce, 0x88, 0x9f, 0xc2, + 0xaf, 0xe0, 0xd8, 0x23, 0x47, 0xd4, 0xfe, 0x0d, 0x0e, 0x68, 0xc7, 0x76, 0x92, 0x06, 0xa7, 0xdc, + 0x38, 0xc4, 0xde, 0x99, 0x7d, 0xf3, 0xf6, 0xbd, 0x59, 0x8f, 0x02, 0x0f, 0x5c, 0x39, 0x1c, 0xca, + 0xa0, 0x15, 0xbf, 0x54, 0xc8, 0x5d, 0xd1, 0xc2, 0xa7, 0x3a, 0x0b, 0xdc, 0x30, 0x92, 0x5a, 0xb6, + 0xf0, 0xa9, 0x26, 0xd9, 0x26, 0x26, 0x68, 0x89, 0x07, 0x67, 0x87, 0x26, 0x57, 0xdd, 0x0a, 0xdf, + 0xf7, 0x5a, 0xdc, 0xf5, 0xcd, 0xcf, 0xed, 0xf3, 0xa0, 0x27, 0x94, 0x59, 0x86, 0xc7, 0x69, 0xe9, + 0x24, 0x1f, 0xd7, 0x3a, 0x9b, 0x90, 0x3f, 0x50, 0x3d, 0x6a, 0x43, 0x11, 0x59, 0xbb, 0x9e, 0x4d, + 0xea, 0xa4, 0xb1, 0xc4, 0xd2, 0xd0, 0xe9, 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0xb7, 0xf3, 0x48, 0x78, 0x25, 0xe7, 0xbc, 0x80, 0xf5, 0xcc, + 0x3e, 0xcc, 0x91, 0x31, 0x4b, 0x99, 0xcb, 0xa0, 0xfc, 0x32, 0xbe, 0xd4, 0xd9, 0x6e, 0xfc, 0x5f, + 0x6f, 0xf7, 0xaa, 0x50, 0xda, 0x8b, 0xa2, 0x5d, 0xe9, 0x09, 0x45, 0x57, 0x01, 0x8e, 0x02, 0xf1, + 0x29, 0x14, 0xae, 0x16, 0x5e, 0xc5, 0x6a, 0x7f, 0x23, 0xb0, 0x88, 0x17, 0x47, 0x1f, 0x43, 0x29, + 0x9d, 0x29, 0x7a, 0x3b, 0x6b, 0xce, 0xb0, 0x1f, 0xd5, 0x6a, 0xe6, 0x08, 0xc6, 0xb6, 0xf6, 0xa1, + 0x70, 0xa8, 0x23, 0xc1, 0x87, 0xf4, 0x4e, 0xd6, 0x10, 0x25, 0xc3, 0x58, 0xbd, 0x6e, 0xb3, 0x41, + 0xb6, 0xc8, 0xce, 0xf6, 0x8f, 0x8b, 0x1a, 0x39, 0xbf, 0xa8, 0x91, 0x5f, 0x17, 0x35, 0xf2, 0xf5, + 0xb2, 0x66, 0x9d, 0x5f, 0xd6, 0xac, 0x9f, 0x97, 0x35, 0xeb, 0xcd, 0xdd, 0x7f, 0xfe, 0x37, 0x1c, + 0x17, 0xf0, 0x75, 0xff, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x51, 0x60, 0x63, 0x47, 0x06, + 0x00, 0x00, } func (m *Msg) Marshal() (dAtA []byte, err error) { @@ -640,6 +1007,313 @@ func (m *HeadSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *ObjectSyncMessage) 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 *ObjectSyncMessage) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.TreeId) > 0 { + i -= len(m.TreeId) + copy(dAtA[i:], m.TreeId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.TreeId))) + i-- + dAtA[i] = 0x22 + } + if m.TreeHeader != nil { + { + size, err := m.TreeHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.Content != nil { + { + size, err := m.Content.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + 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 +} + +func (m *ObjectSyncContentValue) 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 *ObjectSyncContentValue) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != nil { + { + size := m.Value.Size() + i -= size + if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *ObjectSyncContentValue_HeadUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncContentValue_HeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.HeadUpdate != nil { + { + size, err := m.HeadUpdate.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 *ObjectSyncContentValue_FullSyncRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncContentValue_FullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.FullSyncRequest != nil { + { + size, err := m.FullSyncRequest.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + return len(dAtA) - i, nil +} +func (m *ObjectSyncContentValue_FullSyncResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncContentValue_FullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.FullSyncResponse != nil { + { + size, err := m.FullSyncResponse.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + return len(dAtA) - i, nil +} +func (m *ObjectHeadUpdate) 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 *ObjectHeadUpdate) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SnapshotPath) > 0 { + for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SnapshotPath[iNdEx]) + copy(dAtA[i:], m.SnapshotPath[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Changes) > 0 { + for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Heads) > 0 { + for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Heads[iNdEx]) + copy(dAtA[i:], m.Heads[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Heads[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ObjectFullSyncRequest) 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 *ObjectFullSyncRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectFullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SnapshotPath) > 0 { + for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SnapshotPath[iNdEx]) + copy(dAtA[i:], m.SnapshotPath[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) + i-- + dAtA[i] = 0x12 + } + } + if len(m.Heads) > 0 { + for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Heads[iNdEx]) + copy(dAtA[i:], m.Heads[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Heads[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *ObjectFullSyncResponse) 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 *ObjectFullSyncResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectFullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.SnapshotPath) > 0 { + for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.SnapshotPath[iNdEx]) + copy(dAtA[i:], m.SnapshotPath[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) + i-- + dAtA[i] = 0x1a + } + } + if len(m.Changes) > 0 { + for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + } + if len(m.Heads) > 0 { + for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.Heads[iNdEx]) + copy(dAtA[i:], m.Heads[iNdEx]) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Heads[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -755,6 +1429,154 @@ func (m *HeadSyncResponse) Size() (n int) { return n } +func (m *ObjectSyncMessage) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.Content != nil { + l = m.Content.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.TreeHeader != nil { + l = m.TreeHeader.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.TreeId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + +func (m *ObjectSyncContentValue) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *ObjectSyncContentValue_HeadUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.HeadUpdate != nil { + l = m.HeadUpdate.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} +func (m *ObjectSyncContentValue_FullSyncRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FullSyncRequest != nil { + l = m.FullSyncRequest.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} +func (m *ObjectSyncContentValue_FullSyncResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.FullSyncResponse != nil { + l = m.FullSyncResponse.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} +func (m *ObjectHeadUpdate) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Heads) > 0 { + for _, s := range m.Heads { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + if len(m.Changes) > 0 { + for _, e := range m.Changes { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + if len(m.SnapshotPath) > 0 { + for _, s := range m.SnapshotPath { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + +func (m *ObjectFullSyncRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Heads) > 0 { + for _, s := range m.Heads { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + if len(m.SnapshotPath) > 0 { + for _, s := range m.SnapshotPath { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + +func (m *ObjectFullSyncResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Heads) > 0 { + for _, s := range m.Heads { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + if len(m.Changes) > 0 { + for _, e := range m.Changes { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } + if len(m.SnapshotPath) > 0 { + for _, s := range m.SnapshotPath { + l = len(s) + n += 1 + l + sovSpacesync(uint64(l)) + } + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -1401,6 +2223,757 @@ func (m *HeadSyncResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *ObjectSyncMessage) 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: ObjectSyncMessage: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectSyncMessage: illegal tag %d (wire type %d)", fieldNum, wire) + } + 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: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", 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.Content == nil { + m.Content = &ObjectSyncContentValue{} + } + if err := m.Content.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeHeader", 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.TreeHeader == nil { + m.TreeHeader = &aclpb.TreeHeader{} + } + if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeId", 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.TreeId = 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 (m *ObjectSyncContentValue) 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: ObjectSyncContentValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectSyncContentValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field HeadUpdate", 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 + } + v := &ObjectHeadUpdate{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ObjectSyncContentValue_HeadUpdate{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FullSyncRequest", 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 + } + v := &ObjectFullSyncRequest{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ObjectSyncContentValue_FullSyncRequest{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FullSyncResponse", 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 + } + v := &ObjectFullSyncResponse{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ObjectSyncContentValue_FullSyncResponse{v} + 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 *ObjectHeadUpdate) 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: ObjectHeadUpdate: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectHeadUpdate: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Heads", 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.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Changes", 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 + } + m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", 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.SnapshotPath = append(m.SnapshotPath, 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 (m *ObjectFullSyncRequest) 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: ObjectFullSyncRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectFullSyncRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Heads", 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.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", 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.SnapshotPath = append(m.SnapshotPath, 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 (m *ObjectFullSyncResponse) 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: ObjectFullSyncResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectFullSyncResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Heads", 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.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Changes", 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 + } + m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", 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.SnapshotPath = append(m.SnapshotPath, 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) { l := len(dAtA) iNdEx := 0 diff --git a/pkg/acl/account/accountdata.go b/pkg/acl/account/accountdata.go index 07530083..bc775854 100644 --- a/pkg/acl/account/accountdata.go +++ b/pkg/acl/account/accountdata.go @@ -7,7 +7,7 @@ import ( ) type AccountData struct { // TODO: create a convenient constructor for this - Identity string // TODO: this is essentially the same as sign key + Identity []byte // TODO: this is essentially the same as sign key SignKey signingkey.PrivKey EncKey encryptionkey.PrivKey Decoder keys.Decoder diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index c026319c..ecd124b1 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -22,140 +22,80 @@ var _ = math.Inf // proto package needs to be updated. const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package -type ACLChangeUserPermissions int32 +type ACLUserPermissions int32 const ( - ACLChange_Admin ACLChangeUserPermissions = 0 - ACLChange_Writer ACLChangeUserPermissions = 1 - ACLChange_Reader ACLChangeUserPermissions = 2 - ACLChange_Removed ACLChangeUserPermissions = 3 + ACLUserPermissions_Admin ACLUserPermissions = 0 + ACLUserPermissions_Writer ACLUserPermissions = 1 + ACLUserPermissions_Reader ACLUserPermissions = 2 + ACLUserPermissions_Removed ACLUserPermissions = 3 ) -var ACLChangeUserPermissions_name = map[int32]string{ +var ACLUserPermissions_name = map[int32]string{ 0: "Admin", 1: "Writer", 2: "Reader", 3: "Removed", } -var ACLChangeUserPermissions_value = map[string]int32{ +var ACLUserPermissions_value = map[string]int32{ "Admin": 0, "Writer": 1, "Reader": 2, "Removed": 3, } -func (x ACLChangeUserPermissions) String() string { - return proto.EnumName(ACLChangeUserPermissions_name, int32(x)) +func (x ACLUserPermissions) String() string { + return proto.EnumName(ACLUserPermissions_name, int32(x)) } -func (ACLChangeUserPermissions) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 0} -} - -type HeaderDocType int32 - -const ( - Header_ACL HeaderDocType = 0 - Header_DocTree HeaderDocType = 1 -) - -var HeaderDocType_name = map[int32]string{ - 0: "ACL", - 1: "DocTree", -} - -var HeaderDocType_value = map[string]int32{ - "ACL": 0, - "DocTree": 1, -} - -func (x HeaderDocType) String() string { - return proto.EnumName(HeaderDocType_name, int32(x)) -} - -func (HeaderDocType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{5, 0} -} - -type RawChange struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *RawChange) Reset() { *m = RawChange{} } -func (m *RawChange) String() string { return proto.CompactTextString(m) } -func (*RawChange) ProtoMessage() {} -func (*RawChange) Descriptor() ([]byte, []int) { +func (ACLUserPermissions) EnumDescriptor() ([]byte, []int) { return fileDescriptor_37a022c841a51877, []int{0} } -func (m *RawChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RawChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RawChange.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 *RawChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawChange.Merge(m, src) -} -func (m *RawChange) XXX_Size() int { - return m.Size() -} -func (m *RawChange) XXX_DiscardUnknown() { - xxx_messageInfo_RawChange.DiscardUnknown(m) + +type TreeHeaderType int32 + +const ( + TreeHeaderType_Object TreeHeaderType = 0 + TreeHeaderType_Space TreeHeaderType = 1 +) + +var TreeHeaderType_name = map[int32]string{ + 0: "Object", + 1: "Space", } -var xxx_messageInfo_RawChange proto.InternalMessageInfo - -func (m *RawChange) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil +var TreeHeaderType_value = map[string]int32{ + "Object": 0, + "Space": 1, } -func (m *RawChange) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil +func (x TreeHeaderType) String() string { + return proto.EnumName(TreeHeaderType_name, int32(x)) } -func (m *RawChange) GetId() string { - if m != nil { - return m.Id - } - return "" +func (TreeHeaderType) EnumDescriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{1} } -type RawRecord struct { +type RawACLRecord struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` } -func (m *RawRecord) Reset() { *m = RawRecord{} } -func (m *RawRecord) String() string { return proto.CompactTextString(m) } -func (*RawRecord) ProtoMessage() {} -func (*RawRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{1} +func (m *RawACLRecord) Reset() { *m = RawACLRecord{} } +func (m *RawACLRecord) String() string { return proto.CompactTextString(m) } +func (*RawACLRecord) ProtoMessage() {} +func (*RawACLRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{0} } -func (m *RawRecord) XXX_Unmarshal(b []byte) error { +func (m *RawACLRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *RawRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *RawACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_RawRecord.Marshal(b, m, deterministic) + return xxx_messageInfo_RawACLRecord.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -165,164 +105,62 @@ func (m *RawRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *RawRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawRecord.Merge(m, src) +func (m *RawACLRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawACLRecord.Merge(m, src) } -func (m *RawRecord) XXX_Size() int { +func (m *RawACLRecord) XXX_Size() int { return m.Size() } -func (m *RawRecord) XXX_DiscardUnknown() { - xxx_messageInfo_RawRecord.DiscardUnknown(m) +func (m *RawACLRecord) XXX_DiscardUnknown() { + xxx_messageInfo_RawACLRecord.DiscardUnknown(m) } -var xxx_messageInfo_RawRecord proto.InternalMessageInfo +var xxx_messageInfo_RawACLRecord proto.InternalMessageInfo -func (m *RawRecord) GetPayload() []byte { +func (m *RawACLRecord) GetPayload() []byte { if m != nil { return m.Payload } return nil } -func (m *RawRecord) GetSignature() []byte { +func (m *RawACLRecord) GetSignature() []byte { if m != nil { return m.Signature } return nil } -func (m *RawRecord) GetId() string { +func (m *RawACLRecord) GetId() string { if m != nil { return m.Id } return "" } -// the element of change tree used to store and internal apply smartBlock history -type ACLChange struct { - TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` - AclHeadIds []string `protobuf:"bytes,2,rep,name=aclHeadIds,proto3" json:"aclHeadIds,omitempty"` - SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` - AclData *ACLChangeACLData `protobuf:"bytes,4,opt,name=aclData,proto3" json:"aclData,omitempty"` - // the data is encoded with read key and should be read in ChangesData format - ChangesData []byte `protobuf:"bytes,5,opt,name=changesData,proto3" json:"changesData,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,6,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity string `protobuf:"bytes,8,opt,name=identity,proto3" json:"identity,omitempty"` -} - -func (m *ACLChange) Reset() { *m = ACLChange{} } -func (m *ACLChange) String() string { return proto.CompactTextString(m) } -func (*ACLChange) ProtoMessage() {} -func (*ACLChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2} -} -func (m *ACLChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLChange.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 *ACLChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChange.Merge(m, src) -} -func (m *ACLChange) XXX_Size() int { - return m.Size() -} -func (m *ACLChange) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChange.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLChange proto.InternalMessageInfo - -func (m *ACLChange) GetTreeHeadIds() []string { - if m != nil { - return m.TreeHeadIds - } - return nil -} - -func (m *ACLChange) GetAclHeadIds() []string { - if m != nil { - return m.AclHeadIds - } - return nil -} - -func (m *ACLChange) GetSnapshotBaseId() string { - if m != nil { - return m.SnapshotBaseId - } - return "" -} - -func (m *ACLChange) GetAclData() *ACLChangeACLData { - if m != nil { - return m.AclData - } - return nil -} - -func (m *ACLChange) GetChangesData() []byte { - if m != nil { - return m.ChangesData - } - return nil -} - -func (m *ACLChange) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *ACLChange) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *ACLChange) GetIdentity() string { - if m != nil { - return m.Identity - } - return "" -} - -type ACLChangeACLContentValue struct { +type ACLContentValue struct { // Types that are valid to be assigned to Value: - // *ACLChangeACLContentValueValueOfUserAdd - // *ACLChangeACLContentValueValueOfUserRemove - // *ACLChangeACLContentValueValueOfUserPermissionChange - // *ACLChangeACLContentValueValueOfUserInvite - // *ACLChangeACLContentValueValueOfUserJoin - // *ACLChangeACLContentValueValueOfUserConfirm - Value IsACLChangeACLContentValueValue `protobuf_oneof:"value"` + // *ACLContentValue_UserAdd + // *ACLContentValue_UserRemove + // *ACLContentValue_UserPermissionChange + // *ACLContentValue_UserInvite + // *ACLContentValue_UserJoin + // *ACLContentValue_UserConfirm + Value isACLContentValue_Value `protobuf_oneof:"value"` } -func (m *ACLChangeACLContentValue) Reset() { *m = ACLChangeACLContentValue{} } -func (m *ACLChangeACLContentValue) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLContentValue) ProtoMessage() {} -func (*ACLChangeACLContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 0} +func (m *ACLContentValue) Reset() { *m = ACLContentValue{} } +func (m *ACLContentValue) String() string { return proto.CompactTextString(m) } +func (*ACLContentValue) ProtoMessage() {} +func (*ACLContentValue) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{1} } -func (m *ACLChangeACLContentValue) XXX_Unmarshal(b []byte) error { +func (m *ACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLContentValue.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLContentValue.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -332,128 +170,127 @@ func (m *ACLChangeACLContentValue) XXX_Marshal(b []byte, deterministic bool) ([] return b[:n], nil } } -func (m *ACLChangeACLContentValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLContentValue.Merge(m, src) +func (m *ACLContentValue) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLContentValue.Merge(m, src) } -func (m *ACLChangeACLContentValue) XXX_Size() int { +func (m *ACLContentValue) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLContentValue) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLContentValue.DiscardUnknown(m) +func (m *ACLContentValue) XXX_DiscardUnknown() { + xxx_messageInfo_ACLContentValue.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLContentValue proto.InternalMessageInfo +var xxx_messageInfo_ACLContentValue proto.InternalMessageInfo -type IsACLChangeACLContentValueValue interface { - IsACLChangeACLContentValueValue() +type isACLContentValue_Value interface { + isACLContentValue_Value() MarshalTo([]byte) (int, error) Size() int } -type ACLChangeACLContentValueValueOfUserAdd struct { - UserAdd *ACLChangeUserAdd `protobuf:"bytes,1,opt,name=userAdd,proto3,oneof" json:"userAdd,omitempty"` +type ACLContentValue_UserAdd struct { + UserAdd *ACLUserAdd `protobuf:"bytes,1,opt,name=userAdd,proto3,oneof" json:"userAdd,omitempty"` } -type ACLChangeACLContentValueValueOfUserRemove struct { - UserRemove *ACLChangeUserRemove `protobuf:"bytes,2,opt,name=userRemove,proto3,oneof" json:"userRemove,omitempty"` +type ACLContentValue_UserRemove struct { + UserRemove *ACLUserRemove `protobuf:"bytes,2,opt,name=userRemove,proto3,oneof" json:"userRemove,omitempty"` } -type ACLChangeACLContentValueValueOfUserPermissionChange struct { - UserPermissionChange *ACLChangeUserPermissionChange `protobuf:"bytes,3,opt,name=userPermissionChange,proto3,oneof" json:"userPermissionChange,omitempty"` +type ACLContentValue_UserPermissionChange struct { + UserPermissionChange *ACLUserPermissionChange `protobuf:"bytes,3,opt,name=userPermissionChange,proto3,oneof" json:"userPermissionChange,omitempty"` } -type ACLChangeACLContentValueValueOfUserInvite struct { - UserInvite *ACLChangeUserInvite `protobuf:"bytes,4,opt,name=userInvite,proto3,oneof" json:"userInvite,omitempty"` +type ACLContentValue_UserInvite struct { + UserInvite *ACLUserInvite `protobuf:"bytes,4,opt,name=userInvite,proto3,oneof" json:"userInvite,omitempty"` } -type ACLChangeACLContentValueValueOfUserJoin struct { - UserJoin *ACLChangeUserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` +type ACLContentValue_UserJoin struct { + UserJoin *ACLUserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` } -type ACLChangeACLContentValueValueOfUserConfirm struct { - UserConfirm *ACLChangeUserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` +type ACLContentValue_UserConfirm struct { + UserConfirm *ACLUserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` } -func (*ACLChangeACLContentValueValueOfUserAdd) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserRemove) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserPermissionChange) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserInvite) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserJoin) IsACLChangeACLContentValueValue() {} -func (*ACLChangeACLContentValueValueOfUserConfirm) IsACLChangeACLContentValueValue() {} +func (*ACLContentValue_UserAdd) isACLContentValue_Value() {} +func (*ACLContentValue_UserRemove) isACLContentValue_Value() {} +func (*ACLContentValue_UserPermissionChange) isACLContentValue_Value() {} +func (*ACLContentValue_UserInvite) isACLContentValue_Value() {} +func (*ACLContentValue_UserJoin) isACLContentValue_Value() {} +func (*ACLContentValue_UserConfirm) isACLContentValue_Value() {} -func (m *ACLChangeACLContentValue) GetValue() IsACLChangeACLContentValueValue { +func (m *ACLContentValue) GetValue() isACLContentValue_Value { if m != nil { return m.Value } return nil } -func (m *ACLChangeACLContentValue) GetUserAdd() *ACLChangeUserAdd { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserAdd); ok { +func (m *ACLContentValue) GetUserAdd() *ACLUserAdd { + if x, ok := m.GetValue().(*ACLContentValue_UserAdd); ok { return x.UserAdd } return nil } -func (m *ACLChangeACLContentValue) GetUserRemove() *ACLChangeUserRemove { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserRemove); ok { +func (m *ACLContentValue) GetUserRemove() *ACLUserRemove { + if x, ok := m.GetValue().(*ACLContentValue_UserRemove); ok { return x.UserRemove } return nil } -func (m *ACLChangeACLContentValue) GetUserPermissionChange() *ACLChangeUserPermissionChange { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserPermissionChange); ok { +func (m *ACLContentValue) GetUserPermissionChange() *ACLUserPermissionChange { + if x, ok := m.GetValue().(*ACLContentValue_UserPermissionChange); ok { return x.UserPermissionChange } return nil } -func (m *ACLChangeACLContentValue) GetUserInvite() *ACLChangeUserInvite { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserInvite); ok { +func (m *ACLContentValue) GetUserInvite() *ACLUserInvite { + if x, ok := m.GetValue().(*ACLContentValue_UserInvite); ok { return x.UserInvite } return nil } -func (m *ACLChangeACLContentValue) GetUserJoin() *ACLChangeUserJoin { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserJoin); ok { +func (m *ACLContentValue) GetUserJoin() *ACLUserJoin { + if x, ok := m.GetValue().(*ACLContentValue_UserJoin); ok { return x.UserJoin } return nil } -func (m *ACLChangeACLContentValue) GetUserConfirm() *ACLChangeUserConfirm { - if x, ok := m.GetValue().(*ACLChangeACLContentValueValueOfUserConfirm); ok { +func (m *ACLContentValue) GetUserConfirm() *ACLUserConfirm { + if x, ok := m.GetValue().(*ACLContentValue_UserConfirm); ok { return x.UserConfirm } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*ACLChangeACLContentValue) XXX_OneofWrappers() []interface{} { +func (*ACLContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*ACLChangeACLContentValueValueOfUserAdd)(nil), - (*ACLChangeACLContentValueValueOfUserRemove)(nil), - (*ACLChangeACLContentValueValueOfUserPermissionChange)(nil), - (*ACLChangeACLContentValueValueOfUserInvite)(nil), - (*ACLChangeACLContentValueValueOfUserJoin)(nil), - (*ACLChangeACLContentValueValueOfUserConfirm)(nil), + (*ACLContentValue_UserAdd)(nil), + (*ACLContentValue_UserRemove)(nil), + (*ACLContentValue_UserPermissionChange)(nil), + (*ACLContentValue_UserInvite)(nil), + (*ACLContentValue_UserJoin)(nil), + (*ACLContentValue_UserConfirm)(nil), } } -type ACLChangeACLData struct { - AclSnapshot *ACLChangeACLSnapshot `protobuf:"bytes,1,opt,name=aclSnapshot,proto3" json:"aclSnapshot,omitempty"` - AclContent []*ACLChangeACLContentValue `protobuf:"bytes,2,rep,name=aclContent,proto3" json:"aclContent,omitempty"` +type ACLData struct { + AclContent []*ACLContentValue `protobuf:"bytes,1,rep,name=aclContent,proto3" json:"aclContent,omitempty"` } -func (m *ACLChangeACLData) Reset() { *m = ACLChangeACLData{} } -func (m *ACLChangeACLData) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLData) ProtoMessage() {} -func (*ACLChangeACLData) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 1} +func (m *ACLData) Reset() { *m = ACLData{} } +func (m *ACLData) String() string { return proto.CompactTextString(m) } +func (*ACLData) ProtoMessage() {} +func (*ACLData) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{2} } -func (m *ACLChangeACLData) XXX_Unmarshal(b []byte) error { +func (m *ACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLData.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLData.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -463,49 +300,43 @@ func (m *ACLChangeACLData) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *ACLChangeACLData) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLData.Merge(m, src) +func (m *ACLData) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLData.Merge(m, src) } -func (m *ACLChangeACLData) XXX_Size() int { +func (m *ACLData) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLData) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLData.DiscardUnknown(m) +func (m *ACLData) XXX_DiscardUnknown() { + xxx_messageInfo_ACLData.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLData proto.InternalMessageInfo +var xxx_messageInfo_ACLData proto.InternalMessageInfo -func (m *ACLChangeACLData) GetAclSnapshot() *ACLChangeACLSnapshot { - if m != nil { - return m.AclSnapshot - } - return nil -} - -func (m *ACLChangeACLData) GetAclContent() []*ACLChangeACLContentValue { +func (m *ACLData) GetAclContent() []*ACLContentValue { if m != nil { return m.AclContent } return nil } -type ACLChangeACLSnapshot struct { - // We don't need ACLState as a separate message now, because we simplified the snapshot model - AclState *ACLChangeACLState `protobuf:"bytes,1,opt,name=aclState,proto3" json:"aclState,omitempty"` +type ACLState struct { + ReadKeyHashes []uint64 `protobuf:"varint,1,rep,packed,name=readKeyHashes,proto3" json:"readKeyHashes,omitempty"` + UserStates []*ACLUserState `protobuf:"bytes,2,rep,name=userStates,proto3" json:"userStates,omitempty"` + Invites map[string]*ACLUserInvite `protobuf:"bytes,3,rep,name=invites,proto3" json:"invites,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` } -func (m *ACLChangeACLSnapshot) Reset() { *m = ACLChangeACLSnapshot{} } -func (m *ACLChangeACLSnapshot) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLSnapshot) ProtoMessage() {} -func (*ACLChangeACLSnapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 2} +func (m *ACLState) Reset() { *m = ACLState{} } +func (m *ACLState) String() string { return proto.CompactTextString(m) } +func (*ACLState) ProtoMessage() {} +func (*ACLState) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{3} } -func (m *ACLChangeACLSnapshot) XXX_Unmarshal(b []byte) error { +func (m *ACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeACLSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeACLSnapshot.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -515,105 +346,59 @@ func (m *ACLChangeACLSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *ACLChangeACLSnapshot) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLSnapshot.Merge(m, src) +func (m *ACLState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLState.Merge(m, src) } -func (m *ACLChangeACLSnapshot) XXX_Size() int { +func (m *ACLState) XXX_Size() int { return m.Size() } -func (m *ACLChangeACLSnapshot) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLSnapshot.DiscardUnknown(m) +func (m *ACLState) XXX_DiscardUnknown() { + xxx_messageInfo_ACLState.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeACLSnapshot proto.InternalMessageInfo +var xxx_messageInfo_ACLState proto.InternalMessageInfo -func (m *ACLChangeACLSnapshot) GetAclState() *ACLChangeACLState { - if m != nil { - return m.AclState - } - return nil -} - -type ACLChangeACLState struct { - ReadKeyHashes []uint64 `protobuf:"varint,1,rep,packed,name=readKeyHashes,proto3" json:"readKeyHashes,omitempty"` - UserStates []*ACLChangeUserState `protobuf:"bytes,2,rep,name=userStates,proto3" json:"userStates,omitempty"` - Invites map[string]*ACLChangeUserInvite `protobuf:"bytes,3,rep,name=invites,proto3" json:"invites,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` -} - -func (m *ACLChangeACLState) Reset() { *m = ACLChangeACLState{} } -func (m *ACLChangeACLState) String() string { return proto.CompactTextString(m) } -func (*ACLChangeACLState) ProtoMessage() {} -func (*ACLChangeACLState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 3} -} -func (m *ACLChangeACLState) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLChangeACLState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLChangeACLState.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 *ACLChangeACLState) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeACLState.Merge(m, src) -} -func (m *ACLChangeACLState) XXX_Size() int { - return m.Size() -} -func (m *ACLChangeACLState) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeACLState.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLChangeACLState proto.InternalMessageInfo - -func (m *ACLChangeACLState) GetReadKeyHashes() []uint64 { +func (m *ACLState) GetReadKeyHashes() []uint64 { if m != nil { return m.ReadKeyHashes } return nil } -func (m *ACLChangeACLState) GetUserStates() []*ACLChangeUserState { +func (m *ACLState) GetUserStates() []*ACLUserState { if m != nil { return m.UserStates } return nil } -func (m *ACLChangeACLState) GetInvites() map[string]*ACLChangeUserInvite { +func (m *ACLState) GetInvites() map[string]*ACLUserInvite { if m != nil { return m.Invites } return nil } -type ACLChangeUserState struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` - IsConfirmed bool `protobuf:"varint,5,opt,name=IsConfirmed,proto3" json:"IsConfirmed,omitempty"` +type ACLUserState struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + IsConfirmed bool `protobuf:"varint,5,opt,name=isConfirmed,proto3" json:"isConfirmed,omitempty"` } -func (m *ACLChangeUserState) Reset() { *m = ACLChangeUserState{} } -func (m *ACLChangeUserState) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserState) ProtoMessage() {} -func (*ACLChangeUserState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 4} +func (m *ACLUserState) Reset() { *m = ACLUserState{} } +func (m *ACLUserState) String() string { return proto.CompactTextString(m) } +func (*ACLUserState) ProtoMessage() {} +func (*ACLUserState) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{4} } -func (m *ACLChangeUserState) XXX_Unmarshal(b []byte) error { +func (m *ACLUserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserState.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserState.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -623,47 +408,47 @@ func (m *ACLChangeUserState) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserState) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserState.Merge(m, src) +func (m *ACLUserState) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserState.Merge(m, src) } -func (m *ACLChangeUserState) XXX_Size() int { +func (m *ACLUserState) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserState) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserState.DiscardUnknown(m) +func (m *ACLUserState) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserState.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserState proto.InternalMessageInfo +var xxx_messageInfo_ACLUserState proto.InternalMessageInfo -func (m *ACLChangeUserState) GetIdentity() string { +func (m *ACLUserState) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserState) GetEncryptionKey() []byte { +func (m *ACLUserState) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserState) GetEncryptedReadKeys() [][]byte { +func (m *ACLUserState) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserState) GetPermissions() ACLChangeUserPermissions { +func (m *ACLUserState) GetPermissions() ACLUserPermissions { if m != nil { return m.Permissions } - return ACLChange_Admin + return ACLUserPermissions_Admin } -func (m *ACLChangeUserState) GetIsConfirmed() bool { +func (m *ACLUserState) GetIsConfirmed() bool { if m != nil { return m.IsConfirmed } @@ -671,25 +456,25 @@ func (m *ACLChangeUserState) GetIsConfirmed() bool { } // we already know identity and encryptionKey -type ACLChangeUserAdd struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` +type ACLUserAdd struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` } -func (m *ACLChangeUserAdd) Reset() { *m = ACLChangeUserAdd{} } -func (m *ACLChangeUserAdd) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserAdd) ProtoMessage() {} -func (*ACLChangeUserAdd) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 5} +func (m *ACLUserAdd) Reset() { *m = ACLUserAdd{} } +func (m *ACLUserAdd) String() string { return proto.CompactTextString(m) } +func (*ACLUserAdd) ProtoMessage() {} +func (*ACLUserAdd) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{5} } -func (m *ACLChangeUserAdd) XXX_Unmarshal(b []byte) error { +func (m *ACLUserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserAdd.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserAdd.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -699,64 +484,64 @@ func (m *ACLChangeUserAdd) XXX_Marshal(b []byte, deterministic bool) ([]byte, er return b[:n], nil } } -func (m *ACLChangeUserAdd) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserAdd.Merge(m, src) +func (m *ACLUserAdd) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserAdd.Merge(m, src) } -func (m *ACLChangeUserAdd) XXX_Size() int { +func (m *ACLUserAdd) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserAdd) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserAdd.DiscardUnknown(m) +func (m *ACLUserAdd) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserAdd.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserAdd proto.InternalMessageInfo +var xxx_messageInfo_ACLUserAdd proto.InternalMessageInfo -func (m *ACLChangeUserAdd) GetIdentity() string { +func (m *ACLUserAdd) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserAdd) GetEncryptionKey() []byte { +func (m *ACLUserAdd) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserAdd) GetEncryptedReadKeys() [][]byte { +func (m *ACLUserAdd) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserAdd) GetPermissions() ACLChangeUserPermissions { +func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { if m != nil { return m.Permissions } - return ACLChange_Admin + return ACLUserPermissions_Admin } // TODO: this is not used as of now -type ACLChangeUserConfirm struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` +type ACLUserConfirm struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` } -func (m *ACLChangeUserConfirm) Reset() { *m = ACLChangeUserConfirm{} } -func (m *ACLChangeUserConfirm) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserConfirm) ProtoMessage() {} -func (*ACLChangeUserConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 6} +func (m *ACLUserConfirm) Reset() { *m = ACLUserConfirm{} } +func (m *ACLUserConfirm) String() string { return proto.CompactTextString(m) } +func (*ACLUserConfirm) ProtoMessage() {} +func (*ACLUserConfirm) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{6} } -func (m *ACLChangeUserConfirm) XXX_Unmarshal(b []byte) error { +func (m *ACLUserConfirm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserConfirm.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserConfirm.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -766,52 +551,52 @@ func (m *ACLChangeUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte return b[:n], nil } } -func (m *ACLChangeUserConfirm) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserConfirm.Merge(m, src) +func (m *ACLUserConfirm) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserConfirm.Merge(m, src) } -func (m *ACLChangeUserConfirm) XXX_Size() int { +func (m *ACLUserConfirm) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserConfirm) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserConfirm.DiscardUnknown(m) +func (m *ACLUserConfirm) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserConfirm.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserConfirm proto.InternalMessageInfo +var xxx_messageInfo_ACLUserConfirm proto.InternalMessageInfo -func (m *ACLChangeUserConfirm) GetIdentity() string { +func (m *ACLUserConfirm) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserConfirm) GetUserAddId() string { +func (m *ACLUserConfirm) GetUserAddId() string { if m != nil { return m.UserAddId } return "" } -type ACLChangeUserInvite struct { - AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` - EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` - InviteId string `protobuf:"bytes,5,opt,name=InviteId,proto3" json:"InviteId,omitempty"` +type ACLUserInvite struct { + AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` + EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` + EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + InviteId string `protobuf:"bytes,5,opt,name=inviteId,proto3" json:"inviteId,omitempty"` } -func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} } -func (m *ACLChangeUserInvite) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserInvite) ProtoMessage() {} -func (*ACLChangeUserInvite) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 7} +func (m *ACLUserInvite) Reset() { *m = ACLUserInvite{} } +func (m *ACLUserInvite) String() string { return proto.CompactTextString(m) } +func (*ACLUserInvite) ProtoMessage() {} +func (*ACLUserInvite) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{7} } -func (m *ACLChangeUserInvite) XXX_Unmarshal(b []byte) error { +func (m *ACLUserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserInvite.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserInvite.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -821,73 +606,73 @@ func (m *ACLChangeUserInvite) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserInvite) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserInvite.Merge(m, src) +func (m *ACLUserInvite) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserInvite.Merge(m, src) } -func (m *ACLChangeUserInvite) XXX_Size() int { +func (m *ACLUserInvite) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserInvite) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserInvite.DiscardUnknown(m) +func (m *ACLUserInvite) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserInvite.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserInvite proto.InternalMessageInfo +var xxx_messageInfo_ACLUserInvite proto.InternalMessageInfo -func (m *ACLChangeUserInvite) GetAcceptPublicKey() []byte { +func (m *ACLUserInvite) GetAcceptPublicKey() []byte { if m != nil { return m.AcceptPublicKey } return nil } -func (m *ACLChangeUserInvite) GetEncryptPublicKey() []byte { +func (m *ACLUserInvite) GetEncryptPublicKey() []byte { if m != nil { return m.EncryptPublicKey } return nil } -func (m *ACLChangeUserInvite) GetEncryptedReadKeys() [][]byte { +func (m *ACLUserInvite) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -func (m *ACLChangeUserInvite) GetPermissions() ACLChangeUserPermissions { +func (m *ACLUserInvite) GetPermissions() ACLUserPermissions { if m != nil { return m.Permissions } - return ACLChange_Admin + return ACLUserPermissions_Admin } -func (m *ACLChangeUserInvite) GetInviteId() string { +func (m *ACLUserInvite) GetInviteId() string { if m != nil { return m.InviteId } return "" } -type ACLChangeUserJoin struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` +type ACLUserJoin struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` } -func (m *ACLChangeUserJoin) Reset() { *m = ACLChangeUserJoin{} } -func (m *ACLChangeUserJoin) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserJoin) ProtoMessage() {} -func (*ACLChangeUserJoin) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 8} +func (m *ACLUserJoin) Reset() { *m = ACLUserJoin{} } +func (m *ACLUserJoin) String() string { return proto.CompactTextString(m) } +func (*ACLUserJoin) ProtoMessage() {} +func (*ACLUserJoin) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{8} } -func (m *ACLChangeUserJoin) XXX_Unmarshal(b []byte) error { +func (m *ACLUserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserJoin.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserJoin.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -897,70 +682,70 @@ func (m *ACLChangeUserJoin) XXX_Marshal(b []byte, deterministic bool) ([]byte, e return b[:n], nil } } -func (m *ACLChangeUserJoin) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserJoin.Merge(m, src) +func (m *ACLUserJoin) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserJoin.Merge(m, src) } -func (m *ACLChangeUserJoin) XXX_Size() int { +func (m *ACLUserJoin) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserJoin) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserJoin.DiscardUnknown(m) +func (m *ACLUserJoin) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserJoin.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserJoin proto.InternalMessageInfo +var xxx_messageInfo_ACLUserJoin proto.InternalMessageInfo -func (m *ACLChangeUserJoin) GetIdentity() string { +func (m *ACLUserJoin) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserJoin) GetEncryptionKey() []byte { +func (m *ACLUserJoin) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeUserJoin) GetAcceptSignature() []byte { +func (m *ACLUserJoin) GetAcceptSignature() []byte { if m != nil { return m.AcceptSignature } return nil } -func (m *ACLChangeUserJoin) GetUserInviteId() string { +func (m *ACLUserJoin) GetUserInviteId() string { if m != nil { return m.UserInviteId } return "" } -func (m *ACLChangeUserJoin) GetEncryptedReadKeys() [][]byte { +func (m *ACLUserJoin) GetEncryptedReadKeys() [][]byte { if m != nil { return m.EncryptedReadKeys } return nil } -type ACLChangeUserRemove struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - ReadKeyReplaces []*ACLChangeReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` +type ACLUserRemove struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + ReadKeyReplaces []*ACLReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` } -func (m *ACLChangeUserRemove) Reset() { *m = ACLChangeUserRemove{} } -func (m *ACLChangeUserRemove) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserRemove) ProtoMessage() {} -func (*ACLChangeUserRemove) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 9} +func (m *ACLUserRemove) Reset() { *m = ACLUserRemove{} } +func (m *ACLUserRemove) String() string { return proto.CompactTextString(m) } +func (*ACLUserRemove) ProtoMessage() {} +func (*ACLUserRemove) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{9} } -func (m *ACLChangeUserRemove) XXX_Unmarshal(b []byte) error { +func (m *ACLUserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserRemove.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserRemove.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -970,50 +755,50 @@ func (m *ACLChangeUserRemove) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *ACLChangeUserRemove) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserRemove.Merge(m, src) +func (m *ACLUserRemove) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserRemove.Merge(m, src) } -func (m *ACLChangeUserRemove) XXX_Size() int { +func (m *ACLUserRemove) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserRemove) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserRemove.DiscardUnknown(m) +func (m *ACLUserRemove) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserRemove.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserRemove proto.InternalMessageInfo +var xxx_messageInfo_ACLUserRemove proto.InternalMessageInfo -func (m *ACLChangeUserRemove) GetIdentity() string { +func (m *ACLUserRemove) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserRemove) GetReadKeyReplaces() []*ACLChangeReadKeyReplace { +func (m *ACLUserRemove) GetReadKeyReplaces() []*ACLReadKeyReplace { if m != nil { return m.ReadKeyReplaces } return nil } -type ACLChangeReadKeyReplace struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` +type ACLReadKeyReplace struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKey []byte `protobuf:"bytes,3,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` } -func (m *ACLChangeReadKeyReplace) Reset() { *m = ACLChangeReadKeyReplace{} } -func (m *ACLChangeReadKeyReplace) String() string { return proto.CompactTextString(m) } -func (*ACLChangeReadKeyReplace) ProtoMessage() {} -func (*ACLChangeReadKeyReplace) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 10} +func (m *ACLReadKeyReplace) Reset() { *m = ACLReadKeyReplace{} } +func (m *ACLReadKeyReplace) String() string { return proto.CompactTextString(m) } +func (*ACLReadKeyReplace) ProtoMessage() {} +func (*ACLReadKeyReplace) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{10} } -func (m *ACLChangeReadKeyReplace) XXX_Unmarshal(b []byte) error { +func (m *ACLReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeReadKeyReplace.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLReadKeyReplace.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1023,56 +808,56 @@ func (m *ACLChangeReadKeyReplace) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *ACLChangeReadKeyReplace) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeReadKeyReplace.Merge(m, src) +func (m *ACLReadKeyReplace) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLReadKeyReplace.Merge(m, src) } -func (m *ACLChangeReadKeyReplace) XXX_Size() int { +func (m *ACLReadKeyReplace) XXX_Size() int { return m.Size() } -func (m *ACLChangeReadKeyReplace) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeReadKeyReplace.DiscardUnknown(m) +func (m *ACLReadKeyReplace) XXX_DiscardUnknown() { + xxx_messageInfo_ACLReadKeyReplace.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeReadKeyReplace proto.InternalMessageInfo +var xxx_messageInfo_ACLReadKeyReplace proto.InternalMessageInfo -func (m *ACLChangeReadKeyReplace) GetIdentity() string { +func (m *ACLReadKeyReplace) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeReadKeyReplace) GetEncryptionKey() []byte { +func (m *ACLReadKeyReplace) GetEncryptionKey() []byte { if m != nil { return m.EncryptionKey } return nil } -func (m *ACLChangeReadKeyReplace) GetEncryptedReadKey() []byte { +func (m *ACLReadKeyReplace) GetEncryptedReadKey() []byte { if m != nil { return m.EncryptedReadKey } return nil } -type ACLChangeUserPermissionChange struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - Permissions ACLChangeUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLChangeUserPermissions" json:"permissions,omitempty"` +type ACLUserPermissionChange struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` } -func (m *ACLChangeUserPermissionChange) Reset() { *m = ACLChangeUserPermissionChange{} } -func (m *ACLChangeUserPermissionChange) String() string { return proto.CompactTextString(m) } -func (*ACLChangeUserPermissionChange) ProtoMessage() {} -func (*ACLChangeUserPermissionChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2, 11} +func (m *ACLUserPermissionChange) Reset() { *m = ACLUserPermissionChange{} } +func (m *ACLUserPermissionChange) String() string { return proto.CompactTextString(m) } +func (*ACLUserPermissionChange) ProtoMessage() {} +func (*ACLUserPermissionChange) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{11} } -func (m *ACLChangeUserPermissionChange) XXX_Unmarshal(b []byte) error { +func (m *ACLUserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *ACLChangeUserPermissionChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLUserPermissionChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_ACLChangeUserPermissionChange.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLUserPermissionChange.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1082,152 +867,52 @@ func (m *ACLChangeUserPermissionChange) XXX_Marshal(b []byte, deterministic bool return b[:n], nil } } -func (m *ACLChangeUserPermissionChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLChangeUserPermissionChange.Merge(m, src) +func (m *ACLUserPermissionChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLUserPermissionChange.Merge(m, src) } -func (m *ACLChangeUserPermissionChange) XXX_Size() int { +func (m *ACLUserPermissionChange) XXX_Size() int { return m.Size() } -func (m *ACLChangeUserPermissionChange) XXX_DiscardUnknown() { - xxx_messageInfo_ACLChangeUserPermissionChange.DiscardUnknown(m) +func (m *ACLUserPermissionChange) XXX_DiscardUnknown() { + xxx_messageInfo_ACLUserPermissionChange.DiscardUnknown(m) } -var xxx_messageInfo_ACLChangeUserPermissionChange proto.InternalMessageInfo +var xxx_messageInfo_ACLUserPermissionChange proto.InternalMessageInfo -func (m *ACLChangeUserPermissionChange) GetIdentity() string { +func (m *ACLUserPermissionChange) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *ACLChangeUserPermissionChange) GetPermissions() ACLChangeUserPermissions { +func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { if m != nil { return m.Permissions } - return ACLChange_Admin + return ACLUserPermissions_Admin } -type Change struct { - TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` - AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` - SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` - ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity string `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` - IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` -} - -func (m *Change) Reset() { *m = Change{} } -func (m *Change) String() string { return proto.CompactTextString(m) } -func (*Change) ProtoMessage() {} -func (*Change) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{3} -} -func (m *Change) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Change) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Change.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 *Change) XXX_Merge(src proto.Message) { - xxx_messageInfo_Change.Merge(m, src) -} -func (m *Change) XXX_Size() int { - return m.Size() -} -func (m *Change) XXX_DiscardUnknown() { - xxx_messageInfo_Change.DiscardUnknown(m) -} - -var xxx_messageInfo_Change proto.InternalMessageInfo - -func (m *Change) GetTreeHeadIds() []string { - if m != nil { - return m.TreeHeadIds - } - return nil -} - -func (m *Change) GetAclHeadId() string { - if m != nil { - return m.AclHeadId - } - return "" -} - -func (m *Change) GetSnapshotBaseId() string { - if m != nil { - return m.SnapshotBaseId - } - return "" -} - -func (m *Change) GetChangesData() []byte { - if m != nil { - return m.ChangesData - } - return nil -} - -func (m *Change) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *Change) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *Change) GetIdentity() string { - if m != nil { - return m.Identity - } - return "" -} - -func (m *Change) GetIsSnapshot() bool { - if m != nil { - return m.IsSnapshot - } - return false -} - -type Record struct { +type ACLRecord struct { PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` - Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } -func (m *Record) Reset() { *m = Record{} } -func (m *Record) String() string { return proto.CompactTextString(m) } -func (*Record) ProtoMessage() {} -func (*Record) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{4} +func (m *ACLRecord) Reset() { *m = ACLRecord{} } +func (m *ACLRecord) String() string { return proto.CompactTextString(m) } +func (*ACLRecord) ProtoMessage() {} +func (*ACLRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{12} } -func (m *Record) XXX_Unmarshal(b []byte) error { +func (m *ACLRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Record.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLRecord.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1237,72 +922,70 @@ func (m *Record) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Record) XXX_Merge(src proto.Message) { - xxx_messageInfo_Record.Merge(m, src) +func (m *ACLRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLRecord.Merge(m, src) } -func (m *Record) XXX_Size() int { +func (m *ACLRecord) XXX_Size() int { return m.Size() } -func (m *Record) XXX_DiscardUnknown() { - xxx_messageInfo_Record.DiscardUnknown(m) +func (m *ACLRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ACLRecord.DiscardUnknown(m) } -var xxx_messageInfo_Record proto.InternalMessageInfo +var xxx_messageInfo_ACLRecord proto.InternalMessageInfo -func (m *Record) GetPrevId() string { +func (m *ACLRecord) GetPrevId() string { if m != nil { return m.PrevId } return "" } -func (m *Record) GetIdentity() string { +func (m *ACLRecord) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } -func (m *Record) GetData() []byte { +func (m *ACLRecord) GetData() []byte { if m != nil { return m.Data } return nil } -func (m *Record) GetCurrentReadKeyHash() uint64 { +func (m *ACLRecord) GetCurrentReadKeyHash() uint64 { if m != nil { return m.CurrentReadKeyHash } return 0 } -func (m *Record) GetTimestamp() int64 { +func (m *ACLRecord) GetTimestamp() int64 { if m != nil { return m.Timestamp } return 0 } -type Header struct { - FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - AclListId string `protobuf:"bytes,2,opt,name=aclListId,proto3" json:"aclListId,omitempty"` - WorkspaceId string `protobuf:"bytes,3,opt,name=workspaceId,proto3" json:"workspaceId,omitempty"` - DocType HeaderDocType `protobuf:"varint,4,opt,name=docType,proto3,enum=acl.HeaderDocType" json:"docType,omitempty"` +type ACLHeader struct { + FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` } -func (m *Header) Reset() { *m = Header{} } -func (m *Header) String() string { return proto.CompactTextString(m) } -func (*Header) ProtoMessage() {} -func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{5} +func (m *ACLHeader) Reset() { *m = ACLHeader{} } +func (m *ACLHeader) String() string { return proto.CompactTextString(m) } +func (*ACLHeader) ProtoMessage() {} +func (*ACLHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{13} } -func (m *Header) XXX_Unmarshal(b []byte) error { +func (m *ACLHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *ACLHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_Header.Marshal(b, m, deterministic) + return xxx_messageInfo_ACLHeader.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -1312,68 +995,334 @@ func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header.Merge(m, src) +func (m *ACLHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLHeader.Merge(m, src) } -func (m *Header) XXX_Size() int { +func (m *ACLHeader) XXX_Size() int { return m.Size() } -func (m *Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header.DiscardUnknown(m) +func (m *ACLHeader) XXX_DiscardUnknown() { + xxx_messageInfo_ACLHeader.DiscardUnknown(m) } -var xxx_messageInfo_Header proto.InternalMessageInfo +var xxx_messageInfo_ACLHeader proto.InternalMessageInfo -func (m *Header) GetFirstId() string { +func (m *ACLHeader) GetFirstId() string { if m != nil { return m.FirstId } return "" } -func (m *Header) GetAclListId() string { +func (m *ACLHeader) GetIdentity() []byte { if m != nil { - return m.AclListId + return m.Identity + } + return nil +} + +type RawTreeChange struct { + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *RawTreeChange) Reset() { *m = RawTreeChange{} } +func (m *RawTreeChange) String() string { return proto.CompactTextString(m) } +func (*RawTreeChange) ProtoMessage() {} +func (*RawTreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{14} +} +func (m *RawTreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChange.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 *RawTreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChange.Merge(m, src) +} +func (m *RawTreeChange) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChange proto.InternalMessageInfo + +func (m *RawTreeChange) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + +func (m *RawTreeChange) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +type RawTreeChangeWithId struct { + RawChange []byte `protobuf:"bytes,1,opt,name=rawChange,proto3" json:"rawChange,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *RawTreeChangeWithId) Reset() { *m = RawTreeChangeWithId{} } +func (m *RawTreeChangeWithId) String() string { return proto.CompactTextString(m) } +func (*RawTreeChangeWithId) ProtoMessage() {} +func (*RawTreeChangeWithId) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{15} +} +func (m *RawTreeChangeWithId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChangeWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChangeWithId.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 *RawTreeChangeWithId) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChangeWithId.Merge(m, src) +} +func (m *RawTreeChangeWithId) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChangeWithId) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChangeWithId.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChangeWithId proto.InternalMessageInfo + +func (m *RawTreeChangeWithId) GetRawChange() []byte { + if m != nil { + return m.RawChange + } + return nil +} + +func (m *RawTreeChangeWithId) GetId() string { + if m != nil { + return m.Id } return "" } -func (m *Header) GetWorkspaceId() string { +type TreeChange struct { + TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` + AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` + ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` + CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` + IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` +} + +func (m *TreeChange) Reset() { *m = TreeChange{} } +func (m *TreeChange) String() string { return proto.CompactTextString(m) } +func (*TreeChange) ProtoMessage() {} +func (*TreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{16} +} +func (m *TreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TreeChange.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 *TreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_TreeChange.Merge(m, src) +} +func (m *TreeChange) XXX_Size() int { + return m.Size() +} +func (m *TreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_TreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_TreeChange proto.InternalMessageInfo + +func (m *TreeChange) GetTreeHeadIds() []string { if m != nil { - return m.WorkspaceId + return m.TreeHeadIds + } + return nil +} + +func (m *TreeChange) GetAclHeadId() string { + if m != nil { + return m.AclHeadId } return "" } -func (m *Header) GetDocType() HeaderDocType { +func (m *TreeChange) GetSnapshotBaseId() string { if m != nil { - return m.DocType + return m.SnapshotBaseId } - return Header_ACL + return "" +} + +func (m *TreeChange) GetChangesData() []byte { + if m != nil { + return m.ChangesData + } + return nil +} + +func (m *TreeChange) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *TreeChange) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *TreeChange) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *TreeChange) GetIsSnapshot() bool { + if m != nil { + return m.IsSnapshot + } + return false +} + +type TreeHeader struct { + FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` + AclId string `protobuf:"bytes,2,opt,name=aclId,proto3" json:"aclId,omitempty"` + TreeHeaderType TreeHeaderType `protobuf:"varint,3,opt,name=treeHeaderType,proto3,enum=acl.TreeHeaderType" json:"treeHeaderType,omitempty"` + Identity []byte `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` + Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` +} + +func (m *TreeHeader) Reset() { *m = TreeHeader{} } +func (m *TreeHeader) String() string { return proto.CompactTextString(m) } +func (*TreeHeader) ProtoMessage() {} +func (*TreeHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_37a022c841a51877, []int{17} +} +func (m *TreeHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TreeHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TreeHeader.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 *TreeHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_TreeHeader.Merge(m, src) +} +func (m *TreeHeader) XXX_Size() int { + return m.Size() +} +func (m *TreeHeader) XXX_DiscardUnknown() { + xxx_messageInfo_TreeHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_TreeHeader proto.InternalMessageInfo + +func (m *TreeHeader) GetFirstId() string { + if m != nil { + return m.FirstId + } + return "" +} + +func (m *TreeHeader) GetAclId() string { + if m != nil { + return m.AclId + } + return "" +} + +func (m *TreeHeader) GetTreeHeaderType() TreeHeaderType { + if m != nil { + return m.TreeHeaderType + } + return TreeHeaderType_Object +} + +func (m *TreeHeader) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *TreeHeader) GetData() []byte { + if m != nil { + return m.Data + } + return nil } func init() { - proto.RegisterEnum("acl.ACLChangeUserPermissions", ACLChangeUserPermissions_name, ACLChangeUserPermissions_value) - proto.RegisterEnum("acl.HeaderDocType", HeaderDocType_name, HeaderDocType_value) - proto.RegisterType((*RawChange)(nil), "acl.RawChange") - proto.RegisterType((*RawRecord)(nil), "acl.RawRecord") - proto.RegisterType((*ACLChange)(nil), "acl.ACLChange") - proto.RegisterType((*ACLChangeACLContentValue)(nil), "acl.ACLChange.ACLContentValue") - proto.RegisterType((*ACLChangeACLData)(nil), "acl.ACLChange.ACLData") - proto.RegisterType((*ACLChangeACLSnapshot)(nil), "acl.ACLChange.ACLSnapshot") - proto.RegisterType((*ACLChangeACLState)(nil), "acl.ACLChange.ACLState") - proto.RegisterMapType((map[string]*ACLChangeUserInvite)(nil), "acl.ACLChange.ACLState.InvitesEntry") - proto.RegisterType((*ACLChangeUserState)(nil), "acl.ACLChange.UserState") - proto.RegisterType((*ACLChangeUserAdd)(nil), "acl.ACLChange.UserAdd") - proto.RegisterType((*ACLChangeUserConfirm)(nil), "acl.ACLChange.UserConfirm") - proto.RegisterType((*ACLChangeUserInvite)(nil), "acl.ACLChange.UserInvite") - proto.RegisterType((*ACLChangeUserJoin)(nil), "acl.ACLChange.UserJoin") - proto.RegisterType((*ACLChangeUserRemove)(nil), "acl.ACLChange.UserRemove") - proto.RegisterType((*ACLChangeReadKeyReplace)(nil), "acl.ACLChange.ReadKeyReplace") - proto.RegisterType((*ACLChangeUserPermissionChange)(nil), "acl.ACLChange.UserPermissionChange") - proto.RegisterType((*Change)(nil), "acl.Change") - proto.RegisterType((*Record)(nil), "acl.Record") - proto.RegisterType((*Header)(nil), "acl.Header") + proto.RegisterEnum("acl.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) + proto.RegisterEnum("acl.TreeHeaderType", TreeHeaderType_name, TreeHeaderType_value) + proto.RegisterType((*RawACLRecord)(nil), "acl.RawACLRecord") + proto.RegisterType((*ACLContentValue)(nil), "acl.ACLContentValue") + proto.RegisterType((*ACLData)(nil), "acl.ACLData") + proto.RegisterType((*ACLState)(nil), "acl.ACLState") + proto.RegisterMapType((map[string]*ACLUserInvite)(nil), "acl.ACLState.InvitesEntry") + proto.RegisterType((*ACLUserState)(nil), "acl.ACLUserState") + proto.RegisterType((*ACLUserAdd)(nil), "acl.ACLUserAdd") + proto.RegisterType((*ACLUserConfirm)(nil), "acl.ACLUserConfirm") + proto.RegisterType((*ACLUserInvite)(nil), "acl.ACLUserInvite") + proto.RegisterType((*ACLUserJoin)(nil), "acl.ACLUserJoin") + proto.RegisterType((*ACLUserRemove)(nil), "acl.ACLUserRemove") + proto.RegisterType((*ACLReadKeyReplace)(nil), "acl.ACLReadKeyReplace") + proto.RegisterType((*ACLUserPermissionChange)(nil), "acl.ACLUserPermissionChange") + proto.RegisterType((*ACLRecord)(nil), "acl.ACLRecord") + proto.RegisterType((*ACLHeader)(nil), "acl.ACLHeader") + proto.RegisterType((*RawTreeChange)(nil), "acl.RawTreeChange") + proto.RegisterType((*RawTreeChangeWithId)(nil), "acl.RawTreeChangeWithId") + proto.RegisterType((*TreeChange)(nil), "acl.TreeChange") + proto.RegisterType((*TreeHeader)(nil), "acl.TreeHeader") } func init() { @@ -1381,81 +1330,78 @@ func init() { } var fileDescriptor_37a022c841a51877 = []byte{ - // 1131 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x57, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0xf8, 0xdf, 0x7a, 0xdf, 0x86, 0xc4, 0x4c, 0xab, 0xd6, 0xac, 0x8a, 0x6b, 0x99, 0x0a, - 0x59, 0x08, 0x9c, 0xca, 0x15, 0x52, 0x05, 0x28, 0x22, 0x49, 0x51, 0x6d, 0x92, 0x43, 0x35, 0xa1, - 0x20, 0xb8, 0x4d, 0x76, 0xa7, 0xc9, 0x2a, 0xf6, 0xee, 0xb2, 0x33, 0x49, 0xe5, 0x0b, 0x12, 0x27, - 0xae, 0x9c, 0x11, 0xe2, 0x43, 0x70, 0xe5, 0x0b, 0xf4, 0xd8, 0x23, 0x37, 0x50, 0x72, 0xe7, 0xc2, - 0x17, 0x40, 0xf3, 0x67, 0xd7, 0xeb, 0xf5, 0x26, 0x0a, 0x52, 0x84, 0xc4, 0x21, 0xd2, 0xcc, 0xef, - 0xfd, 0xde, 0xf8, 0xbd, 0xf7, 0x7b, 0xf3, 0x32, 0x0b, 0x0f, 0xe3, 0x93, 0xa3, 0x4d, 0xea, 0x4d, - 0xe5, 0x9f, 0x77, 0x4c, 0xc3, 0x23, 0xc6, 0xe5, 0x32, 0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93, 0x12, 0x8b, 0xac, 0x94, 0x08, 0x66, 0x8c, 0x0b, 0x3a, 0x8b, 0x3b, 0x56, 0x0f, 0x0d, 0x6a, - 0x64, 0x01, 0x60, 0x17, 0x5a, 0x81, 0xcf, 0x42, 0x11, 0x88, 0x79, 0xa7, 0xa5, 0x72, 0xc8, 0xf6, - 0xee, 0x4f, 0x35, 0xd8, 0x90, 0xa1, 0x46, 0xa1, 0x60, 0xa1, 0xf8, 0x92, 0x4e, 0x4f, 0x19, 0x1e, - 0x81, 0x75, 0xca, 0x59, 0xb2, 0xed, 0x6b, 0x45, 0x56, 0x33, 0x7a, 0xae, 0xad, 0xe3, 0x0a, 0x49, - 0x89, 0xf8, 0x63, 0x00, 0xb9, 0x24, 0x6c, 0x16, 0x9d, 0x69, 0xb1, 0x9c, 0xd1, 0x5b, 0x25, 0x6e, - 0x9a, 0x30, 0xae, 0x90, 0x1c, 0x1d, 0x7f, 0x0d, 0xb7, 0xe5, 0xee, 0x19, 0x4b, 0x66, 0x01, 0xe7, - 0x41, 0x14, 0x6a, 0x07, 0x55, 0x70, 0x67, 0xf4, 0x4e, 0xc9, 0x31, 0x45, 0xea, 0xb8, 0x42, 0x4a, - 0x8f, 0x48, 0xe3, 0x9a, 0x84, 0x67, 0x81, 0x60, 0x46, 0xa0, 0xb2, 0xb8, 0x34, 0x21, 0x8d, 0x4b, - 0xef, 0xf0, 0x87, 0xd0, 0x92, 0xbb, 0xcf, 0xa3, 0x20, 0x54, 0x2a, 0x39, 0xa3, 0xbb, 0x25, 0xae, - 0xd2, 0x3c, 0xae, 0x90, 0x8c, 0x8a, 0xb7, 0xc0, 0x91, 0xeb, 0xdd, 0x28, 0x7c, 0x11, 0x24, 0x33, - 0x25, 0x9b, 0x33, 0x72, 0x4b, 0x3c, 0x0d, 0x63, 0x5c, 0x21, 0x79, 0x87, 0x1d, 0x0b, 0x1a, 0x67, - 0x52, 0x08, 0xf7, 0x07, 0x04, 0x96, 0xe9, 0x1e, 0xfc, 0x09, 0x38, 0xd4, 0x9b, 0x1e, 0x98, 0xde, - 0x33, 0xc2, 0xb8, 0xab, 0xad, 0x96, 0x32, 0x48, 0x9e, 0x8e, 0xb7, 0x54, 0xb3, 0x1b, 0x95, 0x55, - 0xb3, 0x3b, 0xa3, 0xee, 0xaa, 0x73, 0xbe, 0x0d, 0x48, 0xce, 0xc3, 0xdd, 0x01, 0x27, 0x77, 0x36, - 0x7e, 0x04, 0x2d, 0x79, 0xba, 0xa0, 0x82, 0x99, 0x48, 0xee, 0x96, 0x44, 0x22, 0xcd, 0x24, 0x23, - 0xba, 0xdf, 0x57, 0xa1, 0x95, 0xc2, 0xf8, 0x01, 0xbc, 0x91, 0x2c, 0x1a, 0x98, 0xe9, 0x1b, 0x5a, - 0x27, 0xcb, 0x20, 0x7e, 0xac, 0xd5, 0x53, 0x2e, 0xdc, 0x84, 0xdd, 0x29, 0x29, 0xa4, 0xfe, 0xa9, - 0x1c, 0x17, 0x6f, 0x81, 0x15, 0x28, 0x11, 0x79, 0xa7, 0xa6, 0xdc, 0x1e, 0x5c, 0x12, 0xe0, 0x50, - 0x6b, 0xcd, 0x3f, 0x0b, 0x45, 0x32, 0x27, 0xa9, 0x93, 0xfb, 0x1c, 0xd6, 0xf2, 0x06, 0xdc, 0x86, - 0xda, 0x09, 0x9b, 0xab, 0x64, 0x6d, 0x22, 0x97, 0x78, 0xd3, 0xa8, 0x74, 0x45, 0xb3, 0xeb, 0x13, - 0x88, 0xe6, 0x7d, 0x54, 0x7d, 0x8c, 0xdc, 0x3f, 0x10, 0xd8, 0x59, 0xc0, 0x4b, 0x17, 0x13, 0x2d, - 0x5f, 0x4c, 0x59, 0x20, 0x16, 0x7a, 0xc9, 0x3c, 0x16, 0x41, 0x14, 0xee, 0xb1, 0xb9, 0x19, 0x80, - 0xcb, 0x20, 0x7e, 0x1f, 0xde, 0x34, 0x00, 0xf3, 0xcd, 0x40, 0xd0, 0x09, 0xaf, 0x91, 0x55, 0x03, - 0xfe, 0x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0b, 0xd1, 0xf2, 0x10, - 0xfe, 0x00, 0x2c, 0x3f, 0xf2, 0xbe, 0x98, 0xc7, 0xcc, 0x4c, 0xbd, 0x5b, 0xaa, 0x4b, 0xf5, 0xef, - 0x0e, 0x9f, 0x68, 0x13, 0x49, 0x39, 0xfd, 0xfb, 0x60, 0x19, 0x0c, 0x5b, 0x50, 0xdb, 0xde, 0xdd, - 0x6f, 0x57, 0x64, 0xd3, 0x49, 0x2c, 0x61, 0xac, 0x8d, 0x76, 0xee, 0xbf, 0x3a, 0xef, 0xa2, 0xd7, - 0xe7, 0x5d, 0xf4, 0xe7, 0x79, 0x17, 0xfd, 0x78, 0xd1, 0xad, 0xbc, 0xbe, 0xe8, 0x56, 0x7e, 0xbf, - 0xe8, 0x56, 0xbe, 0x69, 0xa8, 0x4f, 0xaa, 0xc3, 0xa6, 0xfa, 0x82, 0x7a, 0xf4, 0x4f, 0x00, 0x00, - 0x00, 0xff, 0xff, 0x14, 0x6d, 0xee, 0xf8, 0x75, 0x0d, 0x00, 0x00, + // 1078 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45, + 0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x44, 0x23, + 0x04, 0x51, 0x40, 0x5e, 0x08, 0x2b, 0xf1, 0x77, 0x00, 0xc7, 0x8b, 0xb0, 0x37, 0x11, 0xac, 0x3a, + 0x61, 0x57, 0xe2, 0xd6, 0x99, 0xe9, 0x4d, 0x9a, 0xb5, 0x67, 0x46, 0xd3, 0x9d, 0x44, 0x3e, 0xf2, + 0x06, 0x3c, 0x02, 0x1c, 0x79, 0x02, 0x5e, 0x01, 0x89, 0xcb, 0x1e, 0x91, 0xb8, 0xa0, 0xe4, 0x04, + 0x27, 0x1e, 0x01, 0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75, 0x55, 0xc7, 0x45, 0x4d, 0xa8, 0xeb, 0xd6, 0x16, 0x76, 0xaa, 0xbb, 0xaf, + 0x43, 0xbb, 0xec, 0x97, 0x54, 0xfd, 0xfc, 0xe4, 0x2b, 0x1a, 0x88, 0x4e, 0x45, 0x9e, 0x76, 0x94, + 0x90, 0x80, 0x76, 0x9c, 0xfd, 0x57, 0x7e, 0xbc, 0xea, 0x3a, 0x2f, 0xae, 0xba, 0xce, 0xaf, 0x57, + 0x5d, 0xe7, 0x9b, 0xeb, 0x6e, 0xe5, 0xc5, 0x75, 0xb7, 0xf2, 0xf3, 0x75, 0xb7, 0xf2, 0x65, 0x4d, + 0x0d, 0xfb, 0x27, 0xcb, 0x6a, 0xb6, 0x7f, 0xe7, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x25, + 0x31, 0x18, 0x0f, 0x0c, 0x00, 0x00, } -func (m *RawChange) Marshal() (dAtA []byte, err error) { +func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1465,12 +1411,12 @@ func (m *RawChange) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RawChange) MarshalTo(dAtA []byte) (int, error) { +func (m *RawACLRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *RawChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *RawACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1499,7 +1445,7 @@ func (m *RawChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *RawRecord) Marshal() (dAtA []byte, err error) { +func (m *ACLContentValue) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1509,140 +1455,12 @@ func (m *RawRecord) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *RawRecord) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *RawRecord) 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 = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x1a - } - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLChange) 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 *ACLChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x42 - } - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x38 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x30 - } - if len(m.ChangesData) > 0 { - i -= len(m.ChangesData) - copy(dAtA[i:], m.ChangesData) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.ChangesData))) - i-- - dAtA[i] = 0x2a - } - if m.AclData != nil { - { - size, err := m.AclData.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - if len(m.SnapshotBaseId) > 0 { - i -= len(m.SnapshotBaseId) - copy(dAtA[i:], m.SnapshotBaseId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.SnapshotBaseId))) - i-- - dAtA[i] = 0x1a - } - if len(m.AclHeadIds) > 0 { - for iNdEx := len(m.AclHeadIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.AclHeadIds[iNdEx]) - copy(dAtA[i:], m.AclHeadIds[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclHeadIds[iNdEx]))) - i-- - dAtA[i] = 0x12 - } - } - if len(m.TreeHeadIds) > 0 { - for iNdEx := len(m.TreeHeadIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.TreeHeadIds[iNdEx]) - copy(dAtA[i:], m.TreeHeadIds[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.TreeHeadIds[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *ACLChangeACLContentValue) 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 *ACLChangeACLContentValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLChangeACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1659,12 +1477,12 @@ func (m *ACLChangeACLContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserAdd != nil { { @@ -1680,12 +1498,12 @@ func (m *ACLChangeACLContentValueValueOfUserAdd) MarshalToSizedBuffer(dAtA []byt } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserRemove) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserRemove != nil { { @@ -1701,12 +1519,12 @@ func (m *ACLChangeACLContentValueValueOfUserRemove) MarshalToSizedBuffer(dAtA [] } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserPermissionChange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserPermissionChange != nil { { @@ -1722,12 +1540,12 @@ func (m *ACLChangeACLContentValueValueOfUserPermissionChange) MarshalToSizedBuff } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserInvite) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserInvite != nil { { @@ -1743,12 +1561,12 @@ func (m *ACLChangeACLContentValueValueOfUserInvite) MarshalToSizedBuffer(dAtA [] } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserJoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserJoin != nil { { @@ -1764,12 +1582,12 @@ func (m *ACLChangeACLContentValueValueOfUserJoin) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } -func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserConfirm) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLContentValue_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.UserConfirm != nil { { @@ -1785,7 +1603,7 @@ func (m *ACLChangeACLContentValueValueOfUserConfirm) MarshalToSizedBuffer(dAtA [ } return len(dAtA) - i, nil } -func (m *ACLChangeACLData) Marshal() (dAtA []byte, err error) { +func (m *ACLData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1795,12 +1613,12 @@ func (m *ACLChangeACLData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLData) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLData) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1816,25 +1634,13 @@ func (m *ACLChangeACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { i = encodeVarintAclchanges(dAtA, i, uint64(size)) } i-- - dAtA[i] = 0x12 + dAtA[i] = 0xa } } - if m.AclSnapshot != nil { - { - size, err := m.AclSnapshot.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } return len(dAtA) - i, nil } -func (m *ACLChangeACLSnapshot) Marshal() (dAtA []byte, err error) { +func (m *ACLState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1844,47 +1650,12 @@ func (m *ACLChangeACLSnapshot) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeACLSnapshot) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeACLSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.AclState != nil { - { - size, err := m.AclState.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLChangeACLState) 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 *ACLChangeACLState) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLChangeACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1930,27 +1701,27 @@ func (m *ACLChangeACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { } } if len(m.ReadKeyHashes) > 0 { - dAtA12 := make([]byte, len(m.ReadKeyHashes)*10) - var j11 int + dAtA9 := make([]byte, len(m.ReadKeyHashes)*10) + var j8 int for _, num := range m.ReadKeyHashes { for num >= 1<<7 { - dAtA12[j11] = uint8(uint64(num)&0x7f | 0x80) + dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j11++ + j8++ } - dAtA12[j11] = uint8(num) - j11++ + dAtA9[j8] = uint8(num) + j8++ } - i -= j11 - copy(dAtA[i:], dAtA12[:j11]) - i = encodeVarintAclchanges(dAtA, i, uint64(j11)) + i -= j8 + copy(dAtA[i:], dAtA9[:j8]) + i = encodeVarintAclchanges(dAtA, i, uint64(j8)) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ACLChangeUserState) Marshal() (dAtA []byte, err error) { +func (m *ACLUserState) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1960,12 +1731,12 @@ func (m *ACLChangeUserState) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserState) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserState) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2011,7 +1782,7 @@ func (m *ACLChangeUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserAdd) Marshal() (dAtA []byte, err error) { +func (m *ACLUserAdd) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2021,12 +1792,12 @@ func (m *ACLChangeUserAdd) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserAdd) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserAdd) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2062,7 +1833,7 @@ func (m *ACLChangeUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserConfirm) Marshal() (dAtA []byte, err error) { +func (m *ACLUserConfirm) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2072,12 +1843,12 @@ func (m *ACLChangeUserConfirm) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserConfirm) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserConfirm) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2099,7 +1870,7 @@ func (m *ACLChangeUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserInvite) Marshal() (dAtA []byte, err error) { +func (m *ACLUserInvite) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2109,12 +1880,12 @@ func (m *ACLChangeUserInvite) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserInvite) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserInvite) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2157,7 +1928,7 @@ func (m *ACLChangeUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserJoin) Marshal() (dAtA []byte, err error) { +func (m *ACLUserJoin) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2167,12 +1938,12 @@ func (m *ACLChangeUserJoin) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserJoin) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserJoin) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2217,7 +1988,7 @@ func (m *ACLChangeUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeUserRemove) Marshal() (dAtA []byte, err error) { +func (m *ACLUserRemove) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2227,12 +1998,12 @@ func (m *ACLChangeUserRemove) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserRemove) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserRemove) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2261,7 +2032,7 @@ func (m *ACLChangeUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *ACLChangeReadKeyReplace) Marshal() (dAtA []byte, err error) { +func (m *ACLReadKeyReplace) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2271,12 +2042,12 @@ func (m *ACLChangeReadKeyReplace) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeReadKeyReplace) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLReadKeyReplace) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2305,7 +2076,7 @@ func (m *ACLChangeReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *ACLChangeUserPermissionChange) Marshal() (dAtA []byte, err error) { +func (m *ACLUserPermissionChange) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2315,12 +2086,12 @@ func (m *ACLChangeUserPermissionChange) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *ACLChangeUserPermissionChange) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLUserPermissionChange) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *ACLChangeUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2340,7 +2111,7 @@ func (m *ACLChangeUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, return len(dAtA) - i, nil } -func (m *Change) Marshal() (dAtA []byte, err error) { +func (m *ACLRecord) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2350,12 +2121,177 @@ func (m *Change) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Change) MarshalTo(dAtA []byte) (int, error) { +func (m *ACLRecord) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Change) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *ACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x28 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x20 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.PrevId) > 0 { + i -= len(m.PrevId) + copy(dAtA[i:], m.PrevId) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.PrevId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ACLHeader) 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 *ACLHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.FirstId) > 0 { + i -= len(m.FirstId) + copy(dAtA[i:], m.FirstId) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.FirstId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChange) 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 *RawTreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChange) 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 = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChangeWithId) 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 *RawTreeChangeWithId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChangeWithId) 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 = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.RawChange) > 0 { + i -= len(m.RawChange) + copy(dAtA[i:], m.RawChange) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.RawChange))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TreeChange) 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 *TreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -2420,7 +2356,7 @@ func (m *Change) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Record) Marshal() (dAtA []byte, err error) { +func (m *TreeHeader) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -2430,86 +2366,39 @@ func (m *Record) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *Record) MarshalTo(dAtA []byte) (int, error) { +func (m *TreeHeader) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *Record) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *TreeHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int _ = l - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x28 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x20 - } if len(m.Data) > 0 { i -= len(m.Data) copy(dAtA[i:], m.Data) i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) i-- - dAtA[i] = 0x1a + dAtA[i] = 0x2a } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) i-- - dAtA[i] = 0x12 + dAtA[i] = 0x22 } - if len(m.PrevId) > 0 { - i -= len(m.PrevId) - copy(dAtA[i:], m.PrevId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.PrevId))) + if m.TreeHeaderType != 0 { + i = encodeVarintAclchanges(dAtA, i, uint64(m.TreeHeaderType)) i-- - dAtA[i] = 0xa + dAtA[i] = 0x18 } - return len(dAtA) - i, nil -} - -func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.DocType != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.DocType)) - i-- - dAtA[i] = 0x20 - } - if len(m.WorkspaceId) > 0 { - i -= len(m.WorkspaceId) - copy(dAtA[i:], m.WorkspaceId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.WorkspaceId))) - i-- - dAtA[i] = 0x1a - } - if len(m.AclListId) > 0 { - i -= len(m.AclListId) - copy(dAtA[i:], m.AclListId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclListId))) + if len(m.AclId) > 0 { + i -= len(m.AclId) + copy(dAtA[i:], m.AclId) + i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclId))) i-- dAtA[i] = 0x12 } @@ -2534,7 +2423,7 @@ func encodeVarintAclchanges(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *RawChange) Size() (n int) { +func (m *RawACLRecord) Size() (n int) { if m == nil { return 0 } @@ -2555,71 +2444,7 @@ func (m *RawChange) Size() (n int) { return n } -func (m *RawRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Id) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *ACLChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.TreeHeadIds) > 0 { - for _, s := range m.TreeHeadIds { - l = len(s) - n += 1 + l + sovAclchanges(uint64(l)) - } - } - if len(m.AclHeadIds) > 0 { - for _, s := range m.AclHeadIds { - l = len(s) - n += 1 + l + sovAclchanges(uint64(l)) - } - } - l = len(m.SnapshotBaseId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.AclData != nil { - l = m.AclData.Size() - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.ChangesData) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *ACLChangeACLContentValue) Size() (n int) { +func (m *ACLContentValue) Size() (n int) { if m == nil { return 0 } @@ -2631,7 +2456,7 @@ func (m *ACLChangeACLContentValue) Size() (n int) { return n } -func (m *ACLChangeACLContentValueValueOfUserAdd) Size() (n int) { +func (m *ACLContentValue_UserAdd) Size() (n int) { if m == nil { return 0 } @@ -2643,7 +2468,7 @@ func (m *ACLChangeACLContentValueValueOfUserAdd) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserRemove) Size() (n int) { +func (m *ACLContentValue_UserRemove) Size() (n int) { if m == nil { return 0 } @@ -2655,7 +2480,7 @@ func (m *ACLChangeACLContentValueValueOfUserRemove) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserPermissionChange) Size() (n int) { +func (m *ACLContentValue_UserPermissionChange) Size() (n int) { if m == nil { return 0 } @@ -2667,7 +2492,7 @@ func (m *ACLChangeACLContentValueValueOfUserPermissionChange) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserInvite) Size() (n int) { +func (m *ACLContentValue_UserInvite) Size() (n int) { if m == nil { return 0 } @@ -2679,7 +2504,7 @@ func (m *ACLChangeACLContentValueValueOfUserInvite) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserJoin) Size() (n int) { +func (m *ACLContentValue_UserJoin) Size() (n int) { if m == nil { return 0 } @@ -2691,7 +2516,7 @@ func (m *ACLChangeACLContentValueValueOfUserJoin) Size() (n int) { } return n } -func (m *ACLChangeACLContentValueValueOfUserConfirm) Size() (n int) { +func (m *ACLContentValue_UserConfirm) Size() (n int) { if m == nil { return 0 } @@ -2703,16 +2528,12 @@ func (m *ACLChangeACLContentValueValueOfUserConfirm) Size() (n int) { } return n } -func (m *ACLChangeACLData) Size() (n int) { +func (m *ACLData) Size() (n int) { if m == nil { return 0 } var l int _ = l - if m.AclSnapshot != nil { - l = m.AclSnapshot.Size() - n += 1 + l + sovAclchanges(uint64(l)) - } if len(m.AclContent) > 0 { for _, e := range m.AclContent { l = e.Size() @@ -2722,20 +2543,7 @@ func (m *ACLChangeACLData) Size() (n int) { return n } -func (m *ACLChangeACLSnapshot) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AclState != nil { - l = m.AclState.Size() - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *ACLChangeACLState) Size() (n int) { +func (m *ACLState) Size() (n int) { if m == nil { return 0 } @@ -2770,7 +2578,7 @@ func (m *ACLChangeACLState) Size() (n int) { return n } -func (m *ACLChangeUserState) Size() (n int) { +func (m *ACLUserState) Size() (n int) { if m == nil { return 0 } @@ -2799,7 +2607,7 @@ func (m *ACLChangeUserState) Size() (n int) { return n } -func (m *ACLChangeUserAdd) Size() (n int) { +func (m *ACLUserAdd) Size() (n int) { if m == nil { return 0 } @@ -2825,7 +2633,7 @@ func (m *ACLChangeUserAdd) Size() (n int) { return n } -func (m *ACLChangeUserConfirm) Size() (n int) { +func (m *ACLUserConfirm) Size() (n int) { if m == nil { return 0 } @@ -2842,7 +2650,7 @@ func (m *ACLChangeUserConfirm) Size() (n int) { return n } -func (m *ACLChangeUserInvite) Size() (n int) { +func (m *ACLUserInvite) Size() (n int) { if m == nil { return 0 } @@ -2872,7 +2680,7 @@ func (m *ACLChangeUserInvite) Size() (n int) { return n } -func (m *ACLChangeUserJoin) Size() (n int) { +func (m *ACLUserJoin) Size() (n int) { if m == nil { return 0 } @@ -2903,7 +2711,7 @@ func (m *ACLChangeUserJoin) Size() (n int) { return n } -func (m *ACLChangeUserRemove) Size() (n int) { +func (m *ACLUserRemove) Size() (n int) { if m == nil { return 0 } @@ -2922,7 +2730,7 @@ func (m *ACLChangeUserRemove) Size() (n int) { return n } -func (m *ACLChangeReadKeyReplace) Size() (n int) { +func (m *ACLReadKeyReplace) Size() (n int) { if m == nil { return 0 } @@ -2943,7 +2751,7 @@ func (m *ACLChangeReadKeyReplace) Size() (n int) { return n } -func (m *ACLChangeUserPermissionChange) Size() (n int) { +func (m *ACLUserPermissionChange) Size() (n int) { if m == nil { return 0 } @@ -2959,7 +2767,85 @@ func (m *ACLChangeUserPermissionChange) Size() (n int) { return n } -func (m *Change) Size() (n int) { +func (m *ACLRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PrevId) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovAclchanges(uint64(m.Timestamp)) + } + return n +} + +func (m *ACLHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FirstId) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + return n +} + +func (m *RawTreeChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + return n +} + +func (m *RawTreeChangeWithId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawChange) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) + } + return n +} + +func (m *TreeChange) Size() (n int) { if m == nil { return 0 } @@ -2999,34 +2885,7 @@ func (m *Change) Size() (n int) { return n } -func (m *Record) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PrevId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - return n -} - -func (m *Header) Size() (n int) { +func (m *TreeHeader) Size() (n int) { if m == nil { return 0 } @@ -3036,16 +2895,20 @@ func (m *Header) Size() (n int) { if l > 0 { n += 1 + l + sovAclchanges(uint64(l)) } - l = len(m.AclListId) + l = len(m.AclId) if l > 0 { n += 1 + l + sovAclchanges(uint64(l)) } - l = len(m.WorkspaceId) + if m.TreeHeaderType != 0 { + n += 1 + sovAclchanges(uint64(m.TreeHeaderType)) + } + l = len(m.Identity) if l > 0 { n += 1 + l + sovAclchanges(uint64(l)) } - if m.DocType != 0 { - n += 1 + sovAclchanges(uint64(m.DocType)) + l = len(m.Data) + if l > 0 { + n += 1 + l + sovAclchanges(uint64(l)) } return n } @@ -3056,7 +2919,7 @@ func sovAclchanges(x uint64) (n int) { func sozAclchanges(x uint64) (n int) { return sovAclchanges(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *RawChange) Unmarshal(dAtA []byte) error { +func (m *RawACLRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3079,10 +2942,10 @@ func (m *RawChange) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: RawChange: wiretype end group for non-group") + return fmt.Errorf("proto: RawACLRecord: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: RawChange: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: RawACLRecord: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -3206,443 +3069,7 @@ func (m *RawChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *RawRecord) 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 ErrIntOverflowAclchanges - } - 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: RawRecord: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawRecord: 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 byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []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 ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex - case 3: - 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 ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLChange) 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 ErrIntOverflowAclchanges - } - 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: ACLChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeadIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TreeHeadIds = append(m.TreeHeadIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclHeadIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclHeadIds = append(m.AclHeadIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotBaseId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SnapshotBaseId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclData", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AclData == nil { - m.AclData = &ACLChangeACLData{} - } - if err := m.AclData.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChangesData", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ChangesData = append(m.ChangesData[:0], dAtA[iNdEx:postIndex]...) - if m.ChangesData == nil { - m.ChangesData = []byte{} - } - iNdEx = postIndex - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) - } - m.CurrentReadKeyHash = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CurrentReadKeyHash |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 7: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - m.Timestamp = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Timestamp |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 8: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { +func (m *ACLContentValue) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3700,11 +3127,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserAdd{} + v := &ACLUserAdd{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserAdd{v} + m.Value = &ACLContentValue_UserAdd{v} iNdEx = postIndex case 2: if wireType != 2 { @@ -3735,11 +3162,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserRemove{} + v := &ACLUserRemove{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserRemove{v} + m.Value = &ACLContentValue_UserRemove{v} iNdEx = postIndex case 3: if wireType != 2 { @@ -3770,11 +3197,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserPermissionChange{} + v := &ACLUserPermissionChange{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserPermissionChange{v} + m.Value = &ACLContentValue_UserPermissionChange{v} iNdEx = postIndex case 4: if wireType != 2 { @@ -3805,11 +3232,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserInvite{} + v := &ACLUserInvite{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserInvite{v} + m.Value = &ACLContentValue_UserInvite{v} iNdEx = postIndex case 5: if wireType != 2 { @@ -3840,11 +3267,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserJoin{} + v := &ACLUserJoin{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserJoin{v} + m.Value = &ACLContentValue_UserJoin{v} iNdEx = postIndex case 6: if wireType != 2 { @@ -3875,11 +3302,11 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &ACLChangeUserConfirm{} + v := &ACLUserConfirm{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &ACLChangeACLContentValueValueOfUserConfirm{v} + m.Value = &ACLContentValue_UserConfirm{v} iNdEx = postIndex default: iNdEx = preIndex @@ -3902,7 +3329,7 @@ func (m *ACLChangeACLContentValue) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { +func (m *ACLData) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -3932,42 +3359,6 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclSnapshot", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AclSnapshot == nil { - m.AclSnapshot = &ACLChangeACLSnapshot{} - } - if err := m.AclSnapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field AclContent", wireType) } @@ -3996,7 +3387,7 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AclContent = append(m.AclContent, &ACLChangeACLContentValue{}) + m.AclContent = append(m.AclContent, &ACLContentValue{}) if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4022,93 +3413,7 @@ func (m *ACLChangeACLData) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeACLSnapshot) 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 ErrIntOverflowAclchanges - } - 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: ACLSnapshot: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLSnapshot: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclState", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.AclState == nil { - m.AclState = &ACLChangeACLState{} - } - if err := m.AclState.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { +func (m *ACLState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4242,7 +3547,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.UserStates = append(m.UserStates, &ACLChangeUserState{}) + m.UserStates = append(m.UserStates, &ACLUserState{}) if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -4277,10 +3582,10 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Invites == nil { - m.Invites = make(map[string]*ACLChangeUserInvite) + m.Invites = make(map[string]*ACLUserInvite) } var mapkey string - var mapvalue *ACLChangeUserInvite + var mapvalue *ACLUserInvite for iNdEx < postIndex { entryPreIndex := iNdEx var wire uint64 @@ -4354,7 +3659,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { if postmsgIndex > l { return io.ErrUnexpectedEOF } - mapvalue = &ACLChangeUserInvite{} + mapvalue = &ACLUserInvite{} if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { return err } @@ -4397,7 +3702,7 @@ func (m *ACLChangeACLState) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { +func (m *ACLUserState) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4420,17 +3725,17 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserState: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserState: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserState: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserState: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4440,23 +3745,25 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4538,7 +3845,7 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLUserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -4584,7 +3891,7 @@ func (m *ACLChangeUserState) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { +func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4607,17 +3914,17 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserAdd: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserAdd: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserAdd: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserAdd: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4627,23 +3934,25 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4725,7 +4034,7 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLUserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -4751,7 +4060,7 @@ func (m *ACLChangeUserAdd) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { +func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4774,17 +4083,17 @@ func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserConfirm: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserConfirm: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserConfirm: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserConfirm: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4794,23 +4103,25 @@ func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4865,7 +4176,7 @@ func (m *ACLChangeUserConfirm) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { +func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -4888,10 +4199,10 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserInvite: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserInvite: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserInvite: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserInvite: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5008,7 +4319,7 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + m.Permissions |= ACLUserPermissions(b&0x7F) << shift if b < 0x80 { break } @@ -5066,7 +4377,7 @@ func (m *ACLChangeUserInvite) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { +func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5089,17 +4400,17 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserJoin: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserJoin: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserJoin: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserJoin: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5109,23 +4420,25 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -5280,7 +4593,7 @@ func (m *ACLChangeUserJoin) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { +func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5303,17 +4616,17 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserRemove: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserRemove: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserRemove: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserRemove: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5323,23 +4636,25 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { @@ -5370,7 +4685,7 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLChangeReadKeyReplace{}) + m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLReadKeyReplace{}) if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -5396,7 +4711,7 @@ func (m *ACLChangeUserRemove) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { +func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5419,17 +4734,17 @@ func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ReadKeyReplace: wiretype end group for non-group") + return fmt.Errorf("proto: ACLReadKeyReplace: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5439,23 +4754,25 @@ func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -5546,7 +4863,7 @@ func (m *ACLChangeReadKeyReplace) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { +func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5569,16 +4886,119 @@ func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: UserPermissionChange: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserPermissionChange: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: UserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipAclchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLRecord) 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 ErrIntOverflowAclchanges + } + 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: ACLRecord: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLRecord: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PrevId", wireType) + } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { @@ -5605,13 +5025,13 @@ func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.PrevId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - m.Permissions = 0 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5621,7 +5041,94 @@ func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Permissions |= ACLChangeUserPermissions(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + } + m.CurrentReadKeyHash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift if b < 0x80 { break } @@ -5647,7 +5154,7 @@ func (m *ACLChangeUserPermissionChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *Change) Unmarshal(dAtA []byte) error { +func (m *ACLHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5670,10 +5177,360 @@ func (m *Change) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Change: wiretype end group for non-group") + return fmt.Errorf("proto: ACLHeader: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Change: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + 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 ErrInvalidLengthAclchanges + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FirstId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChange) 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 ErrIntOverflowAclchanges + } + 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: RawTreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChange: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []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 ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + 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 := skipAclchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChangeWithId) 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 ErrIntOverflowAclchanges + } + 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: RawTreeChangeWithId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChangeWithId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawChange", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawChange = append(m.RawChange[:0], dAtA[iNdEx:postIndex]...) + if m.RawChange == nil { + m.RawChange = []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 ErrIntOverflowAclchanges + } + 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 ErrInvalidLengthAclchanges + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TreeChange) 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 ErrIntOverflowAclchanges + } + 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: TreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TreeChange: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -5848,7 +5705,7 @@ func (m *Change) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5858,23 +5715,25 @@ func (m *Change) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 8: if wireType != 0 { @@ -5917,7 +5776,7 @@ func (m *Change) Unmarshal(dAtA []byte) error { } return nil } -func (m *Record) Unmarshal(dAtA []byte) error { +func (m *TreeHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5940,196 +5799,10 @@ func (m *Record) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: Record: wiretype end group for non-group") + return fmt.Errorf("proto: TreeHeader: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: Record: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PrevId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.PrevId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) - } - m.CurrentReadKeyHash = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.CurrentReadKeyHash |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) - } - m.Timestamp = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Timestamp |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Header) 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 ErrIntOverflowAclchanges - } - 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: Header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: TreeHeader: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: @@ -6166,7 +5839,7 @@ func (m *Header) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclListId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field AclId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -6194,13 +5867,13 @@ func (m *Header) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.AclListId = string(dAtA[iNdEx:postIndex]) + m.AclId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field WorkspaceId", wireType) + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeHeaderType", wireType) } - var stringLen uint64 + m.TreeHeaderType = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -6210,29 +5883,50 @@ func (m *Header) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + m.TreeHeaderType |= TreeHeaderType(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.WorkspaceId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field DocType", wireType) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} } - m.DocType = 0 + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + } + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -6242,11 +5936,26 @@ func (m *Header) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.DocType |= HeaderDocType(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } + if byteLen < 0 { + return ErrInvalidLengthAclchanges + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) + if m.Data == nil { + m.Data = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAclchanges(dAtA[iNdEx:]) diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto index 76177a7c..73a3fc1f 100644 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto @@ -2,147 +2,142 @@ syntax = "proto3"; package acl; option go_package = "aclpb"; -message RawChange { +// ACL protos + +message RawACLRecord { bytes payload = 1; bytes signature = 2; - string id = 3; + string id = 3; // this field is only used on user side for convenience, it should be empty when saving to db } -message RawRecord { - bytes payload = 1; - bytes signature = 2; - string id = 3; -} - -// the element of change tree used to store and internal apply smartBlock history -message ACLChange { - repeated string treeHeadIds = 1; - repeated string aclHeadIds = 2; - string snapshotBaseId = 3; // we will only have one base snapshot for both - ACLData aclData = 4; - // the data is encoded with read key and should be read in ChangesData format - bytes changesData = 5; - uint64 currentReadKeyHash = 6; - int64 timestamp = 7; - string identity = 8; - - message ACLContentValue { - oneof value { - UserAdd userAdd = 1; - UserRemove userRemove = 2; - UserPermissionChange userPermissionChange = 3; - UserInvite userInvite = 4; - UserJoin userJoin = 5; - UserConfirm userConfirm = 6; - } - } - - message ACLData { - ACLSnapshot aclSnapshot = 1; - repeated ACLContentValue aclContent = 2; - } - - message ACLSnapshot { - // We don't need ACLState as a separate message now, because we simplified the snapshot model - ACLState aclState = 1; - } - - message ACLState { - repeated uint64 readKeyHashes = 1; - repeated UserState userStates = 2; - map invites = 3; // TODO: later - // repeated string unconfirmedUsers = 4; // TODO: later - } - - message UserState { - string identity = 1; - bytes encryptionKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know - UserPermissions permissions = 4; - bool IsConfirmed = 5; - } - - // we already know identity and encryptionKey - message UserAdd { - string identity = 1; // public signing key - bytes encryptionKey = 2; // public encryption key - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - UserPermissions permissions = 4; - } - - // TODO: this is not used as of now - message UserConfirm { // not needed for read permissions - string identity = 1; // not needed - string userAddId = 2; - } - - message UserInvite { - bytes acceptPublicKey = 1; - bytes encryptPublicKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - UserPermissions permissions = 4; - string InviteId = 5; - } - - message UserJoin { - string identity = 1; - bytes encryptionKey = 2; - bytes acceptSignature = 3; // sign acceptPublicKey - string userInviteId = 4; - repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key - } - - message UserRemove { - string identity = 1; - repeated ReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users - } - - message ReadKeyReplace { - string identity = 1; - bytes encryptionKey = 2; - bytes encryptedReadKey = 3; - } - - message UserPermissionChange { - string identity = 1; - UserPermissions permissions = 2; - } - - enum UserPermissions { - Admin = 0; - Writer = 1; - Reader = 2; - Removed = 3; +message ACLContentValue { + oneof value { + ACLUserAdd userAdd = 1; + ACLUserRemove userRemove = 2; + ACLUserPermissionChange userPermissionChange = 3; + ACLUserInvite userInvite = 4; + ACLUserJoin userJoin = 5; + ACLUserConfirm userConfirm = 6; } } -message Change { - repeated string treeHeadIds = 1; - string aclHeadId = 2; - string snapshotBaseId = 3; // we will only have one base snapshot for both - bytes changesData = 4; - uint64 currentReadKeyHash = 5; - int64 timestamp = 6; - string identity = 7; - bool isSnapshot = 8; +message ACLData { + repeated ACLContentValue aclContent = 1; } -message Record { +message ACLState { + repeated uint64 readKeyHashes = 1; + repeated ACLUserState userStates = 2; + map invites = 3; // TODO: later + // repeated string unconfirmedUsers = 4; // TODO: later +} + +message ACLUserState { + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; // all read keys that we know + ACLUserPermissions permissions = 4; + bool isConfirmed = 5; +} + +// we already know identity and encryptionKey +message ACLUserAdd { + bytes identity = 1; // public signing key + bytes encryptionKey = 2; // public encryption key + repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user + ACLUserPermissions permissions = 4; +} + +// TODO: this is not used as of now +message ACLUserConfirm { // not needed for read permissions + bytes identity = 1; // not needed + string userAddId = 2; +} + +message ACLUserInvite { + bytes acceptPublicKey = 1; + bytes encryptPublicKey = 2; + repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user + ACLUserPermissions permissions = 4; + string inviteId = 5; +} + +message ACLUserJoin { + bytes identity = 1; + bytes encryptionKey = 2; + bytes acceptSignature = 3; // sign acceptPublicKey + string userInviteId = 4; + repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key +} + +message ACLUserRemove { + bytes identity = 1; + repeated ACLReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users +} + +message ACLReadKeyReplace { + bytes identity = 1; + bytes encryptionKey = 2; + bytes encryptedReadKey = 3; +} + +message ACLUserPermissionChange { + bytes identity = 1; + ACLUserPermissions permissions = 2; +} + +enum ACLUserPermissions { + Admin = 0; + Writer = 1; + Reader = 2; + Removed = 3; +} + +message ACLRecord { string prevId = 1; - string identity = 2; + bytes identity = 2; bytes data = 3; uint64 currentReadKeyHash = 4; int64 timestamp = 5; } -message Header { +message ACLHeader { string firstId = 1; - string aclListId = 2; - string workspaceId = 3; - DocType docType = 4; - - enum DocType { - ACL = 0; - DocTree = 1; - } + bytes identity = 2; // the identity of the creator +} + +// Tree protos + +message RawTreeChange { + bytes payload = 1; + bytes signature = 2; +} + +message RawTreeChangeWithId { + bytes rawChange = 1; + string id = 2; +} + +message TreeChange { + repeated string treeHeadIds = 1; + string aclHeadId = 2; + string snapshotBaseId = 3; + bytes changesData = 4; + uint64 currentReadKeyHash = 5; + int64 timestamp = 6; + bytes identity = 7; + bool isSnapshot = 8; +} + +enum TreeHeaderType { + Object = 0; + Space = 1; +} + +message TreeHeader { + string firstId = 1; + string aclId = 2; + TreeHeaderType treeHeaderType = 3; + bytes identity = 4; + bytes data = 5; // this should be reserved for the client to add the data it needs } diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 6765ee99..d7a849fb 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -1,6 +1,7 @@ package list import ( + "bytes" "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" @@ -29,14 +30,14 @@ var ErrInvalidSignature = errors.New("signature is invalid") type UserPermissionPair struct { Identity string - Permission aclpb.ACLChangeUserPermissions + Permission aclpb.ACLUserPermissions } type ACLState struct { currentReadKeyHash uint64 userReadKeys map[uint64]*symmetric.Key - userStates map[string]*aclpb.ACLChangeUserState - userInvites map[string]*aclpb.ACLChangeUserInvite + userStates map[string]*aclpb.ACLUserState + userInvites map[string]*aclpb.ACLUserInvite signingPubKeyDecoder keys.Decoder encryptionKey encryptionkey.PrivKey @@ -55,8 +56,8 @@ func newACLStateWithIdentity( identity: identity, encryptionKey: encryptionKey, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLChangeUserState), - userInvites: make(map[string]*aclpb.ACLChangeUserInvite), + userStates: make(map[string]*aclpb.ACLUserState), + userInvites: make(map[string]*aclpb.ACLUserInvite), signingPubKeyDecoder: decoder, permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), @@ -67,8 +68,8 @@ func newACLState(decoder keys.Decoder) *ACLState { return &ACLState{ signingPubKeyDecoder: decoder, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLChangeUserState), - userInvites: make(map[string]*aclpb.ACLChangeUserInvite), + userStates: make(map[string]*aclpb.ACLUserState), + userInvites: make(map[string]*aclpb.ACLUserInvite), permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), } @@ -105,8 +106,8 @@ func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermiss return UserPermissionPair{}, ErrNoSuchUser } -func (st *ACLState) applyRecord(record *aclpb.Record) (err error) { - aclData := &aclpb.ACLChangeACLData{} +func (st *ACLState) applyRecord(record *aclpb.ACLRecord) (err error) { + aclData := &aclpb.ACLData{} err = proto.Unmarshal(record.Data, aclData) if err != nil { @@ -122,14 +123,14 @@ func (st *ACLState) applyRecord(record *aclpb.Record) (err error) { return } -func (st *ACLState) applyChangeAndUpdate(recordWrapper *Record) (err error) { +func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { var ( change = recordWrapper.Content - aclData = &aclpb.ACLChangeACLData{} + aclData = &aclpb.ACLData{} ) if recordWrapper.Model != nil { - aclData = recordWrapper.Model.(*aclpb.ACLChangeACLData) + aclData = recordWrapper.Model.(*aclpb.ACLData) } else { err = proto.Unmarshal(change.Data, aclData) if err != nil { @@ -147,7 +148,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *Record) (err error) { var permissions []UserPermissionPair for _, state := range st.userStates { permission := UserPermissionPair{ - Identity: state.Identity, + Identity: string(state.Identity), Permission: state.Permissions, } permissions = append(permissions, permission) @@ -157,7 +158,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *Record) (err error) { return nil } -func (st *ACLState) applyChangeData(changeData *aclpb.ACLChangeACLData, hash uint64, identity string) (err error) { +func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity []byte) (err error) { defer func() { if err != nil { return @@ -170,12 +171,12 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLChangeACLData, hash uin skipIdentityCheck := st.isUserJoin(changeData) || (st.currentReadKeyHash == 0 && st.isUserAdd(changeData, identity)) if !skipIdentityCheck { // we check signature when we add this to the Tree, so no need to do it here - if _, exists := st.userStates[identity]; !exists { + if _, exists := st.userStates[string(identity)]; !exists { err = ErrNoSuchUser return } - if !st.hasPermission(identity, aclpb.ACLChange_Admin) { + if !st.hasPermission(identity, aclpb.ACLUserPermissions_Admin) { err = fmt.Errorf("user %s must have admin permissions", identity) return } @@ -191,7 +192,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLChangeACLData, hash uin return nil } -func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error { +func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { switch { case ch.GetUserPermissionChange() != nil: return st.applyUserPermissionChange(ch.GetUserPermissionChange()) @@ -210,27 +211,29 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLChangeACLContentValue) error } } -func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLChangeUserPermissionChange) error { - if _, exists := st.userStates[ch.Identity]; !exists { +func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { + chIdentity := string(ch.Identity) + if _, exists := st.userStates[chIdentity]; !exists { return ErrNoSuchUser } - st.userStates[ch.Identity].Permissions = ch.Permissions + st.userStates[chIdentity].Permissions = ch.Permissions return nil } -func (st *ACLState) applyUserInvite(ch *aclpb.ACLChangeUserInvite) error { +func (st *ACLState) applyUserInvite(ch *aclpb.ACLUserInvite) error { st.userInvites[ch.InviteId] = ch return nil } -func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { +func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { invite, exists := st.userInvites[ch.UserInviteId] if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) } + chIdentity := string(ch.Identity) - if _, exists = st.userStates[ch.Identity]; exists { + if _, exists = st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } @@ -241,12 +244,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { return fmt.Errorf("public key verifying invite accepts is given in incorrect format: %v", err) } - rawSignedId, err := st.signingPubKeyDecoder.DecodeFromStringIntoBytes(ch.Identity) - if err != nil { - return fmt.Errorf("failed to decode signing identity as bytes") - } - - res, err := verificationKey.(signingkey.PubKey).Verify(rawSignedId, signature) + res, err := verificationKey.(signingkey.PubKey).Verify(ch.Identity, signature) if err != nil { return fmt.Errorf("verification returned error: %w", err) } @@ -255,7 +253,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { } // if ourselves -> we need to decrypt the read keys - if st.identity == ch.Identity { + if st.identity == chIdentity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -267,30 +265,31 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLChangeUserJoin) error { } // adding user to the list - userState := &aclpb.ACLChangeUserState{ + userState := &aclpb.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, EncryptedReadKeys: ch.EncryptedReadKeys, Permissions: invite.Permissions, IsConfirmed: true, } - st.userStates[ch.Identity] = userState + st.userStates[chIdentity] = userState return nil } -func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error { - if _, exists := st.userStates[ch.Identity]; exists { +func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { + chIdentity := string(ch.Identity) + if _, exists := st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } - st.userStates[ch.Identity] = &aclpb.ACLChangeUserState{ + st.userStates[chIdentity] = &aclpb.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, EncryptedReadKeys: ch.EncryptedReadKeys, } - if ch.Identity == st.identity { + if chIdentity == st.identity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -304,26 +303,28 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLChangeUserAdd) error { return nil } -func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error { - if ch.Identity == st.identity { +func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { + chIdentity := string(ch.Identity) + if chIdentity == st.identity { return ErrDocumentForbidden } - if _, exists := st.userStates[ch.Identity]; !exists { + if _, exists := st.userStates[chIdentity]; !exists { return ErrNoSuchUser } - delete(st.userStates, ch.Identity) + delete(st.userStates, chIdentity) for _, replace := range ch.ReadKeyReplaces { - userState, exists := st.userStates[replace.Identity] + repIdentity := string(replace.Identity) + userState, exists := st.userStates[repIdentity] if !exists { continue } userState.EncryptedReadKeys = append(userState.EncryptedReadKeys, replace.EncryptedReadKey) // if this is our identity then we have to decrypt the key - if replace.Identity == st.identity { + if repIdentity == st.identity { key, hash, err := st.decryptReadKeyAndHash(replace.EncryptedReadKey) if err != nil { return ErrFailedToDecrypt @@ -336,12 +337,13 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLChangeUserRemove) error { return nil } -func (st *ACLState) applyUserConfirm(ch *aclpb.ACLChangeUserConfirm) error { - if _, exists := st.userStates[ch.Identity]; !exists { +func (st *ACLState) applyUserConfirm(ch *aclpb.ACLUserConfirm) error { + chIdentity := string(ch.Identity) + if _, exists := st.userStates[chIdentity]; !exists { return ErrNoSuchUser } - userState := st.userStates[ch.Identity] + userState := st.userStates[chIdentity] userState.IsConfirmed = true return nil } @@ -362,8 +364,8 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChangeUserPermissions) bool { - state, exists := st.userStates[identity] +func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermissions) bool { + state, exists := st.userStates[string(identity)] if !exists { return false } @@ -371,17 +373,17 @@ func (st *ACLState) hasPermission(identity string, permission aclpb.ACLChangeUse return state.Permissions == permission } -func (st *ACLState) isUserJoin(data *aclpb.ACLChangeACLData) bool { +func (st *ACLState) isUserJoin(data *aclpb.ACLData) bool { // if we have a UserJoin, then it should always be the first one applied return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil } -func (st *ACLState) isUserAdd(data *aclpb.ACLChangeACLData, identity string) bool { +func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity []byte) bool { // if we have a UserAdd, then it should always be the first one applied userAdd := data.GetAclContent()[0].GetUserAdd() - return data.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == identity + return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0 } -func (st *ACLState) GetUserStates() map[string]*aclpb.ACLChangeUserState { +func (st *ACLState) GetUserStates() map[string]*aclpb.ACLUserState { return st.userStates } diff --git a/pkg/acl/list/aclstatebuilder.go b/pkg/acl/list/aclstatebuilder.go index f7a06f51..da79141b 100644 --- a/pkg/acl/list/aclstatebuilder.go +++ b/pkg/acl/list/aclstatebuilder.go @@ -15,7 +15,7 @@ type aclStateBuilder struct { func newACLStateBuilderWithIdentity(decoder keys.Decoder, accountData *account.AccountData) *aclStateBuilder { return &aclStateBuilder{ decoder: decoder, - identity: accountData.Identity, + identity: string(accountData.Identity), key: accountData.EncKey, } } @@ -26,7 +26,7 @@ func newACLStateBuilder(decoder keys.Decoder) *aclStateBuilder { } } -func (sb *aclStateBuilder) Build(records []*Record) (*ACLState, error) { +func (sb *aclStateBuilder) Build(records []*ACLRecord) (*ACLState, error) { var ( err error state *ACLState diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go index f5d2fa17..c6413cb0 100644 --- a/pkg/acl/list/changebuilder.go +++ b/pkg/acl/list/changebuilder.go @@ -14,7 +14,7 @@ import ( type MarshalledChange = []byte type ACLChangeBuilder interface { - UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error + UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLUserPermissions) error AddId(id string) // TODO: this is only for testing } @@ -23,7 +23,7 @@ type aclChangeBuilder struct { list ACLList acc *account.AccountData - aclData *aclpb.ACLChangeACLData + aclData *aclpb.ACLData id string readKey *symmetric.Key readKeyHash uint64 @@ -38,7 +38,7 @@ func (c *aclChangeBuilder) Init(state *ACLState, list ACLList, acc *account.Acco c.list = list c.acc = acc - c.aclData = &aclpb.ACLChangeACLData{} + c.aclData = &aclpb.ACLData{} // setting read key for further encryption etc if state.currentReadKeyHash == 0 { c.readKey, _ = symmetric.NewRandom() @@ -56,7 +56,7 @@ func (c *aclChangeBuilder) AddId(id string) { c.id = id } -func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLChangeUserPermissions) error { +func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLUserPermissions) error { var allKeys []*symmetric.Key if c.aclState.currentReadKeyHash != 0 { for _, key := range c.aclState.userReadKeys { @@ -79,10 +79,10 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey. if err != nil { return err } - ch := &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{ - UserAdd: &aclpb.ACLChangeUserAdd{ - Identity: identity, + ch := &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserAdd{ + UserAdd: &aclpb.ACLUserAdd{ + Identity: []byte(identity), EncryptionKey: rawKey, EncryptedReadKeys: encryptedKeys, Permissions: permissions, @@ -93,8 +93,8 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey. return nil } -func (c *aclChangeBuilder) BuildAndApply() (*Record, []byte, error) { - aclRecord := &aclpb.Record{ +func (c *aclChangeBuilder) BuildAndApply() (*ACLRecord, []byte, error) { + aclRecord := &aclpb.ACLRecord{ PrevId: c.list.Head().Id, CurrentReadKeyHash: c.readKeyHash, Timestamp: int64(time.Now().Nanosecond()), diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index ad924714..3cfedd06 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -13,7 +13,7 @@ import ( "sync" ) -type IterFunc = func(record *Record) (IsContinue bool) +type IterFunc = func(record *ACLRecord) (IsContinue bool) var ErrIncorrectCID = errors.New("incorrect CID") @@ -26,20 +26,20 @@ type RWLocker interface { type ACLList interface { RWLocker ID() string - Header() *aclpb.Header - Records() []*Record + Header() *aclpb.ACLHeader + Records() []*ACLRecord ACLState() *ACLState IsAfter(first string, second string) (bool, error) - Head() *Record - Get(id string) (*Record, error) + Head() *ACLRecord + Get(id string) (*ACLRecord, error) Iterate(iterFunc IterFunc) IterateFrom(startId string, iterFunc IterFunc) Close() (err error) } type aclList struct { - header *aclpb.Header - records []*Record + header *aclpb.ACLHeader + records []*ACLRecord indexes map[string]int id string @@ -84,7 +84,7 @@ func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStor if err != nil { return } - records := []*Record{record} + records := []*ACLRecord{record} for record.Content.PrevId != "" { rawRecord, err = storage.GetRawRecord(context.Background(), record.Content.PrevId) @@ -131,7 +131,7 @@ func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStor return } -func (a *aclList) Records() []*Record { +func (a *aclList) Records() []*ACLRecord { return a.records } @@ -139,7 +139,7 @@ func (a *aclList) ID() string { return a.id } -func (a *aclList) Header() *aclpb.Header { +func (a *aclList) Header() *aclpb.ACLHeader { return a.header } @@ -156,11 +156,11 @@ func (a *aclList) IsAfter(first string, second string) (bool, error) { return firstRec >= secondRec, nil } -func (a *aclList) Head() *Record { +func (a *aclList) Head() *ACLRecord { return a.records[len(a.records)-1] } -func (a *aclList) Get(id string) (*Record, error) { +func (a *aclList) Get(id string) (*ACLRecord, error) { recIdx, ok := a.indexes[id] if !ok { return nil, fmt.Errorf("no such record") @@ -192,8 +192,8 @@ func (a *aclList) Close() (err error) { return nil } -func verifyRecord(keychain *common.Keychain, rawRecord *aclpb.RawRecord, record *Record) (err error) { - identityKey, err := keychain.GetOrAdd(record.Content.Identity) +func verifyRecord(keychain *common.Keychain, rawRecord *aclpb.RawACLRecord, record *ACLRecord) (err error) { + identityKey, err := keychain.GetOrAdd(record.Identity) if err != nil { return } diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index 8ca208be..acc5f570 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -28,8 +28,8 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { assert.Equal(t, aclpb.ACLChange_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) assert.Equal(t, aclList.Head().Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) - var records []*Record - aclList.Iterate(func(record *Record) (IsContinue bool) { + var records []*ACLRecord + aclList.Iterate(func(record *ACLRecord) (IsContinue bool) { records = append(records, record) return true }) @@ -69,8 +69,8 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { _, exists := aclList.ACLState().GetUserStates()[idB] assert.Equal(t, false, exists) - var records []*Record - aclList.Iterate(func(record *Record) (IsContinue bool) { + var records []*ACLRecord + aclList.Iterate(func(record *ACLRecord) (IsContinue bool) { records = append(records, record) return true }) diff --git a/pkg/acl/list/record.go b/pkg/acl/list/record.go index 724bd94e..1cf10e59 100644 --- a/pkg/acl/list/record.go +++ b/pkg/acl/list/record.go @@ -5,30 +5,33 @@ import ( "github.com/gogo/protobuf/proto" ) -type Record struct { - Id string - Content *aclpb.Record - Model interface{} - Sign []byte +type ACLRecord struct { + Id string + Content *aclpb.ACLRecord + Identity string + Model interface{} + Sign []byte } -func NewRecord(id string, aclRecord *aclpb.Record) *Record { - return &Record{ - Id: id, - Content: aclRecord, +func NewRecord(id string, aclRecord *aclpb.ACLRecord) *ACLRecord { + return &ACLRecord{ + Id: id, + Content: aclRecord, + Identity: string(aclRecord.Identity), } } -func NewFromRawRecord(rawRec *aclpb.RawRecord) (*Record, error) { - aclRec := &aclpb.Record{} +func NewFromRawRecord(rawRec *aclpb.RawACLRecord) (*ACLRecord, error) { + aclRec := &aclpb.ACLRecord{} err := proto.Unmarshal(rawRec.Payload, aclRec) if err != nil { return nil, err } - return &Record{ - Id: rawRec.Id, - Content: aclRec, - Sign: rawRec.Signature, + return &ACLRecord{ + Id: rawRec.Id, + Content: aclRec, + Sign: rawRec.Signature, + Identity: string(aclRec.Identity), }, nil } diff --git a/pkg/acl/storage/inmemory.go b/pkg/acl/storage/inmemory.go index 16879c38..7f6af367 100644 --- a/pkg/acl/storage/inmemory.go +++ b/pkg/acl/storage/inmemory.go @@ -8,8 +8,8 @@ import ( ) type inMemoryACLListStorage struct { - header *aclpb.Header - records []*aclpb.RawRecord + header *aclpb.ACLHeader + records []*aclpb.RawACLRecord id string @@ -18,8 +18,8 @@ type inMemoryACLListStorage struct { func NewInMemoryACLListStorage( id string, - header *aclpb.Header, - records []*aclpb.RawRecord) (ListStorage, error) { + header *aclpb.ACLHeader, + records []*aclpb.RawACLRecord) (ListStorage, error) { return &inMemoryACLListStorage{ id: id, header: header, @@ -28,19 +28,19 @@ func NewInMemoryACLListStorage( }, nil } -func (i *inMemoryACLListStorage) Header() (*aclpb.Header, error) { +func (i *inMemoryACLListStorage) Header() (*aclpb.ACLHeader, error) { i.RLock() defer i.RUnlock() return i.header, nil } -func (i *inMemoryACLListStorage) Head() (*aclpb.RawRecord, error) { +func (i *inMemoryACLListStorage) Head() (*aclpb.RawACLRecord, error) { i.RLock() defer i.RUnlock() return i.records[len(i.records)-1], nil } -func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclpb.RawRecord, error) { +func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) { i.RLock() defer i.RUnlock() for _, rec := range i.records { @@ -51,7 +51,7 @@ func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (* return nil, fmt.Errorf("no such record") } -func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclpb.RawRecord) error { +func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error { panic("implement me") } @@ -63,19 +63,19 @@ func (i *inMemoryACLListStorage) ID() (string, error) { type inMemoryTreeStorage struct { id string - header *aclpb.Header + header *aclpb.TreeHeader heads []string - changes map[string]*aclpb.RawChange + changes map[string]*aclpb.RawTreeChangeWithId sync.RWMutex } func NewInMemoryTreeStorage( treeId string, - header *aclpb.Header, + header *aclpb.TreeHeader, heads []string, - changes []*aclpb.RawChange) (TreeStorage, error) { - allChanges := make(map[string]*aclpb.RawChange) + changes []*aclpb.RawTreeChangeWithId) (TreeStorage, error) { + allChanges := make(map[string]*aclpb.RawTreeChangeWithId) for _, ch := range changes { allChanges[ch.Id] = ch } @@ -95,7 +95,7 @@ func (t *inMemoryTreeStorage) ID() (string, error) { return t.id, nil } -func (t *inMemoryTreeStorage) Header() (*aclpb.Header, error) { +func (t *inMemoryTreeStorage) Header() (*aclpb.TreeHeader, error) { t.RLock() defer t.RUnlock() return t.header, nil @@ -118,7 +118,7 @@ func (t *inMemoryTreeStorage) SetHeads(heads []string) error { return nil } -func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawChange) error { +func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawTreeChangeWithId) error { t.Lock() defer t.Unlock() // TODO: better to do deep copy @@ -126,7 +126,7 @@ func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawChange) error { return nil } -func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*aclpb.RawChange, error) { +func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*aclpb.RawTreeChangeWithId, error) { t.RLock() defer t.RUnlock() if res, exists := t.changes[changeId]; exists { diff --git a/pkg/acl/storage/liststorage.go b/pkg/acl/storage/liststorage.go index ff2ff426..90cb9cdc 100644 --- a/pkg/acl/storage/liststorage.go +++ b/pkg/acl/storage/liststorage.go @@ -7,8 +7,8 @@ import ( type ListStorage interface { Storage - Head() (*aclpb.RawRecord, error) + Head() (*aclpb.RawACLRecord, error) - GetRawRecord(ctx context.Context, id string) (*aclpb.RawRecord, error) - AddRawRecord(ctx context.Context, rec *aclpb.RawRecord) error + GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) + AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error } diff --git a/pkg/acl/storage/provider.go b/pkg/acl/storage/provider.go index 12d47d00..984b21c4 100644 --- a/pkg/acl/storage/provider.go +++ b/pkg/acl/storage/provider.go @@ -9,15 +9,15 @@ var ErrUnknownTreeId = errors.New("tree does not exist") type TreeStorageCreatePayload struct { TreeId string - Header *aclpb.Header - Changes []*aclpb.RawChange + Header *aclpb.TreeHeader + Changes []*aclpb.RawTreeChangeWithId Heads []string } type ACLListStorageCreatePayload struct { ListId string - Header *aclpb.Header - Records []*aclpb.RawRecord + Header *aclpb.ACLHeader + Records []*aclpb.RawACLRecord } type Provider interface { diff --git a/pkg/acl/storage/treestorage.go b/pkg/acl/storage/treestorage.go index d2cf7eec..3a5d8866 100644 --- a/pkg/acl/storage/treestorage.go +++ b/pkg/acl/storage/treestorage.go @@ -10,8 +10,8 @@ type TreeStorage interface { Heads() ([]string, error) SetHeads(heads []string) error - AddRawChange(change *aclpb.RawChange) error - GetRawChange(ctx context.Context, recordID string) (*aclpb.RawChange, error) + AddRawChange(change *aclpb.RawTreeChangeWithId) error + GetRawChange(ctx context.Context, recordID string) (*aclpb.RawTreeChangeWithId, error) } type TreeStorageCreatorFunc = func(payload TreeStorageCreatePayload) (TreeStorage, error) diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index 324f8733..4dc5086e 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -19,8 +19,8 @@ import ( type ACLListStorageBuilder struct { aclList string - records []*aclpb.Record - rawRecords []*aclpb.RawRecord + records []*aclpb.ACLRecord + rawRecords []*aclpb.RawACLRecord indexes map[string]int keychain *Keychain header *aclpb.Header @@ -29,7 +29,7 @@ type ACLListStorageBuilder struct { func NewACLListStorageBuilder(keychain *Keychain) *ACLListStorageBuilder { return &ACLListStorageBuilder{ - records: make([]*aclpb.Record, 0), + records: make([]*aclpb.ACLRecord, 0), indexes: make(map[string]int), keychain: keychain, } @@ -58,7 +58,7 @@ func NewACLListStorageBuilderFromFile(file string) (*ACLListStorageBuilder, erro return tb, nil } -func (t *ACLListStorageBuilder) createRaw(rec *aclpb.Record) *aclpb.RawRecord { +func (t *ACLListStorageBuilder) createRaw(rec *aclpb.ACLRecord) *aclpb.RawACLRecord { aclMarshaled, err := proto.Marshal(rec) if err != nil { panic("should be able to marshal final acl message!") @@ -71,18 +71,18 @@ func (t *ACLListStorageBuilder) createRaw(rec *aclpb.Record) *aclpb.RawRecord { id, _ := cid.NewCIDFromBytes(aclMarshaled) - return &aclpb.RawRecord{ + return &aclpb.RawACLRecord{ Payload: aclMarshaled, Signature: signature, Id: id, } } -func (t *ACLListStorageBuilder) getRecord(idx int) *aclpb.RawRecord { +func (t *ACLListStorageBuilder) getRecord(idx int) *aclpb.RawACLRecord { return t.rawRecords[idx] } -func (t *ACLListStorageBuilder) Head() (*aclpb.RawRecord, error) { +func (t *ACLListStorageBuilder) Head() (*aclpb.RawACLRecord, error) { return t.getRecord(len(t.records) - 1), nil } @@ -90,7 +90,7 @@ func (t *ACLListStorageBuilder) Header() (*aclpb.Header, error) { return t.header, nil } -func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclpb.RawRecord, error) { +func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) { recIdx, ok := t.indexes[id] if !ok { return nil, fmt.Errorf("no such record") @@ -98,7 +98,7 @@ func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*a return t.getRecord(recIdx), nil } -func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclpb.RawRecord) error { +func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error { panic("implement me") } @@ -106,7 +106,7 @@ func (t *ACLListStorageBuilder) ID() (string, error) { return t.id, nil } -func (t *ACLListStorageBuilder) GetRawRecords() []*aclpb.RawRecord { +func (t *ACLListStorageBuilder) GetRawRecords() []*aclpb.RawACLRecord { return t.rawRecords } @@ -132,7 +132,7 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) { t.createHeaderAndId() } -func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.Record { +func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.ACLRecord { k := t.keychain.GetKey(rec.ReadKey).(*SymKey) var aclChangeContents []*aclpb.ACLChangeACLContentValue for _, ch := range rec.AclChanges { @@ -144,7 +144,7 @@ func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.R } bytes, _ := data.Marshal() - return &aclpb.Record{ + return &aclpb.ACLRecord{ PrevId: prevId, Identity: t.keychain.GetIdentity(rec.Identity), Data: bytes, @@ -163,7 +163,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{ - UserAdd: &aclpb.ACLChangeUserAdd{ + UserAdd: &aclpb.ACLUserPermissionsAdd{ Identity: t.keychain.GetIdentity(add.Identity), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), @@ -187,7 +187,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserJoin{ - UserJoin: &aclpb.ACLChangeUserJoin{ + UserJoin: &aclpb.ACLUserPermissionsJoin{ Identity: t.keychain.GetIdentity(join.Identity), EncryptionKey: rawKey, AcceptSignature: signature, @@ -205,7 +205,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserInvite{ - UserInvite: &aclpb.ACLChangeUserInvite{ + UserInvite: &aclpb.ACLUserPermissionsInvite{ AcceptPublicKey: rawAcceptKey, EncryptPublicKey: rawEncKey, EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), @@ -219,7 +219,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserConfirm{ - UserConfirm: &aclpb.ACLChangeUserConfirm{ + UserConfirm: &aclpb.ACLUserPermissionsConfirm{ Identity: t.keychain.GetIdentity(confirm.Identity), UserAddId: confirm.UserAddId, }, @@ -230,7 +230,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserPermissionChange{ - UserPermissionChange: &aclpb.ACLChangeUserPermissionChange{ + UserPermissionChange: &aclpb.ACLUserPermissionsPermissionChange{ Identity: t.keychain.GetIdentity(permissionChange.Identity), Permissions: t.convertPermission(permissionChange.Permission), }, @@ -259,7 +259,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLChangeACLContentValue{ Value: &aclpb.ACLChangeACLContentValueValueOfUserRemove{ - UserRemove: &aclpb.ACLChangeUserRemove{ + UserRemove: &aclpb.ACLUserPermissionsRemove{ Identity: t.keychain.GetIdentity(remove.RemovedIdentity), ReadKeyReplaces: replaces, }, @@ -286,7 +286,7 @@ func (t *ACLListStorageBuilder) encryptReadKeys(keys []string, encKey encryption return } -func (t *ACLListStorageBuilder) convertPermission(perm string) aclpb.ACLChangeUserPermissions { +func (t *ACLListStorageBuilder) convertPermission(perm string) aclpb.ACLUserPermissions { switch perm { case "admin": return aclpb.ACLChange_Admin @@ -299,7 +299,7 @@ func (t *ACLListStorageBuilder) convertPermission(perm string) aclpb.ACLChangeUs } } -func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclpb.Record, id string) error) (err error) { +func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclpb.ACLRecord, id string) error) (err error) { for i := len(t.records) - 1; i >= 0; i-- { err = f(t.records[i], t.rawRecords[i].Id) if err != nil { diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go index b637827f..9c7bf581 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go @@ -33,7 +33,7 @@ func (t *ACLListStorageBuilder) Graph() (string, error) { graph.SetDir(true) var nodes = make(map[string]struct{}) - var addNodes = func(r *aclpb.Record, id string) error { + var addNodes = func(r *aclpb.ACLRecord, id string) error { style := "solid" var chSymbs []string @@ -92,7 +92,7 @@ func (t *ACLListStorageBuilder) Graph() (string, error) { return nil } - var addLinks = func(r *aclpb.Record, id string) error { + var addLinks = func(r *aclpb.ACLRecord, id string) error { if r.PrevId == "" { return nil } diff --git a/pkg/acl/testutils/testchanges/proto/test.pb.go b/pkg/acl/testutils/testchanges/proto/test.pb.go index 53be5aba..e8e43c54 100644 --- a/pkg/acl/testutils/testchanges/proto/test.pb.go +++ b/pkg/acl/testutils/testchanges/proto/test.pb.go @@ -58,24 +58,24 @@ func (m *PlainTextChange) XXX_DiscardUnknown() { var xxx_messageInfo_PlainTextChange proto.InternalMessageInfo -type PlainTextChangeContent struct { +type PlainTextChange_Content struct { // Types that are valid to be assigned to Value: - // *PlainTextChangeContentValueOfTextAppend - Value IsPlainTextChangeContentValue `protobuf_oneof:"value"` + // *PlainTextChange_Content_TextAppend + Value isPlainTextChange_Content_Value `protobuf_oneof:"value"` } -func (m *PlainTextChangeContent) Reset() { *m = PlainTextChangeContent{} } -func (m *PlainTextChangeContent) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeContent) ProtoMessage() {} -func (*PlainTextChangeContent) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Content) Reset() { *m = PlainTextChange_Content{} } +func (m *PlainTextChange_Content) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Content) ProtoMessage() {} +func (*PlainTextChange_Content) Descriptor() ([]byte, []int) { return fileDescriptor_37f33c266ada4318, []int{0, 0} } -func (m *PlainTextChangeContent) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Content) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Content) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeContent.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Content.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -85,67 +85,67 @@ func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]by return b[:n], nil } } -func (m *PlainTextChangeContent) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeContent.Merge(m, src) +func (m *PlainTextChange_Content) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Content.Merge(m, src) } -func (m *PlainTextChangeContent) XXX_Size() int { +func (m *PlainTextChange_Content) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeContent) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeContent.DiscardUnknown(m) +func (m *PlainTextChange_Content) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Content.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeContent proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Content proto.InternalMessageInfo -type IsPlainTextChangeContentValue interface { - IsPlainTextChangeContentValue() +type isPlainTextChange_Content_Value interface { + isPlainTextChange_Content_Value() MarshalTo([]byte) (int, error) Size() int } -type PlainTextChangeContentValueOfTextAppend struct { - TextAppend *PlainTextChangeTextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"` +type PlainTextChange_Content_TextAppend struct { + TextAppend *PlainTextChange_TextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"` } -func (*PlainTextChangeContentValueOfTextAppend) IsPlainTextChangeContentValue() {} +func (*PlainTextChange_Content_TextAppend) isPlainTextChange_Content_Value() {} -func (m *PlainTextChangeContent) GetValue() IsPlainTextChangeContentValue { +func (m *PlainTextChange_Content) GetValue() isPlainTextChange_Content_Value { if m != nil { return m.Value } return nil } -func (m *PlainTextChangeContent) GetTextAppend() *PlainTextChangeTextAppend { - if x, ok := m.GetValue().(*PlainTextChangeContentValueOfTextAppend); ok { +func (m *PlainTextChange_Content) GetTextAppend() *PlainTextChange_TextAppend { + if x, ok := m.GetValue().(*PlainTextChange_Content_TextAppend); ok { return x.TextAppend } return nil } // XXX_OneofWrappers is for the internal use of the proto package. -func (*PlainTextChangeContent) XXX_OneofWrappers() []interface{} { +func (*PlainTextChange_Content) XXX_OneofWrappers() []interface{} { return []interface{}{ - (*PlainTextChangeContentValueOfTextAppend)(nil), + (*PlainTextChange_Content_TextAppend)(nil), } } -type PlainTextChangeTextAppend struct { +type PlainTextChange_TextAppend struct { Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` } -func (m *PlainTextChangeTextAppend) Reset() { *m = PlainTextChangeTextAppend{} } -func (m *PlainTextChangeTextAppend) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeTextAppend) ProtoMessage() {} -func (*PlainTextChangeTextAppend) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_TextAppend) Reset() { *m = PlainTextChange_TextAppend{} } +func (m *PlainTextChange_TextAppend) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_TextAppend) ProtoMessage() {} +func (*PlainTextChange_TextAppend) Descriptor() ([]byte, []int) { return fileDescriptor_37f33c266ada4318, []int{0, 1} } -func (m *PlainTextChangeTextAppend) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_TextAppend) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_TextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeTextAppend.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_TextAppend.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -155,41 +155,41 @@ func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([ return b[:n], nil } } -func (m *PlainTextChangeTextAppend) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeTextAppend.Merge(m, src) +func (m *PlainTextChange_TextAppend) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_TextAppend.Merge(m, src) } -func (m *PlainTextChangeTextAppend) XXX_Size() int { +func (m *PlainTextChange_TextAppend) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeTextAppend) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeTextAppend.DiscardUnknown(m) +func (m *PlainTextChange_TextAppend) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_TextAppend.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeTextAppend proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_TextAppend proto.InternalMessageInfo -func (m *PlainTextChangeTextAppend) GetText() string { +func (m *PlainTextChange_TextAppend) GetText() string { if m != nil { return m.Text } return "" } -type PlainTextChangeSnapshot struct { +type PlainTextChange_Snapshot struct { Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` } -func (m *PlainTextChangeSnapshot) Reset() { *m = PlainTextChangeSnapshot{} } -func (m *PlainTextChangeSnapshot) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeSnapshot) ProtoMessage() {} -func (*PlainTextChangeSnapshot) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Snapshot) Reset() { *m = PlainTextChange_Snapshot{} } +func (m *PlainTextChange_Snapshot) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Snapshot) ProtoMessage() {} +func (*PlainTextChange_Snapshot) Descriptor() ([]byte, []int) { return fileDescriptor_37f33c266ada4318, []int{0, 2} } -func (m *PlainTextChangeSnapshot) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Snapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Snapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeSnapshot.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Snapshot.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -199,42 +199,42 @@ func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]b return b[:n], nil } } -func (m *PlainTextChangeSnapshot) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeSnapshot.Merge(m, src) +func (m *PlainTextChange_Snapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Snapshot.Merge(m, src) } -func (m *PlainTextChangeSnapshot) XXX_Size() int { +func (m *PlainTextChange_Snapshot) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeSnapshot) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeSnapshot.DiscardUnknown(m) +func (m *PlainTextChange_Snapshot) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Snapshot.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeSnapshot proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Snapshot proto.InternalMessageInfo -func (m *PlainTextChangeSnapshot) GetText() string { +func (m *PlainTextChange_Snapshot) GetText() string { if m != nil { return m.Text } return "" } -type PlainTextChangeData struct { - Content []*PlainTextChangeContent `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` - Snapshot *PlainTextChangeSnapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` +type PlainTextChange_Data struct { + Content []*PlainTextChange_Content `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` + Snapshot *PlainTextChange_Snapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` } -func (m *PlainTextChangeData) Reset() { *m = PlainTextChangeData{} } -func (m *PlainTextChangeData) String() string { return proto.CompactTextString(m) } -func (*PlainTextChangeData) ProtoMessage() {} -func (*PlainTextChangeData) Descriptor() ([]byte, []int) { +func (m *PlainTextChange_Data) Reset() { *m = PlainTextChange_Data{} } +func (m *PlainTextChange_Data) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange_Data) ProtoMessage() {} +func (*PlainTextChange_Data) Descriptor() ([]byte, []int) { return fileDescriptor_37f33c266ada4318, []int{0, 3} } -func (m *PlainTextChangeData) XXX_Unmarshal(b []byte) error { +func (m *PlainTextChange_Data) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *PlainTextChange_Data) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_PlainTextChangeData.Marshal(b, m, deterministic) + return xxx_messageInfo_PlainTextChange_Data.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -244,26 +244,26 @@ func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, return b[:n], nil } } -func (m *PlainTextChangeData) XXX_Merge(src proto.Message) { - xxx_messageInfo_PlainTextChangeData.Merge(m, src) +func (m *PlainTextChange_Data) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange_Data.Merge(m, src) } -func (m *PlainTextChangeData) XXX_Size() int { +func (m *PlainTextChange_Data) XXX_Size() int { return m.Size() } -func (m *PlainTextChangeData) XXX_DiscardUnknown() { - xxx_messageInfo_PlainTextChangeData.DiscardUnknown(m) +func (m *PlainTextChange_Data) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange_Data.DiscardUnknown(m) } -var xxx_messageInfo_PlainTextChangeData proto.InternalMessageInfo +var xxx_messageInfo_PlainTextChange_Data proto.InternalMessageInfo -func (m *PlainTextChangeData) GetContent() []*PlainTextChangeContent { +func (m *PlainTextChange_Data) GetContent() []*PlainTextChange_Content { if m != nil { return m.Content } return nil } -func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot { +func (m *PlainTextChange_Data) GetSnapshot() *PlainTextChange_Snapshot { if m != nil { return m.Snapshot } @@ -272,10 +272,10 @@ func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot { func init() { proto.RegisterType((*PlainTextChange)(nil), "anytype.PlainTextChange") - proto.RegisterType((*PlainTextChangeContent)(nil), "anytype.PlainTextChange.Content") - proto.RegisterType((*PlainTextChangeTextAppend)(nil), "anytype.PlainTextChange.TextAppend") - proto.RegisterType((*PlainTextChangeSnapshot)(nil), "anytype.PlainTextChange.Snapshot") - proto.RegisterType((*PlainTextChangeData)(nil), "anytype.PlainTextChange.Data") + proto.RegisterType((*PlainTextChange_Content)(nil), "anytype.PlainTextChange.Content") + proto.RegisterType((*PlainTextChange_TextAppend)(nil), "anytype.PlainTextChange.TextAppend") + proto.RegisterType((*PlainTextChange_Snapshot)(nil), "anytype.PlainTextChange.Snapshot") + proto.RegisterType((*PlainTextChange_Data)(nil), "anytype.PlainTextChange.Data") } func init() { @@ -326,7 +326,7 @@ func (m *PlainTextChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Content) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -336,12 +336,12 @@ func (m *PlainTextChangeContent) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeContent) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -358,12 +358,12 @@ func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *PlainTextChangeContentValueOfTextAppend) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content_TextAppend) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Content_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) if m.TextAppend != nil { { @@ -379,7 +379,7 @@ func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } -func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_TextAppend) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -389,12 +389,12 @@ func (m *PlainTextChangeTextAppend) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeTextAppend) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_TextAppend) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_TextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -409,7 +409,7 @@ func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, erro return len(dAtA) - i, nil } -func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Snapshot) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -419,12 +419,12 @@ func (m *PlainTextChangeSnapshot) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeSnapshot) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Snapshot) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Snapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -439,7 +439,7 @@ func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } -func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) { +func (m *PlainTextChange_Data) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -449,12 +449,12 @@ func (m *PlainTextChangeData) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *PlainTextChangeData) MarshalTo(dAtA []byte) (int, error) { +func (m *PlainTextChange_Data) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *PlainTextChange_Data) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -508,7 +508,7 @@ func (m *PlainTextChange) Size() (n int) { return n } -func (m *PlainTextChangeContent) Size() (n int) { +func (m *PlainTextChange_Content) Size() (n int) { if m == nil { return 0 } @@ -520,7 +520,7 @@ func (m *PlainTextChangeContent) Size() (n int) { return n } -func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) { +func (m *PlainTextChange_Content_TextAppend) Size() (n int) { if m == nil { return 0 } @@ -532,7 +532,7 @@ func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) { } return n } -func (m *PlainTextChangeTextAppend) Size() (n int) { +func (m *PlainTextChange_TextAppend) Size() (n int) { if m == nil { return 0 } @@ -545,7 +545,7 @@ func (m *PlainTextChangeTextAppend) Size() (n int) { return n } -func (m *PlainTextChangeSnapshot) Size() (n int) { +func (m *PlainTextChange_Snapshot) Size() (n int) { if m == nil { return 0 } @@ -558,7 +558,7 @@ func (m *PlainTextChangeSnapshot) Size() (n int) { return n } -func (m *PlainTextChangeData) Size() (n int) { +func (m *PlainTextChange_Data) Size() (n int) { if m == nil { return 0 } @@ -633,7 +633,7 @@ func (m *PlainTextChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Content) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -691,11 +691,11 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - v := &PlainTextChangeTextAppend{} + v := &PlainTextChange_TextAppend{} if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } - m.Value = &PlainTextChangeContentValueOfTextAppend{v} + m.Value = &PlainTextChange_Content_TextAppend{v} iNdEx = postIndex default: iNdEx = preIndex @@ -718,7 +718,7 @@ func (m *PlainTextChangeContent) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_TextAppend) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -800,7 +800,7 @@ func (m *PlainTextChangeTextAppend) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Snapshot) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -882,7 +882,7 @@ func (m *PlainTextChangeSnapshot) Unmarshal(dAtA []byte) error { } return nil } -func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { +func (m *PlainTextChange_Data) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -940,7 +940,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Content = append(m.Content, &PlainTextChangeContent{}) + m.Content = append(m.Content, &PlainTextChange_Content{}) if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -975,7 +975,7 @@ func (m *PlainTextChangeData) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Snapshot == nil { - m.Snapshot = &PlainTextChangeSnapshot{} + m.Snapshot = &PlainTextChange_Snapshot{} } if err := m.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err diff --git a/pkg/acl/tree/change.go b/pkg/acl/tree/change.go index 514cf862..cefc9327 100644 --- a/pkg/acl/tree/change.go +++ b/pkg/acl/tree/change.go @@ -16,7 +16,7 @@ var ( type ChangeContent struct { ChangesData proto.Marshaler - ACLData *aclpb.ACLChangeACLData + ACLData *aclpb.ACLData Id string // TODO: this is just for testing, because id should be created automatically from content } @@ -34,8 +34,9 @@ type Change struct { visited bool branchesFinished bool - Content *aclpb.Change - Sign []byte + Content *aclpb.TreeChange + Identity string + Sign []byte } func (ch *Change) ProtoChange() proto.Marshaler { @@ -56,7 +57,7 @@ func (ch *Change) DecryptContents(key *symmetric.Key) error { return nil } -func NewChange(id string, ch *aclpb.Change, signature []byte) *Change { +func NewChange(id string, ch *aclpb.TreeChange, signature []byte) *Change { return &Change{ Next: nil, PreviousIds: ch.TreeHeadIds, @@ -64,6 +65,7 @@ func NewChange(id string, ch *aclpb.Change, signature []byte) *Change { Content: ch, SnapshotId: ch.SnapshotBaseId, IsSnapshot: ch.IsSnapshot, + Identity: string(ch.Identity), Sign: signature, } } diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index edaa93a2..3a2f0701 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -1,6 +1,7 @@ package tree import ( + "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" @@ -10,25 +11,24 @@ import ( "time" ) -const componentBuilder = "tree.changebuilder" +var ErrEmptyChange = errors.New("change payload should not be empty") type BuilderContent struct { treeHeadIds []string aclHeadId string snapshotBaseId string currentReadKeyHash uint64 - identity string + identity []byte isSnapshot bool signingKey signingkey.PrivKey readKey *symmetric.Key - content proto.Marshaler + content []byte } type ChangeBuilder interface { - ConvertFromRaw(rawChange *aclpb.RawChange) (ch *Change, err error) - ConvertFromRawAndVerify(rawChange *aclpb.RawChange) (ch *Change, err error) - BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawChange, err error) - BuildRaw(ch *Change) (*aclpb.RawChange, error) + ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) + BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) + BuildRaw(ch *Change) (*aclpb.RawTreeChangeWithId, error) } type changeBuilder struct { @@ -39,49 +39,55 @@ func newChangeBuilder(keys *common.Keychain) ChangeBuilder { return &changeBuilder{keys: keys} } -func (c *changeBuilder) ConvertFromRaw(rawChange *aclpb.RawChange) (ch *Change, err error) { - unmarshalled := &aclpb.Change{} - err = proto.Unmarshal(rawChange.Payload, unmarshalled) - if err != nil { - return nil, err +func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { + if rawIdChange.GetRawChange() == nil { + err = ErrEmptyChange + return } - ch = NewChange(rawChange.Id, unmarshalled, rawChange.Signature) + if verify { + // verifying ID + if !cid.VerifyCID(rawIdChange.RawChange, rawIdChange.Id) { + err = ErrIncorrectCID + return + } + } + + raw := &aclpb.RawTreeChange{} + err = proto.Unmarshal(rawIdChange.GetRawChange(), raw) + if err != nil { + return + } + + if verify { + identityKey, err := c.keys.GetOrAdd(ch.Identity) + if err != nil { + return + } + + // verifying signature + res, err := identityKey.Verify(raw.Payload, raw.Signature) + if err != nil { + return + } + if !res { + err = ErrIncorrectSignature + return + } + } + + unmarshalled := &aclpb.TreeChange{} + err = proto.Unmarshal(raw.Payload, unmarshalled) + if err != nil { + return + } + + ch = NewChange(rawIdChange.Id, unmarshalled, raw.Signature) return } -func (c *changeBuilder) ConvertFromRawAndVerify(rawChange *aclpb.RawChange) (ch *Change, err error) { - unmarshalled := &aclpb.Change{} - ch, err = c.ConvertFromRaw(rawChange) - if err != nil { - return nil, err - } - - identityKey, err := c.keys.GetOrAdd(unmarshalled.Identity) - if err != nil { - return - } - - // verifying signature - res, err := identityKey.Verify(rawChange.Payload, rawChange.Signature) - if err != nil { - return - } - if !res { - err = ErrIncorrectSignature - return - } - - // verifying ID - if !cid.VerifyCID(rawChange.Payload, rawChange.Id) { - err = ErrIncorrectCID - } - - return -} - -func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawChange, err error) { - aclChange := &aclpb.Change{ +func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdChange *aclpb.RawTreeChangeWithId, err error) { + change := &aclpb.TreeChange{ TreeHeadIds: payload.treeHeadIds, AclHeadId: payload.aclHeadId, SnapshotBaseId: payload.snapshotBaseId, @@ -90,53 +96,65 @@ func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *a Identity: payload.identity, IsSnapshot: payload.isSnapshot, } - marshalledData, err := payload.content.Marshal() + + encrypted, err := payload.readKey.Encrypt(payload.content) + if err != nil { + return + } + change.ChangesData = encrypted + + marshalledChange, err := proto.Marshal(change) if err != nil { return } - encrypted, err := payload.readKey.Encrypt(marshalledData) - if err != nil { - return - } - aclChange.ChangesData = encrypted - - fullMarshalledChange, err := proto.Marshal(aclChange) + signature, err := payload.signingKey.Sign(marshalledChange) if err != nil { return } - signature, err := payload.signingKey.Sign(fullMarshalledChange) + raw := &aclpb.RawTreeChange{ + Payload: marshalledChange, + Signature: signature, + } + + marshalledRawChange, err := proto.Marshal(raw) if err != nil { return } - id, err := cid.NewCIDFromBytes(fullMarshalledChange) + id, err := cid.NewCIDFromBytes(marshalledRawChange) if err != nil { return } - ch = NewChange(id, aclChange, signature) + ch = NewChange(id, change, signature) ch.ParsedModel = payload.content - raw = &aclpb.RawChange{ - Payload: fullMarshalledChange, - Signature: signature, + rawIdChange = &aclpb.RawTreeChangeWithId{ + RawChange: marshalledRawChange, Id: id, } return } -func (c *changeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawChange, err error) { +func (c *changeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { var marshalled []byte marshalled, err = ch.Content.Marshal() if err != nil { return } - raw = &aclpb.RawChange{ + marshalledRawChange, err := proto.Marshal(&aclpb.RawTreeChange{ Payload: marshalled, - Signature: ch.Signature(), + Signature: ch.Sign, + }) + if err != nil { + return + } + + raw = &aclpb.RawTreeChangeWithId{ + RawChange: marshalledRawChange, Id: ch.Id, } return diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index 2f582c33..1dfac831 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -48,7 +48,7 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c return } - if perm.Permission != aclpb.ACLChange_Writer && perm.Permission != aclpb.ACLChange_Admin { + if perm.Permission != aclpb.ACLUserPermissions_Writer && perm.Permission != aclpb.ACLUserPermissions_Admin { err = list.ErrInsufficientPermissions return } diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 114e61ba..c6ffeca7 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -8,8 +8,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" - "go.uber.org/zap" "sync" ) @@ -34,7 +32,7 @@ type AddResultSummary int type AddResult struct { OldHeads []string Heads []string - Added []*aclpb.RawChange + Added []*aclpb.RawTreeChangeWithId Mode Mode } @@ -46,7 +44,7 @@ type ObjectTree interface { RWLocker ID() string - Header() *aclpb.Header + Header() *aclpb.TreeHeader Heads() []string Root() *Change HasChange(string) bool @@ -55,13 +53,13 @@ type ObjectTree interface { IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error SnapshotPath() []string - ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawChange, error) + ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) Storage() storage.TreeStorage DebugDump() (string, error) - AddContent(ctx context.Context, content SignableChangeContent) (*aclpb.RawChange, error) - AddRawChanges(ctx context.Context, changes ...*aclpb.RawChange) (AddResult, error) + AddContent(ctx context.Context, content SignableChangeContent) (*aclpb.RawTreeChangeWithId, error) + AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error) Close() error } @@ -76,13 +74,13 @@ type objectTree struct { aclList list.ACLList id string - header *aclpb.Header + header *aclpb.TreeHeader tree *Tree keys map[uint64]*symmetric.Key // buffers - difSnapshotBuf []*aclpb.RawChange + difSnapshotBuf []*aclpb.RawTreeChangeWithId tmpChangesBuf []*Change newSnapshotsBuf []*Change notSeenIdxBuf []int @@ -121,65 +119,6 @@ func defaultObjectTreeDeps( } } -func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { - objTree := &objectTree{ - treeStorage: deps.treeStorage, - updateListener: deps.updateListener, - treeBuilder: deps.treeBuilder, - validator: deps.validator, - aclList: deps.aclList, - changeBuilder: deps.changeBuilder, - rawChangeLoader: deps.rawChangeLoader, - tree: nil, - keys: make(map[uint64]*symmetric.Key), - tmpChangesBuf: make([]*Change, 0, 10), - difSnapshotBuf: make([]*aclpb.RawChange, 0, 10), - notSeenIdxBuf: make([]int, 0, 10), - newSnapshotsBuf: make([]*Change, 0, 10), - } - - err := objTree.rebuildFromStorage(nil) - if err != nil { - return nil, err - } - storageHeads, err := objTree.treeStorage.Heads() - if err != nil { - return nil, err - } - - // comparing rebuilt heads with heads in storage - // in theory it can happen that we didn't set heads because the process has crashed - // therefore we want to set them later - if !slice.UnsortedEquals(storageHeads, objTree.tree.Heads()) { - log.With(zap.Strings("storage", storageHeads), zap.Strings("rebuilt", objTree.tree.Heads())). - Errorf("the heads in storage and objTree are different") - err = objTree.treeStorage.SetHeads(objTree.tree.Heads()) - if err != nil { - return nil, err - } - } - - objTree.id, err = objTree.treeStorage.ID() - if err != nil { - return nil, err - } - objTree.header, err = objTree.treeStorage.Header() - if err != nil { - return nil, err - } - - if objTree.updateListener != nil { - objTree.updateListener.Rebuild(objTree) - } - - return objTree, nil -} - -func BuildObjectTree(treeStorage storage.TreeStorage, listener ObjectTreeUpdateListener, aclList list.ACLList) (ObjectTree, error) { - deps := defaultObjectTreeDeps(treeStorage, listener, aclList) - return buildObjectTree(deps) -} - func (ot *objectTree) rebuildFromStorage(newChanges []*Change) (err error) { ot.treeBuilder.Reset() @@ -201,7 +140,7 @@ func (ot *objectTree) ID() string { return ot.id } -func (ot *objectTree) Header() *aclpb.Header { +func (ot *objectTree) Header() *aclpb.TreeHeader { return ot.header } @@ -209,7 +148,7 @@ func (ot *objectTree) Storage() storage.TreeStorage { return ot.treeStorage } -func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (rawChange *aclpb.RawChange, err error) { +func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (rawChange *aclpb.RawTreeChangeWithId, err error) { defer func() { if err == nil && ot.updateListener != nil { ot.updateListener.Update(ot) @@ -258,12 +197,12 @@ func (ot *objectTree) prepareBuilderContent(content SignableChangeContent) (cnt isSnapshot: content.IsSnapshot, signingKey: content.Key, readKey: readKey, - content: content.Proto, + content: content.Data, } return } -func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.RawChange) (addResult AddResult, err error) { +func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { var mode Mode mode, addResult, err = ot.addRawChanges(ctx, rawChanges...) if err != nil { @@ -302,7 +241,7 @@ func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra return } -func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawChange) (mode Mode, addResult AddResult, err error) { +func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (mode Mode, addResult AddResult, err error) { // resetting buffers ot.tmpChangesBuf = ot.tmpChangesBuf[:0] ot.notSeenIdxBuf = ot.notSeenIdxBuf[:0] @@ -329,7 +268,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra } var change *Change - change, err = ot.changeBuilder.ConvertFromRawAndVerify(ch) + change, err = ot.changeBuilder.ConvertFromRaw(ch, true) if err != nil { return } @@ -354,7 +293,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra // returns changes that we added to the tree as attached this round // they can include not only the changes that were added now, // but also the changes that were previously in the tree - getAddedChanges := func(toConvert []*Change) (added []*aclpb.RawChange, err error) { + getAddedChanges := func(toConvert []*Change) (added []*aclpb.RawTreeChangeWithId, err error) { alreadyConverted := make(map[*Change]struct{}) // first we see if we have already unmarshalled those changes @@ -379,7 +318,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra for _, ch := range toConvert { // if we got some changes that we need to convert to raw if _, exists := alreadyConverted[ch]; !exists { - var raw *aclpb.RawChange + var raw *aclpb.RawTreeChangeWithId raw, err = ot.changeBuilder.BuildRaw(ch) if err != nil { return @@ -421,7 +360,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra ot.rebuildFromStorage(nil) return } - var added []*aclpb.RawChange + var added []*aclpb.RawTreeChangeWithId added, err = getAddedChanges(nil) // we shouldn't get any error in this case if err != nil { @@ -457,7 +396,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra err = ErrHasInvalidChanges return } - var added []*aclpb.RawChange + var added []*aclpb.RawTreeChangeWithId added, err = getAddedChanges(treeChangesAdded) if err != nil { // that means that some unattached changes were somehow corrupted in memory @@ -553,7 +492,7 @@ func (ot *objectTree) SnapshotPath() []string { return path } -func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*aclpb.RawChange, error) { +func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*aclpb.RawTreeChangeWithId, error) { var ( needFullDocument = len(theirPath) == 0 ourPath = ot.SnapshotPath() @@ -577,11 +516,11 @@ func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) } } -func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*aclpb.RawChange, err error) { +func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromTree(ot.tree, theirHeads) } -func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*aclpb.RawChange, err error) { +func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromStorage(commonSnapshot, ot.tree.headIds, theirHeads) } diff --git a/pkg/acl/tree/objecttree_test.go b/pkg/acl/tree/objecttree_test.go index 991eddd7..c73ce3ff 100644 --- a/pkg/acl/tree/objecttree_test.go +++ b/pkg/acl/tree/objecttree_test.go @@ -15,7 +15,7 @@ import ( type mockChangeCreator struct{} func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *aclpb.RawChange { - aclChange := &aclpb.Change{ + aclChange := &aclpb.TreeChange{ TreeHeadIds: prevIds, AclHeadId: aclId, SnapshotBaseId: snapshotId, @@ -23,22 +23,27 @@ func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot b IsSnapshot: isSnapshot, } res, _ := aclChange.Marshal() - return &aclpb.RawChange{ + + raw := &aclpb.RawTreeChange{ Payload: res, Signature: nil, + } + rawMarshalled, _ := raw.Marshal() + + return &aclpb.RawTreeChangeWithId{ + RawChange: rawMarshalled, Id: id, } } func (c *mockChangeCreator) createNewTreeStorage(treeId, aclListId, aclHeadId, firstChangeId string) storage.TreeStorage { firstChange := c.createRaw(firstChangeId, aclHeadId, "", true) - header := &aclpb.Header{ - FirstId: firstChangeId, - AclListId: aclListId, - WorkspaceId: "", - DocType: aclpb.Header_DocTree, + header := &aclpb.TreeHeader{ + FirstId: firstChangeId, + AclId: aclListId, + TreeHeaderType: aclpb.TreeHeaderType_Object, } - treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, header, []string{firstChangeId}, []*aclpb.RawChange{firstChange}) + treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, header, []string{firstChangeId}, []*aclpb.RawTreeChangeWithId{firstChange}) return treeStorage } diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go new file mode 100644 index 00000000..a62c8add --- /dev/null +++ b/pkg/acl/tree/objecttreefactory.go @@ -0,0 +1,161 @@ +package tree + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" + "github.com/gogo/protobuf/proto" + "go.uber.org/zap" +) + +type ObjectTreeCreatePayload struct { + AccountData *account.AccountData + HeaderData []byte + ChangeData []byte + TreeType aclpb.TreeHeaderType +} + +func BuildObjectTree(treeStorage storage.TreeStorage, listener ObjectTreeUpdateListener, aclList list.ACLList) (ObjectTree, error) { + deps := defaultObjectTreeDeps(treeStorage, listener, aclList) + return buildObjectTree(deps) +} + +func CreateObjectTree( + payload ObjectTreeCreatePayload, + listener ObjectTreeUpdateListener, + aclList list.ACLList, + createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + aclList.RLock() + var ( + deps = defaultObjectTreeDeps(nil, listener, aclList) + state = aclList.ACLState() + aclId = aclList.ID() + aclHeadId = aclList.Head().Id + readKeyHash = state.CurrentReadKeyHash() + ) + readKey, err := state.CurrentReadKey() + aclList.RUnlock() + + if err != nil { + return + } + + // create first change + cnt := BuilderContent{ + treeHeadIds: nil, + aclHeadId: aclHeadId, + snapshotBaseId: "", + currentReadKeyHash: readKeyHash, + isSnapshot: true, + readKey: readKey, + identity: payload.AccountData.Identity, + signingKey: payload.AccountData.SignKey, + content: payload.ChangeData, + } + + _, raw, err := deps.changeBuilder.BuildContent(cnt) + if err != nil { + return + } + + // create header + header, id, err := createTreeHeaderAndId( + raw, + payload.TreeType, + aclId, + payload.AccountData.Identity, + payload.HeaderData) + if err != nil { + return + } + + // create storage + st, err := createStorage(storage.TreeStorageCreatePayload{ + TreeId: id, + Header: header, + Changes: []*aclpb.RawTreeChangeWithId{raw}, + Heads: []string{raw.Id}, + }) + if err != nil { + return + } + + deps.treeStorage = st + return buildObjectTree(deps) +} + +func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { + objTree := &objectTree{ + treeStorage: deps.treeStorage, + updateListener: deps.updateListener, + treeBuilder: deps.treeBuilder, + validator: deps.validator, + aclList: deps.aclList, + changeBuilder: deps.changeBuilder, + rawChangeLoader: deps.rawChangeLoader, + tree: nil, + keys: make(map[uint64]*symmetric.Key), + tmpChangesBuf: make([]*Change, 0, 10), + difSnapshotBuf: make([]*aclpb.RawTreeChangeWithId, 0, 10), + notSeenIdxBuf: make([]int, 0, 10), + newSnapshotsBuf: make([]*Change, 0, 10), + } + + err := objTree.rebuildFromStorage(nil) + if err != nil { + return nil, err + } + storageHeads, err := objTree.treeStorage.Heads() + if err != nil { + return nil, err + } + + // comparing rebuilt heads with heads in storage + // in theory it can happen that we didn't set heads because the process has crashed + // therefore we want to set them later + if !slice.UnsortedEquals(storageHeads, objTree.tree.Heads()) { + log.With(zap.Strings("storage", storageHeads), zap.Strings("rebuilt", objTree.tree.Heads())). + Errorf("the heads in storage and objTree are different") + err = objTree.treeStorage.SetHeads(objTree.tree.Heads()) + if err != nil { + return nil, err + } + } + + objTree.id, err = objTree.treeStorage.ID() + if err != nil { + return nil, err + } + objTree.header, err = objTree.treeStorage.Header() + if err != nil { + return nil, err + } + + return objTree, nil +} + +func createTreeHeaderAndId( + raw *aclpb.RawTreeChangeWithId, + treeType aclpb.TreeHeaderType, + aclId string, + identity []byte, + headerData []byte) (header *aclpb.TreeHeader, treeId string, err error) { + header = &aclpb.TreeHeader{ + FirstId: raw.Id, + TreeHeaderType: treeType, + AclId: aclId, + Identity: identity, + Data: headerData, + } + marshalledHeader, err := proto.Marshal(header) + if err != nil { + return + } + + treeId, err = cid.NewCIDFromBytes(marshalledHeader) + return +} diff --git a/pkg/acl/tree/rawloader.go b/pkg/acl/tree/rawloader.go index 424fa2c2..c068cdba 100644 --- a/pkg/acl/tree/rawloader.go +++ b/pkg/acl/tree/rawloader.go @@ -18,7 +18,7 @@ type rawChangeLoader struct { type rawCacheEntry struct { change *Change - rawChange *aclpb.RawChange + rawChange *aclpb.RawTreeChangeWithId position int } @@ -29,15 +29,15 @@ func newRawChangeLoader(treeStorage storage.TreeStorage, changeBuilder ChangeBui } } -func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb.RawChange, error) { +func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { var stack []*Change for _, h := range t.headIds { stack = append(stack, t.attached[h]) } - convert := func(chs []*Change) (rawChanges []*aclpb.RawChange, err error) { + convert := func(chs []*Change) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { for _, ch := range chs { - var raw *aclpb.RawChange + var raw *aclpb.RawTreeChangeWithId raw, err = r.changeBuilder.BuildRaw(ch) if err != nil { return @@ -95,7 +95,7 @@ func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb. return convert(results) } -func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*aclpb.RawChange, error) { +func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { // resetting cache r.cache = make(map[string]rawCacheEntry) defer func() { @@ -162,7 +162,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi // preparing first pass r.idStack = append(r.idStack, heads...) - var buffer []*aclpb.RawChange + var buffer []*aclpb.RawTreeChangeWithId rootVisited := dfs(commonSnapshot, heads, 0, func(counter int, mapExists bool) bool { @@ -203,7 +203,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi }) // discarding visited - buffer = discardFromSlice(buffer, func(change *aclpb.RawChange) bool { + buffer = discardFromSlice(buffer, func(change *aclpb.RawTreeChangeWithId) bool { return change == nil }) @@ -219,7 +219,7 @@ func (r *rawChangeLoader) loadEntry(id string) (entry rawCacheEntry, err error) return } - change, err := r.changeBuilder.ConvertFromRaw(rawChange) + change, err := r.changeBuilder.ConvertFromRaw(rawChange, false) if err != nil { return } diff --git a/pkg/acl/tree/signablecontent.go b/pkg/acl/tree/signablecontent.go index f97ed44a..4774c2fb 100644 --- a/pkg/acl/tree/signablecontent.go +++ b/pkg/acl/tree/signablecontent.go @@ -2,12 +2,11 @@ package tree import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" - "github.com/gogo/protobuf/proto" ) type SignableChangeContent struct { - Proto proto.Marshaler + Data []byte Key signingkey.PrivKey - Identity string + Identity []byte IsSnapshot bool } diff --git a/pkg/acl/tree/tests/benches_test.go b/pkg/acl/tree/tests/benches_test.go new file mode 100644 index 00000000..703cb7a0 --- /dev/null +++ b/pkg/acl/tree/tests/benches_test.go @@ -0,0 +1,91 @@ +package tests + +import ( + "bytes" + "math/rand" + "testing" + "time" +) + +func BenchmarkHashes(b *testing.B) { + genRandomBytes := func() [][]byte { + var res [][]byte + s := rand.NewSource(time.Now().Unix()) + r := rand.New(s) + for i := 0; i < 10000; i++ { + var newBytes []byte + for j := 0; j < 64; j++ { + newBytes = append(newBytes, byte(r.Intn(256))) + } + res = append(res, newBytes) + } + return res + } + makeStrings := func(input [][]byte) []string { + var res []string + for _, bytes := range input { + res = append(res, string(bytes)) + } + return res + } + res := genRandomBytes() + stringRes := makeStrings(res) + stringMap := map[string]struct{}{} + b.Run("string bytes hash map write", func(b *testing.B) { + stringMap = map[string]struct{}{} + for i := 0; i < b.N; i++ { + for _, bytes := range res { + stringMap[string(bytes)] = struct{}{} + } + } + b.Run("hash map read", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, bytes := range res { + _, _ = stringMap[string(bytes)] + } + } + }) + }) + b.Run("compare byte slices as strings", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, bytes := range res { + if string(bytes) == string(bytes) { + + } + } + } + }) + b.Run("compare byte slices", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, bt := range res { + if bytes.Compare(bt, bt) == 0 { + + } + } + } + }) + b.Run("compare strings", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, st := range stringRes { + if st == st { + + } + } + } + }) + b.Run("string hash map write", func(b *testing.B) { + stringMap = map[string]struct{}{} + for i := 0; i < b.N; i++ { + for _, str := range stringRes { + stringMap[str] = struct{}{} + } + } + b.Run("hash map read", func(b *testing.B) { + for i := 0; i < b.N; i++ { + for _, str := range stringRes { + _, _ = stringMap[str] + } + } + }) + }) +} diff --git a/pkg/acl/tree/treebuilder.go b/pkg/acl/tree/treebuilder.go index fdf69873..d7249d28 100644 --- a/pkg/acl/tree/treebuilder.go +++ b/pkg/acl/tree/treebuilder.go @@ -129,7 +129,7 @@ func (tb *treeBuilder) loadChange(id string) (ch *Change, err error) { return nil, err } - ch, err = tb.builder.ConvertFromRawAndVerify(change) + ch, err = tb.builder.ConvertFromRaw(change, true) if err != nil { return nil, err } diff --git a/pkg/acl/tree/treestorage.go b/pkg/acl/tree/treestorage.go deleted file mode 100644 index 27fce1d5..00000000 --- a/pkg/acl/tree/treestorage.go +++ /dev/null @@ -1,91 +0,0 @@ -package tree - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" - "github.com/gogo/protobuf/proto" - "time" -) - -func CreateNewTreeStorage( - acc *account.AccountData, - aclList list.ACLList, - content proto.Marshaler, - create storage.TreeStorageCreatorFunc) (thr storage.TreeStorage, err error) { - - state := aclList.ACLState() - change := &aclpb.Change{ - AclHeadId: aclList.Head().Id, - CurrentReadKeyHash: state.CurrentReadKeyHash(), - Timestamp: int64(time.Now().Nanosecond()), - Identity: acc.Identity, - IsSnapshot: true, - } - - marshalledData, err := content.Marshal() - if err != nil { - return - } - - readKey, err := state.CurrentReadKey() - if err != nil { - return - } - - encrypted, err := readKey.Encrypt(marshalledData) - if err != nil { - return - } - - change.ChangesData = encrypted - - fullMarshalledChange, err := proto.Marshal(change) - if err != nil { - return - } - - signature, err := acc.SignKey.Sign(fullMarshalledChange) - if err != nil { - return - } - - changeId, err := cid.NewCIDFromBytes(fullMarshalledChange) - if err != nil { - return - } - - rawChange := &aclpb.RawChange{ - Payload: fullMarshalledChange, - Signature: signature, - Id: changeId, - } - header, treeId, err := createTreeHeaderAndId(rawChange, aclpb.Header_DocTree, aclList.ID()) - if err != nil { - return - } - - return create(storage.TreeStorageCreatePayload{ - TreeId: treeId, - Header: header, - Changes: []*aclpb.RawChange{rawChange}, - Heads: []string{rawChange.Id}, - }) -} - -func createTreeHeaderAndId(change *aclpb.RawChange, treeType aclpb.HeaderDocType, aclListId string) (header *aclpb.Header, treeId string, err error) { - header = &aclpb.Header{ - FirstId: change.Id, - DocType: treeType, - AclListId: aclListId, - } - marshalledHeader, err := proto.Marshal(header) - if err != nil { - return - } - - treeId, err = cid.NewCIDFromBytes(marshalledHeader) - return -} diff --git a/service/storage/service.go b/service/storage/service.go index e1a6ae6d..43fb44d5 100644 --- a/service/storage/service.go +++ b/service/storage/service.go @@ -15,7 +15,7 @@ var log = logger.NewNamed("storage").Sugar() type ImportedACLSyncData struct { Id string Header *aclpb.Header - Records []*aclpb.RawRecord + Records []*aclpb.RawACLRecord } type Service interface { diff --git a/syncproto/proto/sync.proto b/syncproto/proto/sync.proto index d6cc1ddd..80548336 100644 --- a/syncproto/proto/sync.proto +++ b/syncproto/proto/sync.proto @@ -47,44 +47,3 @@ message System { } } } - -message Sync { - string spaceId = 1; - ContentValue message = 2; - acl.Header treeHeader = 3; - string treeId = 4; - - message ContentValue { - oneof value { - HeadUpdate headUpdate = 1; - Full.Request fullSyncRequest = 2; - Full.Response fullSyncResponse = 3; - ACLList aclList = 4; - } - } - - message ACLList { - repeated acl.RawRecord records = 1; - } - - message HeadUpdate { - repeated string heads = 1; - repeated acl.RawChange changes = 2; - repeated string snapshotPath = 3; - } - - message Full { - // here with send the request with all changes we have (we already know sender's snapshot path) - message Request { - repeated string heads = 1; - repeated acl.RawChange changes = 2; - repeated string snapshotPath = 3; - } - - message Response { - repeated string heads = 1; - repeated acl.RawChange changes = 2; - repeated string snapshotPath = 3; - } - } -} diff --git a/syncproto/sync.pb.go b/syncproto/sync.pb.go index 0f8d273b..20a189a1 100644 --- a/syncproto/sync.pb.go +++ b/syncproto/sync.pb.go @@ -5,7 +5,7 @@ package syncproto import ( fmt "fmt" - aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + _ "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -51,28 +51,28 @@ func (MessageType) EnumDescriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{0} } -type SystemErrorCode int32 +type System_Error_Code int32 const ( - SystemError_UNKNOWN SystemErrorCode = 0 - SystemError_UNSUPPORTED_PROTOCOL_VERSION SystemErrorCode = 10 + System_Error_UNKNOWN System_Error_Code = 0 + System_Error_UNSUPPORTED_PROTOCOL_VERSION System_Error_Code = 10 ) -var SystemErrorCode_name = map[int32]string{ +var System_Error_Code_name = map[int32]string{ 0: "UNKNOWN", 10: "UNSUPPORTED_PROTOCOL_VERSION", } -var SystemErrorCode_value = map[string]int32{ +var System_Error_Code_value = map[string]int32{ "UNKNOWN": 0, "UNSUPPORTED_PROTOCOL_VERSION": 10, } -func (x SystemErrorCode) String() string { - return proto.EnumName(SystemErrorCode_name, int32(x)) +func (x System_Error_Code) String() string { + return proto.EnumName(System_Error_Code_name, int32(x)) } -func (SystemErrorCode) EnumDescriptor() ([]byte, []int) { +func (System_Error_Code) EnumDescriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 3, 0} } @@ -205,9 +205,9 @@ func (m *Header) GetDebugInfo() string { } type System struct { - Handshake *SystemHandshake `protobuf:"bytes,1,opt,name=handshake,proto3" json:"handshake,omitempty"` - Ping *SystemPing `protobuf:"bytes,2,opt,name=ping,proto3" json:"ping,omitempty"` - Ack *SystemAck `protobuf:"bytes,3,opt,name=ack,proto3" json:"ack,omitempty"` + Handshake *System_Handshake `protobuf:"bytes,1,opt,name=handshake,proto3" json:"handshake,omitempty"` + Ping *System_Ping `protobuf:"bytes,2,opt,name=ping,proto3" json:"ping,omitempty"` + Ack *System_Ack `protobuf:"bytes,3,opt,name=ack,proto3" json:"ack,omitempty"` } func (m *System) Reset() { *m = System{} } @@ -243,43 +243,43 @@ func (m *System) XXX_DiscardUnknown() { var xxx_messageInfo_System proto.InternalMessageInfo -func (m *System) GetHandshake() *SystemHandshake { +func (m *System) GetHandshake() *System_Handshake { if m != nil { return m.Handshake } return nil } -func (m *System) GetPing() *SystemPing { +func (m *System) GetPing() *System_Ping { if m != nil { return m.Ping } return nil } -func (m *System) GetAck() *SystemAck { +func (m *System) GetAck() *System_Ack { if m != nil { return m.Ack } return nil } -type SystemHandshake struct { +type System_Handshake struct { ProtocolVersion string `protobuf:"bytes,1,opt,name=protocolVersion,proto3" json:"protocolVersion,omitempty"` } -func (m *SystemHandshake) Reset() { *m = SystemHandshake{} } -func (m *SystemHandshake) String() string { return proto.CompactTextString(m) } -func (*SystemHandshake) ProtoMessage() {} -func (*SystemHandshake) Descriptor() ([]byte, []int) { +func (m *System_Handshake) Reset() { *m = System_Handshake{} } +func (m *System_Handshake) String() string { return proto.CompactTextString(m) } +func (*System_Handshake) ProtoMessage() {} +func (*System_Handshake) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 0} } -func (m *SystemHandshake) XXX_Unmarshal(b []byte) error { +func (m *System_Handshake) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemHandshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Handshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemHandshake.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Handshake.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -289,41 +289,41 @@ func (m *SystemHandshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, err return b[:n], nil } } -func (m *SystemHandshake) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemHandshake.Merge(m, src) +func (m *System_Handshake) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Handshake.Merge(m, src) } -func (m *SystemHandshake) XXX_Size() int { +func (m *System_Handshake) XXX_Size() int { return m.Size() } -func (m *SystemHandshake) XXX_DiscardUnknown() { - xxx_messageInfo_SystemHandshake.DiscardUnknown(m) +func (m *System_Handshake) XXX_DiscardUnknown() { + xxx_messageInfo_System_Handshake.DiscardUnknown(m) } -var xxx_messageInfo_SystemHandshake proto.InternalMessageInfo +var xxx_messageInfo_System_Handshake proto.InternalMessageInfo -func (m *SystemHandshake) GetProtocolVersion() string { +func (m *System_Handshake) GetProtocolVersion() string { if m != nil { return m.ProtocolVersion } return "" } -type SystemPing struct { +type System_Ping struct { UnixTime uint64 `protobuf:"varint,1,opt,name=unixTime,proto3" json:"unixTime,omitempty"` } -func (m *SystemPing) Reset() { *m = SystemPing{} } -func (m *SystemPing) String() string { return proto.CompactTextString(m) } -func (*SystemPing) ProtoMessage() {} -func (*SystemPing) Descriptor() ([]byte, []int) { +func (m *System_Ping) Reset() { *m = System_Ping{} } +func (m *System_Ping) String() string { return proto.CompactTextString(m) } +func (*System_Ping) ProtoMessage() {} +func (*System_Ping) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 1} } -func (m *SystemPing) XXX_Unmarshal(b []byte) error { +func (m *System_Ping) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemPing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemPing.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Ping.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -333,41 +333,41 @@ func (m *SystemPing) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *SystemPing) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemPing.Merge(m, src) +func (m *System_Ping) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Ping.Merge(m, src) } -func (m *SystemPing) XXX_Size() int { +func (m *System_Ping) XXX_Size() int { return m.Size() } -func (m *SystemPing) XXX_DiscardUnknown() { - xxx_messageInfo_SystemPing.DiscardUnknown(m) +func (m *System_Ping) XXX_DiscardUnknown() { + xxx_messageInfo_System_Ping.DiscardUnknown(m) } -var xxx_messageInfo_SystemPing proto.InternalMessageInfo +var xxx_messageInfo_System_Ping proto.InternalMessageInfo -func (m *SystemPing) GetUnixTime() uint64 { +func (m *System_Ping) GetUnixTime() uint64 { if m != nil { return m.UnixTime } return 0 } -type SystemAck struct { - Error *SystemError `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` +type System_Ack struct { + Error *System_Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` } -func (m *SystemAck) Reset() { *m = SystemAck{} } -func (m *SystemAck) String() string { return proto.CompactTextString(m) } -func (*SystemAck) ProtoMessage() {} -func (*SystemAck) Descriptor() ([]byte, []int) { +func (m *System_Ack) Reset() { *m = System_Ack{} } +func (m *System_Ack) String() string { return proto.CompactTextString(m) } +func (*System_Ack) ProtoMessage() {} +func (*System_Ack) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 2} } -func (m *SystemAck) XXX_Unmarshal(b []byte) error { +func (m *System_Ack) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Ack) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemAck.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Ack.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -377,42 +377,42 @@ func (m *SystemAck) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { return b[:n], nil } } -func (m *SystemAck) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemAck.Merge(m, src) +func (m *System_Ack) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Ack.Merge(m, src) } -func (m *SystemAck) XXX_Size() int { +func (m *System_Ack) XXX_Size() int { return m.Size() } -func (m *SystemAck) XXX_DiscardUnknown() { - xxx_messageInfo_SystemAck.DiscardUnknown(m) +func (m *System_Ack) XXX_DiscardUnknown() { + xxx_messageInfo_System_Ack.DiscardUnknown(m) } -var xxx_messageInfo_SystemAck proto.InternalMessageInfo +var xxx_messageInfo_System_Ack proto.InternalMessageInfo -func (m *SystemAck) GetError() *SystemError { +func (m *System_Ack) GetError() *System_Error { if m != nil { return m.Error } return nil } -type SystemError struct { - Code SystemErrorCode `protobuf:"varint,1,opt,name=code,proto3,enum=anytype.SystemErrorCode" json:"code,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` +type System_Error struct { + Code System_Error_Code `protobuf:"varint,1,opt,name=code,proto3,enum=anytype.System_Error_Code" json:"code,omitempty"` + Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` } -func (m *SystemError) Reset() { *m = SystemError{} } -func (m *SystemError) String() string { return proto.CompactTextString(m) } -func (*SystemError) ProtoMessage() {} -func (*SystemError) Descriptor() ([]byte, []int) { +func (m *System_Error) Reset() { *m = System_Error{} } +func (m *System_Error) String() string { return proto.CompactTextString(m) } +func (*System_Error) ProtoMessage() {} +func (*System_Error) Descriptor() ([]byte, []int) { return fileDescriptor_4b28dfdd48a89166, []int{2, 3} } -func (m *SystemError) XXX_Unmarshal(b []byte) error { +func (m *System_Error) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) } -func (m *SystemError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { +func (m *System_Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { if deterministic { - return xxx_messageInfo_SystemError.Marshal(b, m, deterministic) + return xxx_messageInfo_System_Error.Marshal(b, m, deterministic) } else { b = b[:cap(b)] n, err := m.MarshalToSizedBuffer(b) @@ -422,546 +422,82 @@ func (m *SystemError) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) return b[:n], nil } } -func (m *SystemError) XXX_Merge(src proto.Message) { - xxx_messageInfo_SystemError.Merge(m, src) +func (m *System_Error) XXX_Merge(src proto.Message) { + xxx_messageInfo_System_Error.Merge(m, src) } -func (m *SystemError) XXX_Size() int { +func (m *System_Error) XXX_Size() int { return m.Size() } -func (m *SystemError) XXX_DiscardUnknown() { - xxx_messageInfo_SystemError.DiscardUnknown(m) +func (m *System_Error) XXX_DiscardUnknown() { + xxx_messageInfo_System_Error.DiscardUnknown(m) } -var xxx_messageInfo_SystemError proto.InternalMessageInfo +var xxx_messageInfo_System_Error proto.InternalMessageInfo -func (m *SystemError) GetCode() SystemErrorCode { +func (m *System_Error) GetCode() System_Error_Code { if m != nil { return m.Code } - return SystemError_UNKNOWN + return System_Error_UNKNOWN } -func (m *SystemError) GetDescription() string { +func (m *System_Error) GetDescription() string { if m != nil { return m.Description } return "" } -type Sync struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Message *SyncContentValue `protobuf:"bytes,2,opt,name=message,proto3" json:"message,omitempty"` - TreeHeader *aclpb.Header `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` -} - -func (m *Sync) Reset() { *m = Sync{} } -func (m *Sync) String() string { return proto.CompactTextString(m) } -func (*Sync) ProtoMessage() {} -func (*Sync) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3} -} -func (m *Sync) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Sync) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Sync.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 *Sync) XXX_Merge(src proto.Message) { - xxx_messageInfo_Sync.Merge(m, src) -} -func (m *Sync) XXX_Size() int { - return m.Size() -} -func (m *Sync) XXX_DiscardUnknown() { - xxx_messageInfo_Sync.DiscardUnknown(m) -} - -var xxx_messageInfo_Sync proto.InternalMessageInfo - -func (m *Sync) GetSpaceId() string { - if m != nil { - return m.SpaceId - } - return "" -} - -func (m *Sync) GetMessage() *SyncContentValue { - if m != nil { - return m.Message - } - return nil -} - -func (m *Sync) GetTreeHeader() *aclpb.Header { - if m != nil { - return m.TreeHeader - } - return nil -} - -func (m *Sync) GetTreeId() string { - if m != nil { - return m.TreeId - } - return "" -} - -type SyncContentValue struct { - // Types that are valid to be assigned to Value: - // *SyncContentValueValueOfHeadUpdate - // *SyncContentValueValueOfFullSyncRequest - // *SyncContentValueValueOfFullSyncResponse - // *SyncContentValueValueOfAclList - Value IsSyncContentValueValue `protobuf_oneof:"value"` -} - -func (m *SyncContentValue) Reset() { *m = SyncContentValue{} } -func (m *SyncContentValue) String() string { return proto.CompactTextString(m) } -func (*SyncContentValue) ProtoMessage() {} -func (*SyncContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 0} -} -func (m *SyncContentValue) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncContentValue) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncContentValue.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 *SyncContentValue) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncContentValue.Merge(m, src) -} -func (m *SyncContentValue) XXX_Size() int { - return m.Size() -} -func (m *SyncContentValue) XXX_DiscardUnknown() { - xxx_messageInfo_SyncContentValue.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncContentValue proto.InternalMessageInfo - -type IsSyncContentValueValue interface { - IsSyncContentValueValue() - MarshalTo([]byte) (int, error) - Size() int -} - -type SyncContentValueValueOfHeadUpdate struct { - HeadUpdate *SyncHeadUpdate `protobuf:"bytes,1,opt,name=headUpdate,proto3,oneof" json:"headUpdate,omitempty"` -} -type SyncContentValueValueOfFullSyncRequest struct { - FullSyncRequest *SyncFullRequest `protobuf:"bytes,2,opt,name=fullSyncRequest,proto3,oneof" json:"fullSyncRequest,omitempty"` -} -type SyncContentValueValueOfFullSyncResponse struct { - FullSyncResponse *SyncFullResponse `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` -} -type SyncContentValueValueOfAclList struct { - AclList *SyncACLList `protobuf:"bytes,4,opt,name=aclList,proto3,oneof" json:"aclList,omitempty"` -} - -func (*SyncContentValueValueOfHeadUpdate) IsSyncContentValueValue() {} -func (*SyncContentValueValueOfFullSyncRequest) IsSyncContentValueValue() {} -func (*SyncContentValueValueOfFullSyncResponse) IsSyncContentValueValue() {} -func (*SyncContentValueValueOfAclList) IsSyncContentValueValue() {} - -func (m *SyncContentValue) GetValue() IsSyncContentValueValue { - if m != nil { - return m.Value - } - return nil -} - -func (m *SyncContentValue) GetHeadUpdate() *SyncHeadUpdate { - if x, ok := m.GetValue().(*SyncContentValueValueOfHeadUpdate); ok { - return x.HeadUpdate - } - return nil -} - -func (m *SyncContentValue) GetFullSyncRequest() *SyncFullRequest { - if x, ok := m.GetValue().(*SyncContentValueValueOfFullSyncRequest); ok { - return x.FullSyncRequest - } - return nil -} - -func (m *SyncContentValue) GetFullSyncResponse() *SyncFullResponse { - if x, ok := m.GetValue().(*SyncContentValueValueOfFullSyncResponse); ok { - return x.FullSyncResponse - } - return nil -} - -func (m *SyncContentValue) GetAclList() *SyncACLList { - if x, ok := m.GetValue().(*SyncContentValueValueOfAclList); ok { - return x.AclList - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*SyncContentValue) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*SyncContentValueValueOfHeadUpdate)(nil), - (*SyncContentValueValueOfFullSyncRequest)(nil), - (*SyncContentValueValueOfFullSyncResponse)(nil), - (*SyncContentValueValueOfAclList)(nil), - } -} - -type SyncACLList struct { - Records []*aclpb.RawRecord `protobuf:"bytes,1,rep,name=records,proto3" json:"records,omitempty"` -} - -func (m *SyncACLList) Reset() { *m = SyncACLList{} } -func (m *SyncACLList) String() string { return proto.CompactTextString(m) } -func (*SyncACLList) ProtoMessage() {} -func (*SyncACLList) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 1} -} -func (m *SyncACLList) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncACLList) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncACLList.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 *SyncACLList) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncACLList.Merge(m, src) -} -func (m *SyncACLList) XXX_Size() int { - return m.Size() -} -func (m *SyncACLList) XXX_DiscardUnknown() { - xxx_messageInfo_SyncACLList.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncACLList proto.InternalMessageInfo - -func (m *SyncACLList) GetRecords() []*aclpb.RawRecord { - if m != nil { - return m.Records - } - return nil -} - -type SyncHeadUpdate struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` -} - -func (m *SyncHeadUpdate) Reset() { *m = SyncHeadUpdate{} } -func (m *SyncHeadUpdate) String() string { return proto.CompactTextString(m) } -func (*SyncHeadUpdate) ProtoMessage() {} -func (*SyncHeadUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 2} -} -func (m *SyncHeadUpdate) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncHeadUpdate) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncHeadUpdate.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 *SyncHeadUpdate) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncHeadUpdate.Merge(m, src) -} -func (m *SyncHeadUpdate) XXX_Size() int { - return m.Size() -} -func (m *SyncHeadUpdate) XXX_DiscardUnknown() { - xxx_messageInfo_SyncHeadUpdate.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncHeadUpdate proto.InternalMessageInfo - -func (m *SyncHeadUpdate) GetHeads() []string { - if m != nil { - return m.Heads - } - return nil -} - -func (m *SyncHeadUpdate) GetChanges() []*aclpb.RawChange { - if m != nil { - return m.Changes - } - return nil -} - -func (m *SyncHeadUpdate) GetSnapshotPath() []string { - if m != nil { - return m.SnapshotPath - } - return nil -} - -type SyncFull struct { -} - -func (m *SyncFull) Reset() { *m = SyncFull{} } -func (m *SyncFull) String() string { return proto.CompactTextString(m) } -func (*SyncFull) ProtoMessage() {} -func (*SyncFull) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 3} -} -func (m *SyncFull) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncFull) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncFull.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 *SyncFull) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFull.Merge(m, src) -} -func (m *SyncFull) XXX_Size() int { - return m.Size() -} -func (m *SyncFull) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFull.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncFull proto.InternalMessageInfo - -// here with send the request with all changes we have (we already know sender's snapshot path) -type SyncFullRequest struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` -} - -func (m *SyncFullRequest) Reset() { *m = SyncFullRequest{} } -func (m *SyncFullRequest) String() string { return proto.CompactTextString(m) } -func (*SyncFullRequest) ProtoMessage() {} -func (*SyncFullRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 3, 0} -} -func (m *SyncFullRequest) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncFullRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncFullRequest.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 *SyncFullRequest) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFullRequest.Merge(m, src) -} -func (m *SyncFullRequest) XXX_Size() int { - return m.Size() -} -func (m *SyncFullRequest) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFullRequest.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncFullRequest proto.InternalMessageInfo - -func (m *SyncFullRequest) GetHeads() []string { - if m != nil { - return m.Heads - } - return nil -} - -func (m *SyncFullRequest) GetChanges() []*aclpb.RawChange { - if m != nil { - return m.Changes - } - return nil -} - -func (m *SyncFullRequest) GetSnapshotPath() []string { - if m != nil { - return m.SnapshotPath - } - return nil -} - -type SyncFullResponse struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` -} - -func (m *SyncFullResponse) Reset() { *m = SyncFullResponse{} } -func (m *SyncFullResponse) String() string { return proto.CompactTextString(m) } -func (*SyncFullResponse) ProtoMessage() {} -func (*SyncFullResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{3, 3, 1} -} -func (m *SyncFullResponse) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SyncFullResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SyncFullResponse.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 *SyncFullResponse) XXX_Merge(src proto.Message) { - xxx_messageInfo_SyncFullResponse.Merge(m, src) -} -func (m *SyncFullResponse) XXX_Size() int { - return m.Size() -} -func (m *SyncFullResponse) XXX_DiscardUnknown() { - xxx_messageInfo_SyncFullResponse.DiscardUnknown(m) -} - -var xxx_messageInfo_SyncFullResponse proto.InternalMessageInfo - -func (m *SyncFullResponse) GetHeads() []string { - if m != nil { - return m.Heads - } - return nil -} - -func (m *SyncFullResponse) GetChanges() []*aclpb.RawChange { - if m != nil { - return m.Changes - } - return nil -} - -func (m *SyncFullResponse) GetSnapshotPath() []string { - if m != nil { - return m.SnapshotPath - } - return nil -} - func init() { proto.RegisterEnum("anytype.MessageType", MessageType_name, MessageType_value) - proto.RegisterEnum("anytype.SystemErrorCode", SystemErrorCode_name, SystemErrorCode_value) + proto.RegisterEnum("anytype.System_Error_Code", System_Error_Code_name, System_Error_Code_value) proto.RegisterType((*Message)(nil), "anytype.Message") proto.RegisterType((*Header)(nil), "anytype.Header") proto.RegisterType((*System)(nil), "anytype.System") - proto.RegisterType((*SystemHandshake)(nil), "anytype.System.Handshake") - proto.RegisterType((*SystemPing)(nil), "anytype.System.Ping") - proto.RegisterType((*SystemAck)(nil), "anytype.System.Ack") - proto.RegisterType((*SystemError)(nil), "anytype.System.Error") - proto.RegisterType((*Sync)(nil), "anytype.Sync") - proto.RegisterType((*SyncContentValue)(nil), "anytype.Sync.ContentValue") - proto.RegisterType((*SyncACLList)(nil), "anytype.Sync.ACLList") - proto.RegisterType((*SyncHeadUpdate)(nil), "anytype.Sync.HeadUpdate") - proto.RegisterType((*SyncFull)(nil), "anytype.Sync.Full") - proto.RegisterType((*SyncFullRequest)(nil), "anytype.Sync.Full.Request") - proto.RegisterType((*SyncFullResponse)(nil), "anytype.Sync.Full.Response") + proto.RegisterType((*System_Handshake)(nil), "anytype.System.Handshake") + proto.RegisterType((*System_Ping)(nil), "anytype.System.Ping") + proto.RegisterType((*System_Ack)(nil), "anytype.System.Ack") + proto.RegisterType((*System_Error)(nil), "anytype.System.Error") } func init() { proto.RegisterFile("syncproto/proto/sync.proto", fileDescriptor_4b28dfdd48a89166) } var fileDescriptor_4b28dfdd48a89166 = []byte{ - // 812 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xc1, 0x8e, 0xe2, 0x46, - 0x10, 0xb5, 0xc1, 0xe0, 0x75, 0x79, 0x34, 0x90, 0xde, 0xd9, 0xc8, 0x71, 0x56, 0x08, 0xa1, 0x44, - 0x41, 0x59, 0xc9, 0x93, 0xb0, 0x59, 0x45, 0xca, 0x6d, 0x96, 0xcc, 0xc8, 0x28, 0x13, 0x40, 0x0d, - 0x4c, 0xa4, 0x5c, 0x56, 0x3d, 0xed, 0x5e, 0x40, 0x98, 0xb6, 0xe3, 0x36, 0x49, 0xf8, 0x8b, 0xbd, - 0xe6, 0x9a, 0x6f, 0xc8, 0x37, 0x44, 0x39, 0xee, 0x31, 0xc7, 0x68, 0x46, 0xf9, 0x8f, 0xa8, 0xdb, - 0x36, 0x18, 0x32, 0xe7, 0x39, 0x00, 0x5d, 0xaf, 0x5e, 0x55, 0xbf, 0x2a, 0x57, 0x19, 0x70, 0xc5, - 0x96, 0xd3, 0x38, 0x89, 0xd2, 0xe8, 0x3c, 0xfb, 0x96, 0xb6, 0xa7, 0x8e, 0xc8, 0x24, 0x7c, 0x9b, - 0x6e, 0x63, 0xe6, 0x7e, 0x11, 0xaf, 0xe6, 0xe7, 0x84, 0x86, 0xf2, 0x43, 0x17, 0x84, 0xcf, 0x99, - 0x90, 0xc7, 0xf8, 0x36, 0x8b, 0x11, 0x25, 0x3c, 0x0b, 0xed, 0x5c, 0x81, 0xf9, 0x3d, 0x13, 0x82, - 0xcc, 0x19, 0xfa, 0x0c, 0xea, 0x0b, 0x46, 0x02, 0x96, 0x38, 0x7a, 0x5b, 0xef, 0xda, 0xbd, 0x86, - 0x97, 0xa7, 0xf5, 0x7c, 0x05, 0xe3, 0xdc, 0x8d, 0x10, 0x18, 0x01, 0x49, 0x89, 0x53, 0x69, 0xeb, - 0xdd, 0x13, 0xac, 0xce, 0x9d, 0xdf, 0x75, 0xa8, 0x67, 0x34, 0xe4, 0x80, 0x99, 0x26, 0x84, 0xb2, - 0x41, 0xa0, 0x12, 0x9d, 0xe0, 0xc2, 0x44, 0xcf, 0xc1, 0x4a, 0xd8, 0x4f, 0x1b, 0x26, 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0x58, 0x6e, - 0x58, 0x53, 0x47, 0x4f, 0xa1, 0x71, 0x40, 0xe6, 0xb4, 0x59, 0x79, 0xfd, 0xc9, 0x5f, 0x77, 0x2d, - 0xfd, 0xfd, 0x5d, 0x4b, 0xff, 0xe7, 0xae, 0xa5, 0xbf, 0xbb, 0x6f, 0x69, 0xef, 0xef, 0x5b, 0xda, - 0xdf, 0xf7, 0x2d, 0xed, 0x47, 0x38, 0xdf, 0xfd, 0x5f, 0xdd, 0xd6, 0xd5, 0xcf, 0xcb, 0xff, 0x02, - 0x00, 0x00, 0xff, 0xff, 0x6a, 0xb8, 0x16, 0xd3, 0xc3, 0x06, 0x00, 0x00, + // 536 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xd1, 0x8a, 0xd3, 0x40, + 0x14, 0x86, 0x3b, 0xdb, 0x6c, 0x6b, 0x4f, 0x96, 0xdd, 0x38, 0xbb, 0x0b, 0x31, 0x2c, 0x21, 0x14, + 0xc5, 0xa2, 0x90, 0x4a, 0x65, 0xf1, 0x7a, 0x5d, 0x2b, 0x2d, 0x6a, 0x53, 0xa6, 0xed, 0x0a, 0xde, + 0x2c, 0xd3, 0xc9, 0x98, 0x86, 0x76, 0x93, 0x98, 0xa4, 0x60, 0xde, 0x62, 0x9f, 0xc1, 0x67, 0xf0, + 0x21, 0xbc, 0xdc, 0x4b, 0x2f, 0xa5, 0x7d, 0x11, 0x99, 0x49, 0xda, 0xc6, 0xe2, 0x45, 0x92, 0x39, + 0xff, 0xf9, 0xff, 0x33, 0xdf, 0x30, 0x04, 0x8c, 0x24, 0x0b, 0x58, 0x14, 0x87, 0x69, 0xd8, 0xce, + 0xdf, 0xa2, 0xb6, 0xe5, 0x12, 0xd7, 0x69, 0x90, 0xa5, 0x59, 0xc4, 0x8d, 0x57, 0xd1, 0xdc, 0x6b, + 0x53, 0xb6, 0x10, 0x0f, 0x9b, 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 0xd7, 0x10, 0x3e, 0x85, 0x93, 0x7f, 0xcc, 0x01, 0xd3, 0x0e, 0xde, 0x3e, 0xfd, 0xb5, 0x32, 0xd1, + 0xc3, 0xca, 0x44, 0x7f, 0x56, 0x26, 0xba, 0x5f, 0x9b, 0x95, 0x87, 0xb5, 0x59, 0xf9, 0xbd, 0x36, + 0x2b, 0x5f, 0xa0, 0xbd, 0xfd, 0xcd, 0xa6, 0x35, 0xf9, 0x79, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, + 0x5f, 0xee, 0x92, 0xca, 0x7a, 0x03, 0x00, 0x00, } func (m *Message) Marshal() (dAtA []byte, err error) { @@ -1117,7 +653,7 @@ func (m *System) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemHandshake) Marshal() (dAtA []byte, err error) { +func (m *System_Handshake) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1127,12 +663,12 @@ func (m *SystemHandshake) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemHandshake) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Handshake) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemHandshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Handshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1147,7 +683,7 @@ func (m *SystemHandshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemPing) Marshal() (dAtA []byte, err error) { +func (m *System_Ping) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1157,12 +693,12 @@ func (m *SystemPing) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemPing) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Ping) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Ping) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1175,7 +711,7 @@ func (m *SystemPing) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemAck) Marshal() (dAtA []byte, err error) { +func (m *System_Ack) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1185,12 +721,12 @@ func (m *SystemAck) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemAck) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Ack) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Ack) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1210,7 +746,7 @@ func (m *SystemAck) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *SystemError) Marshal() (dAtA []byte, err error) { +func (m *System_Error) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) n, err := m.MarshalToSizedBuffer(dAtA[:size]) @@ -1220,12 +756,12 @@ func (m *SystemError) Marshal() (dAtA []byte, err error) { return dAtA[:n], nil } -func (m *SystemError) MarshalTo(dAtA []byte) (int, error) { +func (m *System_Error) MarshalTo(dAtA []byte) (int, error) { size := m.Size() return m.MarshalToSizedBuffer(dAtA[:size]) } -func (m *SystemError) MarshalToSizedBuffer(dAtA []byte) (int, error) { +func (m *System_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { i := len(dAtA) _ = i var l int @@ -1245,408 +781,6 @@ func (m *SystemError) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } -func (m *Sync) 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 *Sync) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Sync) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.TreeId) > 0 { - i -= len(m.TreeId) - copy(dAtA[i:], m.TreeId) - i = encodeVarintSync(dAtA, i, uint64(len(m.TreeId))) - i-- - dAtA[i] = 0x22 - } - if m.TreeHeader != nil { - { - size, err := m.TreeHeader.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Message != nil { - { - size, err := m.Message.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if len(m.SpaceId) > 0 { - i -= len(m.SpaceId) - copy(dAtA[i:], m.SpaceId) - i = encodeVarintSync(dAtA, i, uint64(len(m.SpaceId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SyncContentValue) 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 *SyncContentValue) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncContentValue) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Value != nil { - { - size := m.Value.Size() - i -= size - if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *SyncContentValueValueOfHeadUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncContentValueValueOfHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.HeadUpdate != nil { - { - size, err := m.HeadUpdate.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *SyncContentValueValueOfFullSyncRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncContentValueValueOfFullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.FullSyncRequest != nil { - { - size, err := m.FullSyncRequest.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *SyncContentValueValueOfFullSyncResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncContentValueValueOfFullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.FullSyncResponse != nil { - { - size, err := m.FullSyncResponse.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *SyncContentValueValueOfAclList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncContentValueValueOfAclList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.AclList != nil { - { - size, err := m.AclList.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *SyncACLList) 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 *SyncACLList) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncACLList) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Records) > 0 { - for iNdEx := len(m.Records) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Records[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SyncHeadUpdate) 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 *SyncHeadUpdate) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SnapshotPath) > 0 { - for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SnapshotPath[iNdEx]) - copy(dAtA[i:], m.SnapshotPath[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Changes) > 0 { - for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Heads) > 0 { - for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Heads[iNdEx]) - copy(dAtA[i:], m.Heads[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SyncFull) 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 *SyncFull) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncFull) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - return len(dAtA) - i, nil -} - -func (m *SyncFullRequest) 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 *SyncFullRequest) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncFullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SnapshotPath) > 0 { - for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SnapshotPath[iNdEx]) - copy(dAtA[i:], m.SnapshotPath[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Changes) > 0 { - for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Heads) > 0 { - for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Heads[iNdEx]) - copy(dAtA[i:], m.Heads[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *SyncFullResponse) 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 *SyncFullResponse) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SyncFullResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.SnapshotPath) > 0 { - for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.SnapshotPath[iNdEx]) - copy(dAtA[i:], m.SnapshotPath[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) - i-- - dAtA[i] = 0x1a - } - } - if len(m.Changes) > 0 { - for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { - { - size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - } - if len(m.Heads) > 0 { - for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.Heads[iNdEx]) - copy(dAtA[i:], m.Heads[iNdEx]) - i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - func encodeVarintSync(dAtA []byte, offset int, v uint64) int { offset -= sovSync(v) base := offset @@ -1722,7 +856,7 @@ func (m *System) Size() (n int) { return n } -func (m *SystemHandshake) Size() (n int) { +func (m *System_Handshake) Size() (n int) { if m == nil { return 0 } @@ -1735,7 +869,7 @@ func (m *SystemHandshake) Size() (n int) { return n } -func (m *SystemPing) Size() (n int) { +func (m *System_Ping) Size() (n int) { if m == nil { return 0 } @@ -1747,7 +881,7 @@ func (m *SystemPing) Size() (n int) { return n } -func (m *SystemAck) Size() (n int) { +func (m *System_Ack) Size() (n int) { if m == nil { return 0 } @@ -1760,7 +894,7 @@ func (m *SystemAck) Size() (n int) { return n } -func (m *SystemError) Size() (n int) { +func (m *System_Error) Size() (n int) { if m == nil { return 0 } @@ -1776,196 +910,6 @@ func (m *SystemError) Size() (n int) { return n } -func (m *Sync) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SpaceId) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - if m.Message != nil { - l = m.Message.Size() - n += 1 + l + sovSync(uint64(l)) - } - if m.TreeHeader != nil { - l = m.TreeHeader.Size() - n += 1 + l + sovSync(uint64(l)) - } - l = len(m.TreeId) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *SyncContentValue) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Value != nil { - n += m.Value.Size() - } - return n -} - -func (m *SyncContentValueValueOfHeadUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.HeadUpdate != nil { - l = m.HeadUpdate.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} -func (m *SyncContentValueValueOfFullSyncRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FullSyncRequest != nil { - l = m.FullSyncRequest.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} -func (m *SyncContentValueValueOfFullSyncResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.FullSyncResponse != nil { - l = m.FullSyncResponse.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} -func (m *SyncContentValueValueOfAclList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.AclList != nil { - l = m.AclList.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} -func (m *SyncACLList) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Records) > 0 { - for _, e := range m.Records { - l = e.Size() - n += 1 + l + sovSync(uint64(l)) - } - } - return n -} - -func (m *SyncHeadUpdate) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Heads) > 0 { - for _, s := range m.Heads { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.Changes) > 0 { - for _, e := range m.Changes { - l = e.Size() - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.SnapshotPath) > 0 { - for _, s := range m.SnapshotPath { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - return n -} - -func (m *SyncFull) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - return n -} - -func (m *SyncFullRequest) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Heads) > 0 { - for _, s := range m.Heads { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.Changes) > 0 { - for _, e := range m.Changes { - l = e.Size() - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.SnapshotPath) > 0 { - for _, s := range m.SnapshotPath { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - return n -} - -func (m *SyncFullResponse) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.Heads) > 0 { - for _, s := range m.Heads { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.Changes) > 0 { - for _, e := range m.Changes { - l = e.Size() - n += 1 + l + sovSync(uint64(l)) - } - } - if len(m.SnapshotPath) > 0 { - for _, s := range m.SnapshotPath { - l = len(s) - n += 1 + l + sovSync(uint64(l)) - } - } - return n -} - func sovSync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2324,7 +1268,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Handshake == nil { - m.Handshake = &SystemHandshake{} + m.Handshake = &System_Handshake{} } if err := m.Handshake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2360,7 +1304,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Ping == nil { - m.Ping = &SystemPing{} + m.Ping = &System_Ping{} } if err := m.Ping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2396,7 +1340,7 @@ func (m *System) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Ack == nil { - m.Ack = &SystemAck{} + m.Ack = &System_Ack{} } if err := m.Ack.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2423,7 +1367,7 @@ func (m *System) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemHandshake) Unmarshal(dAtA []byte) error { +func (m *System_Handshake) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2505,7 +1449,7 @@ func (m *SystemHandshake) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemPing) Unmarshal(dAtA []byte) error { +func (m *System_Ping) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2574,7 +1518,7 @@ func (m *SystemPing) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemAck) Unmarshal(dAtA []byte) error { +func (m *System_Ack) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2633,7 +1577,7 @@ func (m *SystemAck) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.Error == nil { - m.Error = &SystemError{} + m.Error = &System_Error{} } if err := m.Error.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2660,7 +1604,7 @@ func (m *SystemAck) Unmarshal(dAtA []byte) error { } return nil } -func (m *SystemError) Unmarshal(dAtA []byte) error { +func (m *System_Error) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -2703,7 +1647,7 @@ func (m *SystemError) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - m.Code |= SystemErrorCode(b&0x7F) << shift + m.Code |= System_Error_Code(b&0x7F) << shift if b < 0x80 { break } @@ -2761,960 +1705,6 @@ func (m *SystemError) Unmarshal(dAtA []byte) error { } return nil } -func (m *Sync) 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 ErrIntOverflowSync - } - 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: Sync: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Sync: illegal tag %d (wire type %d)", fieldNum, wire) - } - 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 ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SpaceId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Message", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Message == nil { - m.Message = &SyncContentValue{} - } - if err := m.Message.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeader", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.TreeHeader == nil { - m.TreeHeader = &aclpb.Header{} - } - if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TreeId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncContentValue) 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 ErrIntOverflowSync - } - 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: ContentValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ContentValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field HeadUpdate", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SyncHeadUpdate{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &SyncContentValueValueOfHeadUpdate{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FullSyncRequest", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SyncFullRequest{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &SyncContentValueValueOfFullSyncRequest{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FullSyncResponse", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SyncFullResponse{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &SyncContentValueValueOfFullSyncResponse{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclList", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SyncACLList{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &SyncContentValueValueOfAclList{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncACLList) 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 ErrIntOverflowSync - } - 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: ACLList: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLList: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Records", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Records = append(m.Records, &aclpb.RawRecord{}) - if err := m.Records[len(m.Records)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncHeadUpdate) 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 ErrIntOverflowSync - } - 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: HeadUpdate: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: HeadUpdate: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Changes = append(m.Changes, &aclpb.RawChange{}) - if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SnapshotPath = append(m.SnapshotPath, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncFull) 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 ErrIntOverflowSync - } - 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: Full: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Full: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncFullRequest) 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 ErrIntOverflowSync - } - 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: Request: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Request: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Changes = append(m.Changes, &aclpb.RawChange{}) - if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SnapshotPath = append(m.SnapshotPath, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SyncFullResponse) 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 ErrIntOverflowSync - } - 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: Response: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Response: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Changes", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Changes = append(m.Changes, &aclpb.RawChange{}) - if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.SnapshotPath = append(m.SnapshotPath, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} func skipSync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 From b5aa0b135f465258dc0bc8e03188460d4e75eaba Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 12 Sep 2022 21:25:20 +0200 Subject: [PATCH 09/44] Fix list package and some storage stuff --- pkg/acl/list/list_test.go | 14 +-- pkg/acl/storage/liststorage.go | 1 + pkg/acl/storage/storage.go | 3 - pkg/acl/storage/treestorage.go | 1 + pkg/acl/testutils/acllistbuilder/keychain.go | 8 +- .../acllistbuilder/liststoragebuilder.go | 79 ++++++++-------- .../liststoragebuildergraph_nix.go | 2 +- pkg/acl/tree/tests/benches_test.go | 91 ------------------- 8 files changed, 53 insertions(+), 146 deletions(-) delete mode 100644 pkg/acl/tree/tests/benches_test.go diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index acc5f570..fd249cfb 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -23,9 +23,9 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { idC := keychain.GetIdentity("C") // checking final state - assert.Equal(t, aclpb.ACLChange_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) - assert.Equal(t, aclpb.ACLChange_Writer, aclList.ACLState().GetUserStates()[idB].Permissions) - assert.Equal(t, aclpb.ACLChange_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) + assert.Equal(t, aclpb.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) + assert.Equal(t, aclpb.ACLUserPermissions_Writer, aclList.ACLState().GetUserStates()[idB].Permissions) + assert.Equal(t, aclpb.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) assert.Equal(t, aclList.Head().Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) var records []*ACLRecord @@ -44,7 +44,7 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { assert.NoError(t, err, "should have no error with permissions of B in the record 2") assert.Equal(t, UserPermissionPair{ Identity: idB, - Permission: aclpb.ACLChange_Writer, + Permission: aclpb.ACLUserPermissions_Writer, }, perm) } @@ -62,8 +62,8 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { idC := keychain.GetIdentity("C") // checking final state - assert.Equal(t, aclpb.ACLChange_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) - assert.Equal(t, aclpb.ACLChange_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) + assert.Equal(t, aclpb.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) + assert.Equal(t, aclpb.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) assert.Equal(t, aclList.Head().Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) _, exists := aclList.ACLState().GetUserStates()[idB] @@ -84,7 +84,7 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { assert.NoError(t, err, "should have no error with permissions of B in the record 2") assert.Equal(t, UserPermissionPair{ Identity: idB, - Permission: aclpb.ACLChange_Writer, + Permission: aclpb.ACLUserPermissions_Writer, }, perm) _, err = aclList.ACLState().PermissionsAtRecord(records[3].Id, idB) diff --git a/pkg/acl/storage/liststorage.go b/pkg/acl/storage/liststorage.go index 90cb9cdc..ccb5b5da 100644 --- a/pkg/acl/storage/liststorage.go +++ b/pkg/acl/storage/liststorage.go @@ -7,6 +7,7 @@ import ( type ListStorage interface { Storage + Header() (*aclpb.ACLHeader, error) Head() (*aclpb.RawACLRecord, error) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) diff --git a/pkg/acl/storage/storage.go b/pkg/acl/storage/storage.go index 7f14166c..42af1815 100644 --- a/pkg/acl/storage/storage.go +++ b/pkg/acl/storage/storage.go @@ -1,8 +1,5 @@ package storage -import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - type Storage interface { ID() (string, error) - Header() (*aclpb.Header, error) } diff --git a/pkg/acl/storage/treestorage.go b/pkg/acl/storage/treestorage.go index 3a5d8866..0e7d09a1 100644 --- a/pkg/acl/storage/treestorage.go +++ b/pkg/acl/storage/treestorage.go @@ -7,6 +7,7 @@ import ( type TreeStorage interface { Storage + Header() (*aclpb.TreeHeader, error) Heads() ([]string, error) SetHeads(heads []string) error diff --git a/pkg/acl/testutils/acllistbuilder/keychain.go b/pkg/acl/testutils/acllistbuilder/keychain.go index d968cd4c..b6112ae9 100644 --- a/pkg/acl/testutils/acllistbuilder/keychain.go +++ b/pkg/acl/testutils/acllistbuilder/keychain.go @@ -99,12 +99,14 @@ func (k *Keychain) AddSigningKey(key *Key) { } k.SigningKeys[key.Name] = newPrivKey - res, err := k.coder.EncodeToString(pubKey) + rawPubKey, err := pubKey.Raw() if err != nil { panic(err) } - k.SigningKeysByIdentity[res] = newPrivKey - k.GeneratedIdentities[key.Name] = res + encoded := string(rawPubKey) + + k.SigningKeysByIdentity[encoded] = newPrivKey + k.GeneratedIdentities[key.Name] = encoded } func (k *Keychain) AddReadKey(key *Key) { diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index 4dc5086e..c6d8703a 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -23,7 +23,7 @@ type ACLListStorageBuilder struct { rawRecords []*aclpb.RawACLRecord indexes map[string]int keychain *Keychain - header *aclpb.Header + header *aclpb.ACLHeader id string } @@ -64,7 +64,7 @@ func (t *ACLListStorageBuilder) createRaw(rec *aclpb.ACLRecord) *aclpb.RawACLRec panic("should be able to marshal final acl message!") } - signature, err := t.keychain.SigningKeysByIdentity[rec.Identity].Sign(aclMarshaled) + signature, err := t.keychain.SigningKeysByIdentity[string(rec.Identity)].Sign(aclMarshaled) if err != nil { panic("should be able to sign final acl message!") } @@ -86,7 +86,7 @@ func (t *ACLListStorageBuilder) Head() (*aclpb.RawACLRecord, error) { return t.getRecord(len(t.records) - 1), nil } -func (t *ACLListStorageBuilder) Header() (*aclpb.Header, error) { +func (t *ACLListStorageBuilder) Header() (*aclpb.ACLHeader, error) { return t.header, nil } @@ -134,26 +134,26 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) { func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.ACLRecord { k := t.keychain.GetKey(rec.ReadKey).(*SymKey) - var aclChangeContents []*aclpb.ACLChangeACLContentValue + var aclChangeContents []*aclpb.ACLContentValue for _, ch := range rec.AclChanges { aclChangeContent := t.parseACLChange(ch) aclChangeContents = append(aclChangeContents, aclChangeContent) } - data := &aclpb.ACLChangeACLData{ + data := &aclpb.ACLData{ AclContent: aclChangeContents, } bytes, _ := data.Marshal() return &aclpb.ACLRecord{ PrevId: prevId, - Identity: t.keychain.GetIdentity(rec.Identity), + Identity: []byte(t.keychain.GetIdentity(rec.Identity)), Data: bytes, CurrentReadKeyHash: k.Hash, Timestamp: time.Now().Unix(), } } -func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLChangeACLContentValue) { +func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLContentValue) { switch { case ch.UserAdd != nil: add := ch.UserAdd @@ -161,10 +161,10 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL encKey := t.keychain.GetKey(add.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserAdd{ - UserAdd: &aclpb.ACLUserPermissionsAdd{ - Identity: t.keychain.GetIdentity(add.Identity), + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserAdd{ + UserAdd: &aclpb.ACLUserAdd{ + Identity: []byte(t.keychain.GetIdentity(add.Identity)), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), Permissions: t.convertPermission(add.Permission), @@ -185,10 +185,10 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL panic(err) } - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserJoin{ - UserJoin: &aclpb.ACLUserPermissionsJoin{ - Identity: t.keychain.GetIdentity(join.Identity), + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserJoin{ + UserJoin: &aclpb.ACLUserJoin{ + Identity: []byte(t.keychain.GetIdentity(join.Identity)), EncryptionKey: rawKey, AcceptSignature: signature, UserInviteId: join.InviteId, @@ -203,9 +203,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL GetKey(invite.EncryptionKey).(encryptionkey.PrivKey) rawEncKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserInvite{ - UserInvite: &aclpb.ACLUserPermissionsInvite{ + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserInvite{ + UserInvite: &aclpb.ACLUserInvite{ AcceptPublicKey: rawAcceptKey, EncryptPublicKey: rawEncKey, EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), @@ -217,10 +217,10 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL case ch.UserConfirm != nil: confirm := ch.UserConfirm - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserConfirm{ - UserConfirm: &aclpb.ACLUserPermissionsConfirm{ - Identity: t.keychain.GetIdentity(confirm.Identity), + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserConfirm{ + UserConfirm: &aclpb.ACLUserConfirm{ + Identity: []byte(t.keychain.GetIdentity(confirm.Identity)), UserAddId: confirm.UserAddId, }, }, @@ -228,10 +228,10 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL case ch.UserPermissionChange != nil: permissionChange := ch.UserPermissionChange - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserPermissionChange{ - UserPermissionChange: &aclpb.ACLUserPermissionsPermissionChange{ - Identity: t.keychain.GetIdentity(permissionChange.Identity), + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserPermissionChange{ + UserPermissionChange: &aclpb.ACLUserPermissionChange{ + Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)), Permissions: t.convertPermission(permissionChange.Permission), }, }, @@ -241,7 +241,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey) - var replaces []*aclpb.ACLChangeReadKeyReplace + var replaces []*aclpb.ACLReadKeyReplace for _, id := range remove.IdentitiesLeft { identity := t.keychain.GetIdentity(id) encKey := t.keychain.EncryptionKeys[id] @@ -250,17 +250,17 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL if err != nil { panic(err) } - replaces = append(replaces, &aclpb.ACLChangeReadKeyReplace{ - Identity: identity, + replaces = append(replaces, &aclpb.ACLReadKeyReplace{ + Identity: []byte(identity), EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) } - convCh = &aclpb.ACLChangeACLContentValue{ - Value: &aclpb.ACLChangeACLContentValueValueOfUserRemove{ - UserRemove: &aclpb.ACLUserPermissionsRemove{ - Identity: t.keychain.GetIdentity(remove.RemovedIdentity), + convCh = &aclpb.ACLContentValue{ + Value: &aclpb.ACLContentValue_UserRemove{ + UserRemove: &aclpb.ACLUserRemove{ + Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)), ReadKeyReplaces: replaces, }, }, @@ -289,11 +289,11 @@ func (t *ACLListStorageBuilder) encryptReadKeys(keys []string, encKey encryption func (t *ACLListStorageBuilder) convertPermission(perm string) aclpb.ACLUserPermissions { switch perm { case "admin": - return aclpb.ACLChange_Admin + return aclpb.ACLUserPermissions_Admin case "writer": - return aclpb.ACLChange_Writer + return aclpb.ACLUserPermissions_Writer case "reader": - return aclpb.ACLChange_Reader + return aclpb.ACLUserPermissions_Reader default: panic(fmt.Sprintf("incorrect permission: %s", perm)) } @@ -310,11 +310,8 @@ func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclpb.ACLRecord, id } func (t *ACLListStorageBuilder) createHeaderAndId() { - t.header = &aclpb.Header{ - FirstId: t.rawRecords[0].Id, - AclListId: "", - WorkspaceId: "", - DocType: aclpb.Header_ACL, + t.header = &aclpb.ACLHeader{ + FirstId: t.rawRecords[0].Id, } bytes, _ := t.header.Marshal() id, _ := cid.NewCIDFromBytes(bytes) diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go index 9c7bf581..d7dfc85f 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go @@ -37,7 +37,7 @@ func (t *ACLListStorageBuilder) Graph() (string, error) { style := "solid" var chSymbs []string - aclData := &aclpb.ACLChangeACLData{} + aclData := &aclpb.ACLData{} err := proto.Unmarshal(r.GetData(), aclData) if err != nil { return err diff --git a/pkg/acl/tree/tests/benches_test.go b/pkg/acl/tree/tests/benches_test.go deleted file mode 100644 index 703cb7a0..00000000 --- a/pkg/acl/tree/tests/benches_test.go +++ /dev/null @@ -1,91 +0,0 @@ -package tests - -import ( - "bytes" - "math/rand" - "testing" - "time" -) - -func BenchmarkHashes(b *testing.B) { - genRandomBytes := func() [][]byte { - var res [][]byte - s := rand.NewSource(time.Now().Unix()) - r := rand.New(s) - for i := 0; i < 10000; i++ { - var newBytes []byte - for j := 0; j < 64; j++ { - newBytes = append(newBytes, byte(r.Intn(256))) - } - res = append(res, newBytes) - } - return res - } - makeStrings := func(input [][]byte) []string { - var res []string - for _, bytes := range input { - res = append(res, string(bytes)) - } - return res - } - res := genRandomBytes() - stringRes := makeStrings(res) - stringMap := map[string]struct{}{} - b.Run("string bytes hash map write", func(b *testing.B) { - stringMap = map[string]struct{}{} - for i := 0; i < b.N; i++ { - for _, bytes := range res { - stringMap[string(bytes)] = struct{}{} - } - } - b.Run("hash map read", func(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, bytes := range res { - _, _ = stringMap[string(bytes)] - } - } - }) - }) - b.Run("compare byte slices as strings", func(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, bytes := range res { - if string(bytes) == string(bytes) { - - } - } - } - }) - b.Run("compare byte slices", func(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, bt := range res { - if bytes.Compare(bt, bt) == 0 { - - } - } - } - }) - b.Run("compare strings", func(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, st := range stringRes { - if st == st { - - } - } - } - }) - b.Run("string hash map write", func(b *testing.B) { - stringMap = map[string]struct{}{} - for i := 0; i < b.N; i++ { - for _, str := range stringRes { - stringMap[str] = struct{}{} - } - } - b.Run("hash map read", func(b *testing.B) { - for i := 0; i < b.N; i++ { - for _, str := range stringRes { - _, _ = stringMap[str] - } - } - }) - }) -} From 77bbb64febf7d82f78c39efaf87b098579c95e26 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 09:04:47 +0200 Subject: [PATCH 10/44] Fix pkg tests --- pkg/acl/common/keychain.go | 2 +- pkg/acl/tree/changebuilder.go | 6 ++++-- pkg/acl/tree/changevalidator.go | 2 +- pkg/acl/tree/objecttree_test.go | 32 ++++++++++++++------------------ 4 files changed, 20 insertions(+), 22 deletions(-) diff --git a/pkg/acl/common/keychain.go b/pkg/acl/common/keychain.go index 2842ae5e..d90965c6 100644 --- a/pkg/acl/common/keychain.go +++ b/pkg/acl/common/keychain.go @@ -21,7 +21,7 @@ func (k *Keychain) GetOrAdd(identity string) (signingkey.PubKey, error) { if key, exists := k.keys[identity]; exists { return key, nil } - res, err := k.decoder.DecodeFromString(identity) + res, err := k.decoder.DecodeFromBytes([]byte(identity)) if err != nil { return nil, err } diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 3a2f0701..67985c82 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -60,13 +60,15 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } if verify { - identityKey, err := c.keys.GetOrAdd(ch.Identity) + var identityKey signingkey.PubKey + identityKey, err = c.keys.GetOrAdd(ch.Identity) if err != nil { return } // verifying signature - res, err := identityKey.Verify(raw.Payload, raw.Signature) + var res bool + res, err = identityKey.Verify(raw.Payload, raw.Signature) if err != nil { return } diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index 1dfac831..bbc337cf 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -43,7 +43,7 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c state = aclList.ACLState() ) // checking if the user could write - perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Content.Identity) + perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Identity) if err != nil { return } diff --git a/pkg/acl/tree/objecttree_test.go b/pkg/acl/tree/objecttree_test.go index c73ce3ff..6e43d8d3 100644 --- a/pkg/acl/tree/objecttree_test.go +++ b/pkg/acl/tree/objecttree_test.go @@ -14,7 +14,7 @@ import ( type mockChangeCreator struct{} -func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *aclpb.RawChange { +func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *aclpb.RawTreeChangeWithId { aclChange := &aclpb.TreeChange{ TreeHeadIds: prevIds, AclHeadId: aclId, @@ -51,19 +51,15 @@ type mockChangeBuilder struct { originalBuilder ChangeBuilder } -func (c *mockChangeBuilder) ConvertFromRaw(rawChange *aclpb.RawChange) (ch *Change, err error) { - return c.originalBuilder.ConvertFromRaw(rawChange) +func (c *mockChangeBuilder) ConvertFromRaw(rawChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { + return c.originalBuilder.ConvertFromRaw(rawChange, false) } -func (c *mockChangeBuilder) ConvertFromRawAndVerify(rawChange *aclpb.RawChange) (ch *Change, err error) { - return c.originalBuilder.ConvertFromRaw(rawChange) -} - -func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawChange, err error) { +func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) { panic("implement me") } -func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawChange, err error) { +func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { return c.originalBuilder.BuildRaw(ch) } @@ -141,7 +137,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } @@ -182,7 +178,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("0", aclList.Head().Id, "", true, ""), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -202,7 +198,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -224,7 +220,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -268,7 +264,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -287,7 +283,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -361,7 +357,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -437,7 +433,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawChange{ + rawChanges := []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -446,7 +442,7 @@ func TestObjectTree(t *testing.T) { require.NoError(t, err, "adding changes should be without error") require.Equal(t, "3", objTree.Root().Id) - rawChanges = []*aclpb.RawChange{ + rawChanges = []*aclpb.RawTreeChangeWithId{ changeCreator.createRaw("4", aclList.Head().Id, "0", false, "2"), changeCreator.createRaw("5", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("6", aclList.Head().Id, "0", false, "3", "4", "5"), From a907cde3993868dbf27938fe609fd2bbc02db2b5 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 10:44:02 +0200 Subject: [PATCH 11/44] Use string instead of bytes, to simplify code --- pkg/acl/account/accountdata.go | 3 +- pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 296 ++++++++---------- .../aclchanges/aclpb/protos/aclchanges.proto | 22 +- pkg/acl/list/aclstate.go | 46 ++- pkg/acl/list/changebuilder.go | 4 +- .../acllistbuilder/liststoragebuilder.go | 14 +- pkg/acl/tree/change.go | 1 - pkg/acl/tree/changebuilder.go | 2 +- pkg/acl/tree/changevalidator.go | 2 +- pkg/acl/tree/objecttreefactory.go | 2 +- pkg/acl/tree/signablecontent.go | 2 +- 11 files changed, 185 insertions(+), 209 deletions(-) diff --git a/pkg/acl/account/accountdata.go b/pkg/acl/account/accountdata.go index bc775854..1bf30c95 100644 --- a/pkg/acl/account/accountdata.go +++ b/pkg/acl/account/accountdata.go @@ -7,7 +7,8 @@ import ( ) type AccountData struct { // TODO: create a convenient constructor for this - Identity []byte // TODO: this is essentially the same as sign key + // Identity is non utf8 encoded, but we use this type, to eliminate copying between []byte to string conversions + Identity string SignKey signingkey.PrivKey EncKey encryptionkey.PrivKey Decoder keys.Decoder diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index ecd124b1..9c7c75b4 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -380,7 +380,7 @@ func (m *ACLState) GetInvites() map[string]*ACLUserInvite { } type ACLUserState struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` @@ -420,11 +420,11 @@ func (m *ACLUserState) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserState proto.InternalMessageInfo -func (m *ACLUserState) GetIdentity() []byte { +func (m *ACLUserState) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserState) GetEncryptionKey() []byte { @@ -457,7 +457,7 @@ func (m *ACLUserState) GetIsConfirmed() bool { // we already know identity and encryptionKey type ACLUserAdd struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` @@ -496,11 +496,11 @@ func (m *ACLUserAdd) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserAdd proto.InternalMessageInfo -func (m *ACLUserAdd) GetIdentity() []byte { +func (m *ACLUserAdd) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserAdd) GetEncryptionKey() []byte { @@ -526,7 +526,7 @@ func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { // TODO: this is not used as of now type ACLUserConfirm struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` } @@ -563,11 +563,11 @@ func (m *ACLUserConfirm) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserConfirm proto.InternalMessageInfo -func (m *ACLUserConfirm) GetIdentity() []byte { +func (m *ACLUserConfirm) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserConfirm) GetUserAddId() string { @@ -654,7 +654,7 @@ func (m *ACLUserInvite) GetInviteId() string { } type ACLUserJoin struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"` @@ -694,11 +694,11 @@ func (m *ACLUserJoin) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserJoin proto.InternalMessageInfo -func (m *ACLUserJoin) GetIdentity() []byte { +func (m *ACLUserJoin) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserJoin) GetEncryptionKey() []byte { @@ -730,7 +730,7 @@ func (m *ACLUserJoin) GetEncryptedReadKeys() [][]byte { } type ACLUserRemove struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` ReadKeyReplaces []*ACLReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` } @@ -767,11 +767,11 @@ func (m *ACLUserRemove) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserRemove proto.InternalMessageInfo -func (m *ACLUserRemove) GetIdentity() []byte { +func (m *ACLUserRemove) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserRemove) GetReadKeyReplaces() []*ACLReadKeyReplace { @@ -782,7 +782,7 @@ func (m *ACLUserRemove) GetReadKeyReplaces() []*ACLReadKeyReplace { } type ACLReadKeyReplace struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKey []byte `protobuf:"bytes,3,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` } @@ -820,11 +820,11 @@ func (m *ACLReadKeyReplace) XXX_DiscardUnknown() { var xxx_messageInfo_ACLReadKeyReplace proto.InternalMessageInfo -func (m *ACLReadKeyReplace) GetIdentity() []byte { +func (m *ACLReadKeyReplace) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLReadKeyReplace) GetEncryptionKey() []byte { @@ -842,7 +842,7 @@ func (m *ACLReadKeyReplace) GetEncryptedReadKey() []byte { } type ACLUserPermissionChange struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` } @@ -879,11 +879,11 @@ func (m *ACLUserPermissionChange) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserPermissionChange proto.InternalMessageInfo -func (m *ACLUserPermissionChange) GetIdentity() []byte { +func (m *ACLUserPermissionChange) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { @@ -895,7 +895,7 @@ func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { type ACLRecord struct { PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` @@ -941,11 +941,11 @@ func (m *ACLRecord) GetPrevId() string { return "" } -func (m *ACLRecord) GetIdentity() []byte { +func (m *ACLRecord) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *ACLRecord) GetData() []byte { @@ -971,7 +971,7 @@ func (m *ACLRecord) GetTimestamp() int64 { type ACLHeader struct { FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` } func (m *ACLHeader) Reset() { *m = ACLHeader{} } @@ -1014,11 +1014,11 @@ func (m *ACLHeader) GetFirstId() string { return "" } -func (m *ACLHeader) GetIdentity() []byte { +func (m *ACLHeader) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } type RawTreeChange struct { @@ -1132,7 +1132,7 @@ type TreeChange struct { ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` } @@ -1211,11 +1211,11 @@ func (m *TreeChange) GetTimestamp() int64 { return 0 } -func (m *TreeChange) GetIdentity() []byte { +func (m *TreeChange) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *TreeChange) GetIsSnapshot() bool { @@ -1229,7 +1229,7 @@ type TreeHeader struct { FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` AclId string `protobuf:"bytes,2,opt,name=aclId,proto3" json:"aclId,omitempty"` TreeHeaderType TreeHeaderType `protobuf:"varint,3,opt,name=treeHeaderType,proto3,enum=acl.TreeHeaderType" json:"treeHeaderType,omitempty"` - Identity []byte `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` + Identity string `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` } @@ -1287,11 +1287,11 @@ func (m *TreeHeader) GetTreeHeaderType() TreeHeaderType { return TreeHeaderType_Object } -func (m *TreeHeader) GetIdentity() []byte { +func (m *TreeHeader) GetIdentity() string { if m != nil { return m.Identity } - return nil + return "" } func (m *TreeHeader) GetData() []byte { @@ -1361,44 +1361,44 @@ var fileDescriptor_37a022c841a51877 = []byte{ 0xf8, 0x27, 0x91, 0x48, 0xa7, 0x38, 0x53, 0xdd, 0xfc, 0x0c, 0x5a, 0xb6, 0x00, 0x75, 0xa0, 0xfa, 0x9c, 0x4e, 0x55, 0x1d, 0x35, 0xb0, 0x5c, 0xa2, 0x1d, 0xc3, 0xc3, 0xa2, 0x5a, 0xd1, 0xa6, 0x58, 0x2b, 0x7c, 0xe0, 0xbe, 0xe7, 0xf8, 0xbf, 0x38, 0xd0, 0xb2, 0x5d, 0x44, 0x9b, 0xb0, 0xc2, 0x42, - 0x1a, 0x09, 0x26, 0xa6, 0xa6, 0xf2, 0xf3, 0xbd, 0xe4, 0x82, 0x46, 0x41, 0x3a, 0x4d, 0x04, 0x8b, - 0xa3, 0x03, 0x3a, 0x35, 0xe5, 0x5f, 0x06, 0xd1, 0x9b, 0xb0, 0x6e, 0x00, 0x1a, 0x62, 0xcd, 0x92, - 0x0e, 0xb1, 0x85, 0xe7, 0x05, 0xe8, 0x7d, 0x68, 0x26, 0x79, 0xa5, 0x71, 0x55, 0x56, 0xed, 0xbd, - 0x7b, 0x8b, 0x0b, 0x94, 0x63, 0x5b, 0x17, 0x6d, 0x43, 0x93, 0x71, 0x93, 0x7e, 0x1a, 0xaa, 0xea, - 0x5a, 0xc1, 0x36, 0xe4, 0xff, 0xe0, 0x00, 0x14, 0xbf, 0xd5, 0xff, 0x28, 0x36, 0xff, 0x11, 0xb4, - 0xcb, 0xe5, 0x7e, 0xab, 0xf3, 0x5b, 0xd0, 0x30, 0xfd, 0x62, 0x14, 0x2a, 0xc7, 0x1b, 0xb8, 0x00, - 0xfc, 0xdf, 0x1d, 0x58, 0x2d, 0x15, 0x00, 0xda, 0x81, 0x35, 0x12, 0x04, 0x34, 0x11, 0x8f, 0xcf, - 0x4f, 0xc6, 0x2c, 0x38, 0xa0, 0xd9, 0x91, 0xb3, 0x30, 0xda, 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x5c, + 0x61, 0x76, 0xa5, 0xcb, 0xdd, 0x99, 0xcb, 0x11, 0x2c, 0x85, 0x44, 0x10, 0x13, 0x93, 0x5a, 0xa3, + 0x1e, 0xa0, 0xe0, 0x3c, 0x4d, 0x69, 0x24, 0x70, 0xf1, 0x54, 0xa8, 0x92, 0x58, 0xc2, 0x0b, 0x24, + 0xf2, 0x1f, 0x16, 0x6c, 0x42, 0xb9, 0x20, 0x93, 0x44, 0x55, 0x75, 0x15, 0x17, 0x80, 0xdf, 0x57, + 0x2e, 0x0e, 0x29, 0x09, 0x69, 0x2a, 0x87, 0x93, 0x67, 0x2c, 0xe5, 0x22, 0xf7, 0x31, 0xdb, 0xde, + 0xe6, 0xa4, 0xff, 0x29, 0xac, 0x62, 0x72, 0x79, 0x9c, 0x52, 0x6a, 0xe8, 0xfc, 0x97, 0x33, 0x8e, + 0x3f, 0x80, 0x3b, 0xa5, 0x83, 0x9e, 0x32, 0x71, 0x36, 0x52, 0x46, 0x29, 0xb9, 0x34, 0x83, 0x86, + 0x3e, 0xb0, 0x00, 0xcc, 0x60, 0xe4, 0xe6, 0x83, 0xd1, 0xb7, 0x2e, 0x80, 0xe5, 0xcb, 0x36, 0x34, + 0x45, 0x4a, 0xa9, 0x0c, 0x70, 0x14, 0xea, 0x47, 0xb6, 0x81, 0x6d, 0x48, 0x1e, 0x4f, 0x82, 0xb1, + 0xde, 0x65, 0x3d, 0x2e, 0x07, 0xd0, 0x6b, 0xd0, 0xe6, 0x11, 0x49, 0xf8, 0x59, 0x2c, 0xf6, 0x09, + 0x97, 0x3f, 0x9f, 0x9e, 0xc1, 0x66, 0x50, 0x79, 0x8f, 0x99, 0xfe, 0xe4, 0x80, 0xa0, 0xd2, 0xd1, + 0xc2, 0x36, 0x74, 0x43, 0xde, 0x6a, 0x7f, 0x2f, 0x6f, 0xcb, 0x33, 0x79, 0x2b, 0x25, 0xa4, 0x3e, + 0x53, 0x35, 0x5d, 0x00, 0xc6, 0x8f, 0x8c, 0x7f, 0xde, 0x8a, 0x7a, 0xbe, 0x2c, 0xc4, 0xff, 0xde, + 0xd1, 0x14, 0xfd, 0x65, 0xd6, 0x37, 0xa0, 0x46, 0x82, 0x71, 0x4e, 0x8b, 0xde, 0xa0, 0x0f, 0xa1, + 0x2d, 0x72, 0xeb, 0xe3, 0x69, 0xa2, 0xdb, 0x56, 0xdb, 0x0c, 0x53, 0xc7, 0x25, 0x11, 0x9e, 0x51, + 0x2d, 0xf9, 0xbd, 0x74, 0x43, 0xb5, 0xd7, 0x8a, 0x6a, 0xdf, 0x7d, 0x08, 0x68, 0xfe, 0x37, 0x43, + 0x0d, 0xa8, 0xf5, 0xc3, 0x09, 0x8b, 0x3a, 0x15, 0x04, 0xb0, 0xfc, 0x34, 0x65, 0x82, 0xa6, 0x1d, + 0x47, 0xae, 0xb1, 0xba, 0xaa, 0xe3, 0xa2, 0x26, 0xd4, 0x75, 0x6b, 0x0b, 0x3b, 0xd5, 0xdd, 0xd7, + 0xa1, 0x5d, 0xf6, 0x4b, 0xaa, 0x7e, 0x7e, 0xf2, 0x15, 0x0d, 0x44, 0xa7, 0x22, 0x4f, 0x3b, 0x4a, + 0x48, 0x40, 0x3b, 0xce, 0xfe, 0x2b, 0x3f, 0x5e, 0x75, 0x9d, 0x17, 0x57, 0x5d, 0xe7, 0xd7, 0xab, + 0xae, 0xf3, 0xcd, 0x75, 0xb7, 0xf2, 0xe2, 0xba, 0x5b, 0xf9, 0xf9, 0xba, 0x5b, 0xf9, 0xb2, 0xa6, + 0x86, 0xfd, 0x93, 0x65, 0x35, 0xdb, 0xbf, 0xf3, 0x67, 0x00, 0x00, 0x00, 0xff, 0xff, 0x7e, 0xb7, + 0x4f, 0x73, 0x0f, 0x0c, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -3735,7 +3735,7 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -3745,25 +3745,23 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -3924,7 +3922,7 @@ func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -3934,25 +3932,23 @@ func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4093,7 +4089,7 @@ func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4103,25 +4099,23 @@ func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4410,7 +4404,7 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4420,25 +4414,23 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4626,7 +4618,7 @@ func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4636,25 +4628,23 @@ func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -4744,7 +4734,7 @@ func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4754,25 +4744,23 @@ func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 2 { @@ -4896,7 +4884,7 @@ func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4906,25 +4894,23 @@ func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 2: if wireType != 0 { @@ -5031,7 +5017,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5041,25 +5027,23 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 3: if wireType != 2 { @@ -5219,7 +5203,7 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5229,25 +5213,23 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -5705,7 +5687,7 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5715,25 +5697,23 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 8: if wireType != 0 { @@ -5892,7 +5872,7 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var byteLen int + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5902,25 +5882,23 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - byteLen |= int(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - if byteLen < 0 { + intStringLen := int(stringLen) + if intStringLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + byteLen + postIndex := iNdEx + intStringLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } + m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 5: if wireType != 2 { diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto index 73a3fc1f..2ac1e5f7 100644 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto @@ -33,7 +33,7 @@ message ACLState { } message ACLUserState { - bytes identity = 1; + string identity = 1; bytes encryptionKey = 2; repeated bytes encryptedReadKeys = 3; // all read keys that we know ACLUserPermissions permissions = 4; @@ -42,7 +42,7 @@ message ACLUserState { // we already know identity and encryptionKey message ACLUserAdd { - bytes identity = 1; // public signing key + string identity = 1; // public signing key bytes encryptionKey = 2; // public encryption key repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user ACLUserPermissions permissions = 4; @@ -50,7 +50,7 @@ message ACLUserAdd { // TODO: this is not used as of now message ACLUserConfirm { // not needed for read permissions - bytes identity = 1; // not needed + string identity = 1; // not needed string userAddId = 2; } @@ -63,7 +63,7 @@ message ACLUserInvite { } message ACLUserJoin { - bytes identity = 1; + string identity = 1; bytes encryptionKey = 2; bytes acceptSignature = 3; // sign acceptPublicKey string userInviteId = 4; @@ -71,18 +71,18 @@ message ACLUserJoin { } message ACLUserRemove { - bytes identity = 1; + string identity = 1; repeated ACLReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users } message ACLReadKeyReplace { - bytes identity = 1; + string identity = 1; bytes encryptionKey = 2; bytes encryptedReadKey = 3; } message ACLUserPermissionChange { - bytes identity = 1; + string identity = 1; ACLUserPermissions permissions = 2; } @@ -95,7 +95,7 @@ enum ACLUserPermissions { message ACLRecord { string prevId = 1; - bytes identity = 2; + string identity = 2; bytes data = 3; uint64 currentReadKeyHash = 4; int64 timestamp = 5; @@ -103,7 +103,7 @@ message ACLRecord { message ACLHeader { string firstId = 1; - bytes identity = 2; // the identity of the creator + string identity = 2; // the identity of the creator } // Tree protos @@ -125,7 +125,7 @@ message TreeChange { bytes changesData = 4; uint64 currentReadKeyHash = 5; int64 timestamp = 6; - bytes identity = 7; + string identity = 7; bool isSnapshot = 8; } @@ -138,6 +138,6 @@ message TreeHeader { string firstId = 1; string aclId = 2; TreeHeaderType treeHeaderType = 3; - bytes identity = 4; + string identity = 4; bytes data = 5; // this should be reserved for the client to add the data it needs } diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index d7a849fb..fceeaadc 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -1,7 +1,6 @@ package list import ( - "bytes" "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" @@ -148,7 +147,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { var permissions []UserPermissionPair for _, state := range st.userStates { permission := UserPermissionPair{ - Identity: string(state.Identity), + Identity: state.Identity, Permission: state.Permissions, } permissions = append(permissions, permission) @@ -158,7 +157,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { return nil } -func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity []byte) (err error) { +func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity string) (err error) { defer func() { if err != nil { return @@ -171,7 +170,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden skipIdentityCheck := st.isUserJoin(changeData) || (st.currentReadKeyHash == 0 && st.isUserAdd(changeData, identity)) if !skipIdentityCheck { // we check signature when we add this to the Tree, so no need to do it here - if _, exists := st.userStates[string(identity)]; !exists { + if _, exists := st.userStates[identity]; !exists { err = ErrNoSuchUser return } @@ -212,12 +211,11 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { } func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { - chIdentity := string(ch.Identity) - if _, exists := st.userStates[chIdentity]; !exists { + if _, exists := st.userStates[ch.Identity]; !exists { return ErrNoSuchUser } - st.userStates[chIdentity].Permissions = ch.Permissions + st.userStates[ch.Identity].Permissions = ch.Permissions return nil } @@ -231,9 +229,8 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) } - chIdentity := string(ch.Identity) - if _, exists = st.userStates[chIdentity]; exists { + if _, exists = st.userStates[ch.Identity]; exists { return ErrUserAlreadyExists } @@ -244,7 +241,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { return fmt.Errorf("public key verifying invite accepts is given in incorrect format: %v", err) } - res, err := verificationKey.(signingkey.PubKey).Verify(ch.Identity, signature) + res, err := verificationKey.(signingkey.PubKey).Verify([]byte(ch.Identity), signature) if err != nil { return fmt.Errorf("verification returned error: %w", err) } @@ -253,7 +250,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { } // if ourselves -> we need to decrypt the read keys - if st.identity == chIdentity { + if st.identity == ch.Identity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -272,24 +269,23 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { Permissions: invite.Permissions, IsConfirmed: true, } - st.userStates[chIdentity] = userState + st.userStates[ch.Identity] = userState return nil } func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { - chIdentity := string(ch.Identity) - if _, exists := st.userStates[chIdentity]; exists { + if _, exists := st.userStates[ch.Identity]; exists { return ErrUserAlreadyExists } - st.userStates[chIdentity] = &aclpb.ACLUserState{ + st.userStates[ch.Identity] = &aclpb.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, EncryptedReadKeys: ch.EncryptedReadKeys, } - if chIdentity == st.identity { + if ch.Identity == st.identity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -304,16 +300,15 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { } func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { - chIdentity := string(ch.Identity) - if chIdentity == st.identity { + if ch.Identity == st.identity { return ErrDocumentForbidden } - if _, exists := st.userStates[chIdentity]; !exists { + if _, exists := st.userStates[ch.Identity]; !exists { return ErrNoSuchUser } - delete(st.userStates, chIdentity) + delete(st.userStates, ch.Identity) for _, replace := range ch.ReadKeyReplaces { repIdentity := string(replace.Identity) @@ -364,8 +359,8 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermissions) bool { - state, exists := st.userStates[string(identity)] +func (st *ACLState) hasPermission(identity string, permission aclpb.ACLUserPermissions) bool { + state, exists := st.userStates[identity] if !exists { return false } @@ -378,10 +373,13 @@ func (st *ACLState) isUserJoin(data *aclpb.ACLData) bool { return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil } -func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity []byte) bool { +func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity string) bool { + if len(data.GetAclContent()) == 0 { + return false + } // if we have a UserAdd, then it should always be the first one applied userAdd := data.GetAclContent()[0].GetUserAdd() - return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0 + return data.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == identity } func (st *ACLState) GetUserStates() map[string]*aclpb.ACLUserState { diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go index c6413cb0..52a44e18 100644 --- a/pkg/acl/list/changebuilder.go +++ b/pkg/acl/list/changebuilder.go @@ -82,7 +82,7 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey. ch := &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserAdd{ UserAdd: &aclpb.ACLUserAdd{ - Identity: []byte(identity), + Identity: identity, EncryptionKey: rawKey, EncryptedReadKeys: encryptedKeys, Permissions: permissions, @@ -98,7 +98,7 @@ func (c *aclChangeBuilder) BuildAndApply() (*ACLRecord, []byte, error) { PrevId: c.list.Head().Id, CurrentReadKeyHash: c.readKeyHash, Timestamp: int64(time.Now().Nanosecond()), - Identity: c.acc.Identity, + Identity: string(c.acc.Identity), } marshalledData, err := proto.Marshal(c.aclData) diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index c6d8703a..fb73d450 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -146,7 +146,7 @@ func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.A return &aclpb.ACLRecord{ PrevId: prevId, - Identity: []byte(t.keychain.GetIdentity(rec.Identity)), + Identity: t.keychain.GetIdentity(rec.Identity), Data: bytes, CurrentReadKeyHash: k.Hash, Timestamp: time.Now().Unix(), @@ -164,7 +164,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserAdd{ UserAdd: &aclpb.ACLUserAdd{ - Identity: []byte(t.keychain.GetIdentity(add.Identity)), + Identity: t.keychain.GetIdentity(add.Identity), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), Permissions: t.convertPermission(add.Permission), @@ -188,7 +188,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserJoin{ UserJoin: &aclpb.ACLUserJoin{ - Identity: []byte(t.keychain.GetIdentity(join.Identity)), + Identity: t.keychain.GetIdentity(join.Identity), EncryptionKey: rawKey, AcceptSignature: signature, UserInviteId: join.InviteId, @@ -220,7 +220,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserConfirm{ UserConfirm: &aclpb.ACLUserConfirm{ - Identity: []byte(t.keychain.GetIdentity(confirm.Identity)), + Identity: t.keychain.GetIdentity(confirm.Identity), UserAddId: confirm.UserAddId, }, }, @@ -231,7 +231,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserPermissionChange{ UserPermissionChange: &aclpb.ACLUserPermissionChange{ - Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)), + Identity: t.keychain.GetIdentity(permissionChange.Identity), Permissions: t.convertPermission(permissionChange.Permission), }, }, @@ -251,7 +251,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL panic(err) } replaces = append(replaces, &aclpb.ACLReadKeyReplace{ - Identity: []byte(identity), + Identity: identity, EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) @@ -260,7 +260,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserRemove{ UserRemove: &aclpb.ACLUserRemove{ - Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)), + Identity: t.keychain.GetIdentity(remove.RemovedIdentity), ReadKeyReplaces: replaces, }, }, diff --git a/pkg/acl/tree/change.go b/pkg/acl/tree/change.go index cefc9327..930a7abc 100644 --- a/pkg/acl/tree/change.go +++ b/pkg/acl/tree/change.go @@ -65,7 +65,6 @@ func NewChange(id string, ch *aclpb.TreeChange, signature []byte) *Change { Content: ch, SnapshotId: ch.SnapshotBaseId, IsSnapshot: ch.IsSnapshot, - Identity: string(ch.Identity), Sign: signature, } } diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 67985c82..c58cf218 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -18,7 +18,7 @@ type BuilderContent struct { aclHeadId string snapshotBaseId string currentReadKeyHash uint64 - identity []byte + identity string isSnapshot bool signingKey signingkey.PrivKey readKey *symmetric.Key diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index bbc337cf..1dfac831 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -43,7 +43,7 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c state = aclList.ACLState() ) // checking if the user could write - perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Identity) + perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Content.Identity) if err != nil { return } diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index a62c8add..01afdc92 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -142,7 +142,7 @@ func createTreeHeaderAndId( raw *aclpb.RawTreeChangeWithId, treeType aclpb.TreeHeaderType, aclId string, - identity []byte, + identity string, headerData []byte) (header *aclpb.TreeHeader, treeId string, err error) { header = &aclpb.TreeHeader{ FirstId: raw.Id, diff --git a/pkg/acl/tree/signablecontent.go b/pkg/acl/tree/signablecontent.go index 4774c2fb..b51d1dea 100644 --- a/pkg/acl/tree/signablecontent.go +++ b/pkg/acl/tree/signablecontent.go @@ -7,6 +7,6 @@ import ( type SignableChangeContent struct { Data []byte Key signingkey.PrivKey - Identity []byte + Identity string IsSnapshot bool } From 7a62b348cd5be34d175b6573811a48161c5c0186 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 12:26:37 +0200 Subject: [PATCH 12/44] Revert "Use string instead of bytes, to simplify code" This reverts commit a907cde3993868dbf27938fe609fd2bbc02db2b5. --- pkg/acl/account/accountdata.go | 3 +- pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 296 ++++++++++-------- .../aclchanges/aclpb/protos/aclchanges.proto | 22 +- pkg/acl/list/aclstate.go | 46 +-- pkg/acl/list/changebuilder.go | 4 +- .../acllistbuilder/liststoragebuilder.go | 14 +- pkg/acl/tree/change.go | 1 + pkg/acl/tree/changebuilder.go | 2 +- pkg/acl/tree/changevalidator.go | 2 +- pkg/acl/tree/objecttreefactory.go | 2 +- pkg/acl/tree/signablecontent.go | 2 +- 11 files changed, 209 insertions(+), 185 deletions(-) diff --git a/pkg/acl/account/accountdata.go b/pkg/acl/account/accountdata.go index 1bf30c95..bc775854 100644 --- a/pkg/acl/account/accountdata.go +++ b/pkg/acl/account/accountdata.go @@ -7,8 +7,7 @@ import ( ) type AccountData struct { // TODO: create a convenient constructor for this - // Identity is non utf8 encoded, but we use this type, to eliminate copying between []byte to string conversions - Identity string + Identity []byte // TODO: this is essentially the same as sign key SignKey signingkey.PrivKey EncKey encryptionkey.PrivKey Decoder keys.Decoder diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index 9c7c75b4..ecd124b1 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -380,7 +380,7 @@ func (m *ACLState) GetInvites() map[string]*ACLUserInvite { } type ACLUserState struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` @@ -420,11 +420,11 @@ func (m *ACLUserState) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserState proto.InternalMessageInfo -func (m *ACLUserState) GetIdentity() string { +func (m *ACLUserState) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserState) GetEncryptionKey() []byte { @@ -457,7 +457,7 @@ func (m *ACLUserState) GetIsConfirmed() bool { // we already know identity and encryptionKey type ACLUserAdd struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` @@ -496,11 +496,11 @@ func (m *ACLUserAdd) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserAdd proto.InternalMessageInfo -func (m *ACLUserAdd) GetIdentity() string { +func (m *ACLUserAdd) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserAdd) GetEncryptionKey() []byte { @@ -526,7 +526,7 @@ func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { // TODO: this is not used as of now type ACLUserConfirm struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` } @@ -563,11 +563,11 @@ func (m *ACLUserConfirm) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserConfirm proto.InternalMessageInfo -func (m *ACLUserConfirm) GetIdentity() string { +func (m *ACLUserConfirm) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserConfirm) GetUserAddId() string { @@ -654,7 +654,7 @@ func (m *ACLUserInvite) GetInviteId() string { } type ACLUserJoin struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"` @@ -694,11 +694,11 @@ func (m *ACLUserJoin) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserJoin proto.InternalMessageInfo -func (m *ACLUserJoin) GetIdentity() string { +func (m *ACLUserJoin) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserJoin) GetEncryptionKey() []byte { @@ -730,7 +730,7 @@ func (m *ACLUserJoin) GetEncryptedReadKeys() [][]byte { } type ACLUserRemove struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` ReadKeyReplaces []*ACLReadKeyReplace `protobuf:"bytes,3,rep,name=readKeyReplaces,proto3" json:"readKeyReplaces,omitempty"` } @@ -767,11 +767,11 @@ func (m *ACLUserRemove) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserRemove proto.InternalMessageInfo -func (m *ACLUserRemove) GetIdentity() string { +func (m *ACLUserRemove) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserRemove) GetReadKeyReplaces() []*ACLReadKeyReplace { @@ -782,7 +782,7 @@ func (m *ACLUserRemove) GetReadKeyReplaces() []*ACLReadKeyReplace { } type ACLReadKeyReplace struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKey []byte `protobuf:"bytes,3,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` } @@ -820,11 +820,11 @@ func (m *ACLReadKeyReplace) XXX_DiscardUnknown() { var xxx_messageInfo_ACLReadKeyReplace proto.InternalMessageInfo -func (m *ACLReadKeyReplace) GetIdentity() string { +func (m *ACLReadKeyReplace) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLReadKeyReplace) GetEncryptionKey() []byte { @@ -842,7 +842,7 @@ func (m *ACLReadKeyReplace) GetEncryptedReadKey() []byte { } type ACLUserPermissionChange struct { - Identity string `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` } @@ -879,11 +879,11 @@ func (m *ACLUserPermissionChange) XXX_DiscardUnknown() { var xxx_messageInfo_ACLUserPermissionChange proto.InternalMessageInfo -func (m *ACLUserPermissionChange) GetIdentity() string { +func (m *ACLUserPermissionChange) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { @@ -895,7 +895,7 @@ func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { type ACLRecord struct { PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` - Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` @@ -941,11 +941,11 @@ func (m *ACLRecord) GetPrevId() string { return "" } -func (m *ACLRecord) GetIdentity() string { +func (m *ACLRecord) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *ACLRecord) GetData() []byte { @@ -971,7 +971,7 @@ func (m *ACLRecord) GetTimestamp() int64 { type ACLHeader struct { FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - Identity string `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` } func (m *ACLHeader) Reset() { *m = ACLHeader{} } @@ -1014,11 +1014,11 @@ func (m *ACLHeader) GetFirstId() string { return "" } -func (m *ACLHeader) GetIdentity() string { +func (m *ACLHeader) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } type RawTreeChange struct { @@ -1132,7 +1132,7 @@ type TreeChange struct { ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity string `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` } @@ -1211,11 +1211,11 @@ func (m *TreeChange) GetTimestamp() int64 { return 0 } -func (m *TreeChange) GetIdentity() string { +func (m *TreeChange) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *TreeChange) GetIsSnapshot() bool { @@ -1229,7 +1229,7 @@ type TreeHeader struct { FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` AclId string `protobuf:"bytes,2,opt,name=aclId,proto3" json:"aclId,omitempty"` TreeHeaderType TreeHeaderType `protobuf:"varint,3,opt,name=treeHeaderType,proto3,enum=acl.TreeHeaderType" json:"treeHeaderType,omitempty"` - Identity string `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` + Identity []byte `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` } @@ -1287,11 +1287,11 @@ func (m *TreeHeader) GetTreeHeaderType() TreeHeaderType { return TreeHeaderType_Object } -func (m *TreeHeader) GetIdentity() string { +func (m *TreeHeader) GetIdentity() []byte { if m != nil { return m.Identity } - return "" + return nil } func (m *TreeHeader) GetData() []byte { @@ -1361,44 +1361,44 @@ var fileDescriptor_37a022c841a51877 = []byte{ 0xf8, 0x27, 0x91, 0x48, 0xa7, 0x38, 0x53, 0xdd, 0xfc, 0x0c, 0x5a, 0xb6, 0x00, 0x75, 0xa0, 0xfa, 0x9c, 0x4e, 0x55, 0x1d, 0x35, 0xb0, 0x5c, 0xa2, 0x1d, 0xc3, 0xc3, 0xa2, 0x5a, 0xd1, 0xa6, 0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, 0x8a, 0xce, 0x37, 0x0a, 0x55, 0x4c, 0x0d, 0x5c, 0xc2, 0x16, - 0x93, 0x54, 0xbb, 0x81, 0x24, 0x7f, 0x92, 0x67, 0xce, 0x34, 0xf6, 0xdb, 0xc2, 0xf9, 0x18, 0xd6, - 0x4c, 0x57, 0xc2, 0x34, 0x19, 0x93, 0x20, 0xef, 0x2c, 0x77, 0x33, 0x56, 0x71, 0x49, 0x8c, 0x67, - 0xd5, 0xfd, 0xaf, 0x1d, 0x58, 0x9f, 0x53, 0x7b, 0x09, 0x14, 0x16, 0x55, 0x94, 0xc7, 0x66, 0x38, - 0x9c, 0xc3, 0xfd, 0x04, 0xee, 0xdd, 0xf0, 0x32, 0xdd, 0xea, 0xc8, 0x4c, 0x39, 0xb9, 0xff, 0xe0, - 0x5f, 0xfb, 0xce, 0x81, 0x46, 0xf1, 0xf2, 0xdf, 0x85, 0xe5, 0x24, 0xa5, 0x17, 0xa3, 0xd0, 0x5c, - 0x61, 0x76, 0xa5, 0xcb, 0xdd, 0x99, 0xcb, 0x11, 0x2c, 0x85, 0x44, 0x10, 0x13, 0x93, 0x5a, 0xa3, - 0x1e, 0xa0, 0xe0, 0x3c, 0x4d, 0x69, 0x24, 0x70, 0xf1, 0x54, 0xa8, 0x92, 0x58, 0xc2, 0x0b, 0x24, - 0xf2, 0x1f, 0x16, 0x6c, 0x42, 0xb9, 0x20, 0x93, 0x44, 0x55, 0x75, 0x15, 0x17, 0x80, 0xdf, 0x57, - 0x2e, 0x0e, 0x29, 0x09, 0x69, 0x2a, 0x87, 0x93, 0x67, 0x2c, 0xe5, 0x22, 0xf7, 0x31, 0xdb, 0xde, - 0xe6, 0xa4, 0xff, 0x29, 0xac, 0x62, 0x72, 0x79, 0x9c, 0x52, 0x6a, 0xe8, 0xfc, 0x97, 0x33, 0x8e, - 0x3f, 0x80, 0x3b, 0xa5, 0x83, 0x9e, 0x32, 0x71, 0x36, 0x52, 0x46, 0x29, 0xb9, 0x34, 0x83, 0x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xf2, 0x7b, 0xe9, 0x86, 0x6a, 0xaf, 0x15, 0xd5, 0xbe, 0xfb, 0x10, 0xd0, 0xfc, 0x6f, 0x86, + 0x1a, 0x50, 0xeb, 0x87, 0x13, 0x16, 0x75, 0x2a, 0x08, 0x60, 0xf9, 0x69, 0xca, 0x04, 0x4d, 0x3b, + 0x8e, 0x5c, 0x63, 0x75, 0x55, 0xc7, 0x45, 0x4d, 0xa8, 0xeb, 0xd6, 0x16, 0x76, 0xaa, 0xbb, 0xaf, + 0x43, 0xbb, 0xec, 0x97, 0x54, 0xfd, 0xfc, 0xe4, 0x2b, 0x1a, 0x88, 0x4e, 0x45, 0x9e, 0x76, 0x94, + 0x90, 0x80, 0x76, 0x9c, 0xfd, 0x57, 0x7e, 0xbc, 0xea, 0x3a, 0x2f, 0xae, 0xba, 0xce, 0xaf, 0x57, + 0x5d, 0xe7, 0x9b, 0xeb, 0x6e, 0xe5, 0xc5, 0x75, 0xb7, 0xf2, 0xf3, 0x75, 0xb7, 0xf2, 0x65, 0x4d, + 0x0d, 0xfb, 0x27, 0xcb, 0x6a, 0xb6, 0x7f, 0xe7, 0xcf, 0x00, 0x00, 0x00, 0xff, 0xff, 0x8c, 0x25, + 0x31, 0x18, 0x0f, 0x0c, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -3735,7 +3735,7 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -3745,23 +3745,25 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -3922,7 +3924,7 @@ func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -3932,23 +3934,25 @@ func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4089,7 +4093,7 @@ func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4099,23 +4103,25 @@ func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4404,7 +4410,7 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4414,23 +4420,25 @@ func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4618,7 +4626,7 @@ func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4628,23 +4636,25 @@ func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { @@ -4734,7 +4744,7 @@ func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4744,23 +4754,25 @@ func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 2 { @@ -4884,7 +4896,7 @@ func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -4894,23 +4906,25 @@ func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 2: if wireType != 0 { @@ -5017,7 +5031,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5027,23 +5041,25 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 3: if wireType != 2 { @@ -5203,7 +5219,7 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5213,23 +5229,25 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex default: iNdEx = preIndex @@ -5687,7 +5705,7 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5697,23 +5715,25 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 8: if wireType != 0 { @@ -5872,7 +5892,7 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } - var stringLen uint64 + var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { return ErrIntOverflowAclchanges @@ -5882,23 +5902,25 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } b := dAtA[iNdEx] iNdEx++ - stringLen |= uint64(b&0x7F) << shift + byteLen |= int(b&0x7F) << shift if b < 0x80 { break } } - intStringLen := int(stringLen) - if intStringLen < 0 { + if byteLen < 0 { return ErrInvalidLengthAclchanges } - postIndex := iNdEx + intStringLen + postIndex := iNdEx + byteLen if postIndex < 0 { return ErrInvalidLengthAclchanges } if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } iNdEx = postIndex case 5: if wireType != 2 { diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto index 2ac1e5f7..73a3fc1f 100644 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto @@ -33,7 +33,7 @@ message ACLState { } message ACLUserState { - string identity = 1; + bytes identity = 1; bytes encryptionKey = 2; repeated bytes encryptedReadKeys = 3; // all read keys that we know ACLUserPermissions permissions = 4; @@ -42,7 +42,7 @@ message ACLUserState { // we already know identity and encryptionKey message ACLUserAdd { - string identity = 1; // public signing key + bytes identity = 1; // public signing key bytes encryptionKey = 2; // public encryption key repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user ACLUserPermissions permissions = 4; @@ -50,7 +50,7 @@ message ACLUserAdd { // TODO: this is not used as of now message ACLUserConfirm { // not needed for read permissions - string identity = 1; // not needed + bytes identity = 1; // not needed string userAddId = 2; } @@ -63,7 +63,7 @@ message ACLUserInvite { } message ACLUserJoin { - string identity = 1; + bytes identity = 1; bytes encryptionKey = 2; bytes acceptSignature = 3; // sign acceptPublicKey string userInviteId = 4; @@ -71,18 +71,18 @@ message ACLUserJoin { } message ACLUserRemove { - string identity = 1; + bytes identity = 1; repeated ACLReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users } message ACLReadKeyReplace { - string identity = 1; + bytes identity = 1; bytes encryptionKey = 2; bytes encryptedReadKey = 3; } message ACLUserPermissionChange { - string identity = 1; + bytes identity = 1; ACLUserPermissions permissions = 2; } @@ -95,7 +95,7 @@ enum ACLUserPermissions { message ACLRecord { string prevId = 1; - string identity = 2; + bytes identity = 2; bytes data = 3; uint64 currentReadKeyHash = 4; int64 timestamp = 5; @@ -103,7 +103,7 @@ message ACLRecord { message ACLHeader { string firstId = 1; - string identity = 2; // the identity of the creator + bytes identity = 2; // the identity of the creator } // Tree protos @@ -125,7 +125,7 @@ message TreeChange { bytes changesData = 4; uint64 currentReadKeyHash = 5; int64 timestamp = 6; - string identity = 7; + bytes identity = 7; bool isSnapshot = 8; } @@ -138,6 +138,6 @@ message TreeHeader { string firstId = 1; string aclId = 2; TreeHeaderType treeHeaderType = 3; - string identity = 4; + bytes identity = 4; bytes data = 5; // this should be reserved for the client to add the data it needs } diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index fceeaadc..d7a849fb 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -1,6 +1,7 @@ package list import ( + "bytes" "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" @@ -147,7 +148,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { var permissions []UserPermissionPair for _, state := range st.userStates { permission := UserPermissionPair{ - Identity: state.Identity, + Identity: string(state.Identity), Permission: state.Permissions, } permissions = append(permissions, permission) @@ -157,7 +158,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { return nil } -func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity string) (err error) { +func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity []byte) (err error) { defer func() { if err != nil { return @@ -170,7 +171,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden skipIdentityCheck := st.isUserJoin(changeData) || (st.currentReadKeyHash == 0 && st.isUserAdd(changeData, identity)) if !skipIdentityCheck { // we check signature when we add this to the Tree, so no need to do it here - if _, exists := st.userStates[identity]; !exists { + if _, exists := st.userStates[string(identity)]; !exists { err = ErrNoSuchUser return } @@ -211,11 +212,12 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { } func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { - if _, exists := st.userStates[ch.Identity]; !exists { + chIdentity := string(ch.Identity) + if _, exists := st.userStates[chIdentity]; !exists { return ErrNoSuchUser } - st.userStates[ch.Identity].Permissions = ch.Permissions + st.userStates[chIdentity].Permissions = ch.Permissions return nil } @@ -229,8 +231,9 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) } + chIdentity := string(ch.Identity) - if _, exists = st.userStates[ch.Identity]; exists { + if _, exists = st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } @@ -241,7 +244,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { return fmt.Errorf("public key verifying invite accepts is given in incorrect format: %v", err) } - res, err := verificationKey.(signingkey.PubKey).Verify([]byte(ch.Identity), signature) + res, err := verificationKey.(signingkey.PubKey).Verify(ch.Identity, signature) if err != nil { return fmt.Errorf("verification returned error: %w", err) } @@ -250,7 +253,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { } // if ourselves -> we need to decrypt the read keys - if st.identity == ch.Identity { + if st.identity == chIdentity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -269,23 +272,24 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { Permissions: invite.Permissions, IsConfirmed: true, } - st.userStates[ch.Identity] = userState + st.userStates[chIdentity] = userState return nil } func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { - if _, exists := st.userStates[ch.Identity]; exists { + chIdentity := string(ch.Identity) + if _, exists := st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } - st.userStates[ch.Identity] = &aclpb.ACLUserState{ + st.userStates[chIdentity] = &aclpb.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, EncryptedReadKeys: ch.EncryptedReadKeys, } - if ch.Identity == st.identity { + if chIdentity == st.identity { for _, key := range ch.EncryptedReadKeys { key, hash, err := st.decryptReadKeyAndHash(key) if err != nil { @@ -300,15 +304,16 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { } func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { - if ch.Identity == st.identity { + chIdentity := string(ch.Identity) + if chIdentity == st.identity { return ErrDocumentForbidden } - if _, exists := st.userStates[ch.Identity]; !exists { + if _, exists := st.userStates[chIdentity]; !exists { return ErrNoSuchUser } - delete(st.userStates, ch.Identity) + delete(st.userStates, chIdentity) for _, replace := range ch.ReadKeyReplaces { repIdentity := string(replace.Identity) @@ -359,8 +364,8 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity string, permission aclpb.ACLUserPermissions) bool { - state, exists := st.userStates[identity] +func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermissions) bool { + state, exists := st.userStates[string(identity)] if !exists { return false } @@ -373,13 +378,10 @@ func (st *ACLState) isUserJoin(data *aclpb.ACLData) bool { return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil } -func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity string) bool { - if len(data.GetAclContent()) == 0 { - return false - } +func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity []byte) bool { // if we have a UserAdd, then it should always be the first one applied userAdd := data.GetAclContent()[0].GetUserAdd() - return data.GetAclContent() != nil && userAdd != nil && userAdd.GetIdentity() == identity + return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0 } func (st *ACLState) GetUserStates() map[string]*aclpb.ACLUserState { diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go index 52a44e18..c6413cb0 100644 --- a/pkg/acl/list/changebuilder.go +++ b/pkg/acl/list/changebuilder.go @@ -82,7 +82,7 @@ func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey. ch := &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserAdd{ UserAdd: &aclpb.ACLUserAdd{ - Identity: identity, + Identity: []byte(identity), EncryptionKey: rawKey, EncryptedReadKeys: encryptedKeys, Permissions: permissions, @@ -98,7 +98,7 @@ func (c *aclChangeBuilder) BuildAndApply() (*ACLRecord, []byte, error) { PrevId: c.list.Head().Id, CurrentReadKeyHash: c.readKeyHash, Timestamp: int64(time.Now().Nanosecond()), - Identity: string(c.acc.Identity), + Identity: c.acc.Identity, } marshalledData, err := proto.Marshal(c.aclData) diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index fb73d450..c6d8703a 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -146,7 +146,7 @@ func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.A return &aclpb.ACLRecord{ PrevId: prevId, - Identity: t.keychain.GetIdentity(rec.Identity), + Identity: []byte(t.keychain.GetIdentity(rec.Identity)), Data: bytes, CurrentReadKeyHash: k.Hash, Timestamp: time.Now().Unix(), @@ -164,7 +164,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserAdd{ UserAdd: &aclpb.ACLUserAdd{ - Identity: t.keychain.GetIdentity(add.Identity), + Identity: []byte(t.keychain.GetIdentity(add.Identity)), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), Permissions: t.convertPermission(add.Permission), @@ -188,7 +188,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserJoin{ UserJoin: &aclpb.ACLUserJoin{ - Identity: t.keychain.GetIdentity(join.Identity), + Identity: []byte(t.keychain.GetIdentity(join.Identity)), EncryptionKey: rawKey, AcceptSignature: signature, UserInviteId: join.InviteId, @@ -220,7 +220,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserConfirm{ UserConfirm: &aclpb.ACLUserConfirm{ - Identity: t.keychain.GetIdentity(confirm.Identity), + Identity: []byte(t.keychain.GetIdentity(confirm.Identity)), UserAddId: confirm.UserAddId, }, }, @@ -231,7 +231,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserPermissionChange{ UserPermissionChange: &aclpb.ACLUserPermissionChange{ - Identity: t.keychain.GetIdentity(permissionChange.Identity), + Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)), Permissions: t.convertPermission(permissionChange.Permission), }, }, @@ -251,7 +251,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL panic(err) } replaces = append(replaces, &aclpb.ACLReadKeyReplace{ - Identity: identity, + Identity: []byte(identity), EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) @@ -260,7 +260,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL convCh = &aclpb.ACLContentValue{ Value: &aclpb.ACLContentValue_UserRemove{ UserRemove: &aclpb.ACLUserRemove{ - Identity: t.keychain.GetIdentity(remove.RemovedIdentity), + Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)), ReadKeyReplaces: replaces, }, }, diff --git a/pkg/acl/tree/change.go b/pkg/acl/tree/change.go index 930a7abc..cefc9327 100644 --- a/pkg/acl/tree/change.go +++ b/pkg/acl/tree/change.go @@ -65,6 +65,7 @@ func NewChange(id string, ch *aclpb.TreeChange, signature []byte) *Change { Content: ch, SnapshotId: ch.SnapshotBaseId, IsSnapshot: ch.IsSnapshot, + Identity: string(ch.Identity), Sign: signature, } } diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index c58cf218..67985c82 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -18,7 +18,7 @@ type BuilderContent struct { aclHeadId string snapshotBaseId string currentReadKeyHash uint64 - identity string + identity []byte isSnapshot bool signingKey signingkey.PrivKey readKey *symmetric.Key diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index 1dfac831..bbc337cf 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -43,7 +43,7 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c state = aclList.ACLState() ) // checking if the user could write - perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Content.Identity) + perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Identity) if err != nil { return } diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index 01afdc92..a62c8add 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -142,7 +142,7 @@ func createTreeHeaderAndId( raw *aclpb.RawTreeChangeWithId, treeType aclpb.TreeHeaderType, aclId string, - identity string, + identity []byte, headerData []byte) (header *aclpb.TreeHeader, treeId string, err error) { header = &aclpb.TreeHeader{ FirstId: raw.Id, diff --git a/pkg/acl/tree/signablecontent.go b/pkg/acl/tree/signablecontent.go index b51d1dea..4774c2fb 100644 --- a/pkg/acl/tree/signablecontent.go +++ b/pkg/acl/tree/signablecontent.go @@ -7,6 +7,6 @@ import ( type SignableChangeContent struct { Data []byte Key signingkey.PrivKey - Identity string + Identity []byte IsSnapshot bool } From 5599277bf247dd2d55ef87f4a83abf02b56e6606 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 15:52:47 +0200 Subject: [PATCH 13/44] Generate drpc and some fixes --- Makefile | 4 +- .../spacesyncproto/protos/spacesync.proto | 5 - .../spacesyncproto/spacesync.pb.go | 278 ++++------------- .../spacesyncproto/spacesync_drpc.pb.go | 24 +- common/commonspace/syncservice/syncservice.go | 291 ++++++++++++++++++ pkg/acl/aclchanges/aclpb/aclchanges.pb.go | 132 ++++---- .../aclchanges/aclpb/protos/aclchanges.proto | 2 +- pkg/acl/list/aclstate.go | 11 +- pkg/acl/tree/changebuilder.go | 2 +- pkg/acl/tree/objecttree.go | 22 +- 10 files changed, 450 insertions(+), 321 deletions(-) create mode 100644 common/commonspace/syncservice/syncservice.go diff --git a/Makefile b/Makefile index b004f35e..b75d2d22 100644 --- a/Makefile +++ b/Makefile @@ -26,11 +26,11 @@ proto: @$(eval P_ACL_CHANGES := M$(P_ACL_CHANGES_PATH_PB)/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_CHANGES_PATH_PB)) # use if needed $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT)) - $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_CHANGES_PATH_PB)/protos/*.proto; mv $(P_ACL_CHANGES_PATH_PB)/protos/*.go $(P_ACL_CHANGES_PATH_PB) + $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_CHANGES_PATH_PB)/protos/*.proto $(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto $(eval PKGMAP := $$(P_ACL_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. common/commonspace/spacesyncproto/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 16fbdd14..25c5fefb 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -14,11 +14,6 @@ service Space { rpc Stream(stream ObjectSyncMessage) returns (stream ObjectSyncMessage); } -// TODO: temporary mock message -message Msg { - string spaceId = 1; -} - // HeadSyncRange presenting a request for one range message HeadSyncRange { uint64 from = 1; diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index a3299fee..b23dcf9b 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -45,51 +45,6 @@ func (ErrCodes) EnumDescriptor() ([]byte, []int) { return fileDescriptor_5855f4ef9cf24cdb, []int{0} } -// TODO: temporary mock message -type Msg struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` -} - -func (m *Msg) Reset() { *m = Msg{} } -func (m *Msg) String() string { return proto.CompactTextString(m) } -func (*Msg) ProtoMessage() {} -func (*Msg) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{0} -} -func (m *Msg) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Msg) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Msg.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 *Msg) XXX_Merge(src proto.Message) { - xxx_messageInfo_Msg.Merge(m, src) -} -func (m *Msg) XXX_Size() int { - return m.Size() -} -func (m *Msg) XXX_DiscardUnknown() { - xxx_messageInfo_Msg.DiscardUnknown(m) -} - -var xxx_messageInfo_Msg proto.InternalMessageInfo - -func (m *Msg) GetSpaceId() string { - if m != nil { - return m.SpaceId - } - return "" -} - // HeadSyncRange presenting a request for one range type HeadSyncRange struct { From uint64 `protobuf:"varint,1,opt,name=from,proto3" json:"from,omitempty"` @@ -101,7 +56,7 @@ func (m *HeadSyncRange) Reset() { *m = HeadSyncRange{} } func (m *HeadSyncRange) String() string { return proto.CompactTextString(m) } func (*HeadSyncRange) ProtoMessage() {} func (*HeadSyncRange) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{1} + return fileDescriptor_5855f4ef9cf24cdb, []int{0} } func (m *HeadSyncRange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -162,7 +117,7 @@ func (m *HeadSyncResult) Reset() { *m = HeadSyncResult{} } func (m *HeadSyncResult) String() string { return proto.CompactTextString(m) } func (*HeadSyncResult) ProtoMessage() {} func (*HeadSyncResult) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{2} + return fileDescriptor_5855f4ef9cf24cdb, []int{1} } func (m *HeadSyncResult) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -222,7 +177,7 @@ func (m *HeadSyncResultElement) Reset() { *m = HeadSyncResultElement{} } func (m *HeadSyncResultElement) String() string { return proto.CompactTextString(m) } func (*HeadSyncResultElement) ProtoMessage() {} func (*HeadSyncResultElement) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{3} + return fileDescriptor_5855f4ef9cf24cdb, []int{2} } func (m *HeadSyncResultElement) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -275,7 +230,7 @@ func (m *HeadSyncRequest) Reset() { *m = HeadSyncRequest{} } func (m *HeadSyncRequest) String() string { return proto.CompactTextString(m) } func (*HeadSyncRequest) ProtoMessage() {} func (*HeadSyncRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{4} + return fileDescriptor_5855f4ef9cf24cdb, []int{3} } func (m *HeadSyncRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -327,7 +282,7 @@ func (m *HeadSyncResponse) Reset() { *m = HeadSyncResponse{} } func (m *HeadSyncResponse) String() string { return proto.CompactTextString(m) } func (*HeadSyncResponse) ProtoMessage() {} func (*HeadSyncResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{5} + return fileDescriptor_5855f4ef9cf24cdb, []int{4} } func (m *HeadSyncResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -375,7 +330,7 @@ func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } func (m *ObjectSyncMessage) String() string { return proto.CompactTextString(m) } func (*ObjectSyncMessage) ProtoMessage() {} func (*ObjectSyncMessage) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{6} + return fileDescriptor_5855f4ef9cf24cdb, []int{5} } func (m *ObjectSyncMessage) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -445,7 +400,7 @@ func (m *ObjectSyncContentValue) Reset() { *m = ObjectSyncContentValue{} func (m *ObjectSyncContentValue) String() string { return proto.CompactTextString(m) } func (*ObjectSyncContentValue) ProtoMessage() {} func (*ObjectSyncContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{7} + return fileDescriptor_5855f4ef9cf24cdb, []int{6} } func (m *ObjectSyncContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -542,7 +497,7 @@ func (m *ObjectHeadUpdate) Reset() { *m = ObjectHeadUpdate{} } func (m *ObjectHeadUpdate) String() string { return proto.CompactTextString(m) } func (*ObjectHeadUpdate) ProtoMessage() {} func (*ObjectHeadUpdate) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{8} + return fileDescriptor_5855f4ef9cf24cdb, []int{7} } func (m *ObjectHeadUpdate) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -602,7 +557,7 @@ func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} } func (m *ObjectFullSyncRequest) String() string { return proto.CompactTextString(m) } func (*ObjectFullSyncRequest) ProtoMessage() {} func (*ObjectFullSyncRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{9} + return fileDescriptor_5855f4ef9cf24cdb, []int{8} } func (m *ObjectFullSyncRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -656,7 +611,7 @@ func (m *ObjectFullSyncResponse) Reset() { *m = ObjectFullSyncResponse{} func (m *ObjectFullSyncResponse) String() string { return proto.CompactTextString(m) } func (*ObjectFullSyncResponse) ProtoMessage() {} func (*ObjectFullSyncResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5855f4ef9cf24cdb, []int{10} + return fileDescriptor_5855f4ef9cf24cdb, []int{9} } func (m *ObjectFullSyncResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -708,7 +663,6 @@ func (m *ObjectFullSyncResponse) GetSnapshotPath() []string { func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) - proto.RegisterType((*Msg)(nil), "anySpace.Msg") proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") proto.RegisterType((*HeadSyncResult)(nil), "anySpace.HeadSyncResult") proto.RegisterType((*HeadSyncResultElement)(nil), "anySpace.HeadSyncResultElement") @@ -726,80 +680,49 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 674 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4d, 0x6f, 0xd3, 0x40, - 0x10, 0xf5, 0x26, 0x6d, 0x92, 0x4e, 0xfa, 0x11, 0x56, 0xb4, 0x98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 0x02, 0xf1, - 0x29, 0x14, 0xae, 0x16, 0x5e, 0xc5, 0x6a, 0x7f, 0x23, 0xb0, 0x88, 0x17, 0x47, 0x1f, 0x43, 0x29, - 0x9d, 0x29, 0x7a, 0x3b, 0x6b, 0xce, 0xb0, 0x1f, 0xd5, 0x6a, 0xe6, 0x08, 0xc6, 0xb6, 0xf6, 0xa1, - 0x70, 0xa8, 0x23, 0xc1, 0x87, 0xf4, 0x4e, 0xd6, 0x10, 0x25, 0xc3, 0x58, 0xbd, 0x6e, 0xb3, 0x41, - 0xb6, 0xc8, 0xce, 0xf6, 0x8f, 0x8b, 0x1a, 0x39, 0xbf, 0xa8, 0x91, 0x5f, 0x17, 0x35, 0xf2, 0xf5, - 0xb2, 0x66, 0x9d, 0x5f, 0xd6, 0xac, 0x9f, 0x97, 0x35, 0xeb, 0xcd, 0xdd, 0x7f, 0xfe, 0x37, 0x1c, - 0x17, 0xf0, 0x75, 0xff, 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0xd7, 0x51, 0x60, 0x63, 0x47, 0x06, - 0x00, 0x00, -} - -func (m *Msg) 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 *Msg) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Msg) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - 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 + // 666 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3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, 0x81, 0x73, 0x02, 0x2b, 0x63, 0x2a, 0x54, 0x23, 0x5f, 0x1b, 0xae, 0xbe, + 0x54, 0x7d, 0xe2, 0x5a, 0x12, 0xb4, 0xe6, 0x5b, 0x50, 0x46, 0x1f, 0x87, 0x18, 0x68, 0x65, 0x17, + 0x1a, 0x73, 0xcd, 0x4a, 0x67, 0xa3, 0x95, 0xe9, 0x6f, 0x5d, 0xc6, 0xef, 0x26, 0x75, 0x62, 0x0c, + 0x30, 0x07, 0xbb, 0xe1, 0x28, 0x18, 0x1f, 0x4c, 0x81, 0xb3, 0x05, 0x6b, 0xb9, 0x40, 0xa3, 0x7b, + 0xe0, 0xd1, 0xe9, 0x8b, 0xa2, 0x30, 0xf0, 0x48, 0x0f, 0x4a, 0x8f, 0x3a, 0x59, 0x14, 0xb4, 0x76, + 0xde, 0xc0, 0xea, 0x04, 0xfc, 0x7e, 0x84, 0x4a, 0x73, 0x1b, 0x4a, 0x64, 0x71, 0x2f, 0xc3, 0x66, + 0x21, 0x6f, 0x43, 0x31, 0x26, 0xf7, 0x52, 0xe9, 0x37, 0x72, 0xa4, 0x9b, 0x7d, 0x91, 0x96, 0x39, + 0x7b, 0x50, 0x9d, 0x92, 0x16, 0x85, 0x81, 0x42, 0xde, 0x81, 0x52, 0x4c, 0x32, 0x95, 0xcd, 0x88, + 0xc5, 0xbe, 0xca, 0x00, 0x91, 0x15, 0x3a, 0xdf, 0x18, 0xfc, 0xf7, 0xf4, 0xf0, 0x2d, 0xba, 0xda, + 0xec, 0x3e, 0x46, 0xa5, 0xe4, 0x31, 0x5e, 0x23, 0xf4, 0x3e, 0x94, 0xdc, 0x30, 0xd0, 0x18, 0x68, + 0x6a, 0xb6, 0xd2, 0x69, 0x4c, 0xce, 0x98, 0xf0, 0xec, 0x24, 0x25, 0x2f, 0xa5, 0x3f, 0x42, 0x91, + 0x01, 0x78, 0x1b, 0x40, 0xc7, 0x88, 0x46, 0x0a, 0xc6, 0xe4, 0x74, 0xa5, 0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, 0x1e, 0x2a, 0xbe, 0x02, 0x70, 0x10, 0xe0, 0xc7, 0x08, 0x5d, 0x8d, 0x5e, 0xd5, 0xea, + 0x7c, 0x65, 0xb0, 0x40, 0x17, 0xc7, 0x1f, 0x42, 0x39, 0x9b, 0x29, 0x7e, 0x33, 0x6f, 0xce, 0xc8, + 0x8f, 0x5a, 0x2d, 0x77, 0x04, 0x93, 0xb6, 0xf6, 0xa0, 0xb8, 0xaf, 0x63, 0x94, 0x43, 0x7e, 0x2b, + 0x6f, 0x88, 0xd2, 0x61, 0xac, 0x5d, 0xb7, 0xd9, 0x64, 0x9b, 0x6c, 0x7b, 0xeb, 0xfb, 0x79, 0x9d, + 0x9d, 0x9d, 0xd7, 0xd9, 0xcf, 0xf3, 0x3a, 0xfb, 0x72, 0x51, 0xb7, 0xce, 0x2e, 0xea, 0xd6, 0x8f, + 0x8b, 0xba, 0xf5, 0xfa, 0xf6, 0x5f, 0xff, 0xfa, 0x0f, 0x8b, 0xf4, 0xba, 0xfb, 0x3b, 0x00, 0x00, + 0xff, 0xff, 0xcf, 0x4f, 0x53, 0x3d, 0x26, 0x06, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -1325,19 +1248,6 @@ func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { dAtA[offset] = uint8(v) return base } -func (m *Msg) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.SpaceId) - if l > 0 { - n += 1 + l + sovSpacesync(uint64(l)) - } - return n -} - func (m *HeadSyncRange) Size() (n int) { if m == nil { return 0 @@ -1583,88 +1493,6 @@ func sovSpacesync(x uint64) (n int) { func sozSpacesync(x uint64) (n int) { return sovSpacesync(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } -func (m *Msg) 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: Msg: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Msg: illegal tag %d (wire type %d)", fieldNum, wire) - } - 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 - 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 *HeadSyncRange) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/spacesyncproto/spacesync_drpc.pb.go b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go index b17dc589..9f984b1e 100644 --- a/common/commonspace/spacesyncproto/spacesync_drpc.pb.go +++ b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go @@ -74,27 +74,27 @@ func (c *drpcSpaceClient) Stream(ctx context.Context) (DRPCSpace_StreamClient, e type DRPCSpace_StreamClient interface { drpc.Stream - Send(*Msg) error - Recv() (*Msg, error) + Send(*ObjectSyncMessage) error + Recv() (*ObjectSyncMessage, error) } type drpcSpace_StreamClient struct { drpc.Stream } -func (x *drpcSpace_StreamClient) Send(m *Msg) error { +func (x *drpcSpace_StreamClient) Send(m *ObjectSyncMessage) error { return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) } -func (x *drpcSpace_StreamClient) Recv() (*Msg, error) { - m := new(Msg) +func (x *drpcSpace_StreamClient) Recv() (*ObjectSyncMessage, error) { + m := new(ObjectSyncMessage) if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { return nil, err } return m, nil } -func (x *drpcSpace_StreamClient) RecvMsg(m *Msg) error { +func (x *drpcSpace_StreamClient) RecvMsg(m *ObjectSyncMessage) error { return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) } @@ -163,26 +163,26 @@ func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { type DRPCSpace_StreamStream interface { drpc.Stream - Send(*Msg) error - Recv() (*Msg, error) + Send(*ObjectSyncMessage) error + Recv() (*ObjectSyncMessage, error) } type drpcSpace_StreamStream struct { drpc.Stream } -func (x *drpcSpace_StreamStream) Send(m *Msg) error { +func (x *drpcSpace_StreamStream) Send(m *ObjectSyncMessage) error { return x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) } -func (x *drpcSpace_StreamStream) Recv() (*Msg, error) { - m := new(Msg) +func (x *drpcSpace_StreamStream) Recv() (*ObjectSyncMessage, error) { + m := new(ObjectSyncMessage) if err := x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { return nil, err } return m, nil } -func (x *drpcSpace_StreamStream) RecvMsg(m *Msg) error { +func (x *drpcSpace_StreamStream) RecvMsg(m *ObjectSyncMessage) error { return x.MsgRecv(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) } diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go new file mode 100644 index 00000000..0f133fd9 --- /dev/null +++ b/common/commonspace/syncservice/syncservice.go @@ -0,0 +1,291 @@ +package syncservice + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" + "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" + "go.uber.org/zap" +) + +type syncService struct { + treeCache treecache.Service + account account.Service + messageService MessageSender +} + +var log = logger.NewNamed("requesthandler") + +func New() app.Component { + return &syncService{} +} + +type SyncService interface { + HandleSyncMessage(ctx context.Context, senderId string, request *syncproto.Sync) (err error) +} + +type MessageSender interface { + SendMessageAsync(peerId string, msg *syncproto.Sync) error + SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error +} + +const CName = "SyncRequestHandler" + +func (r *syncService) Init(a *app.App) (err error) { + r.treeCache = a.MustComponent(treecache.CName).(treecache.Service) + r.account = a.MustComponent(account.CName).(account.Service) + r.messageService = a.MustComponent("MessageService").(MessageSender) + return nil +} + +func (r *syncService) Name() (name string) { + return CName +} + +func (r *syncService) Run(ctx context.Context) (err error) { + return nil +} + +func (r *syncService) Close(ctx context.Context) (err error) { + return nil +} + +func (r *syncService) HandleSyncMessage(ctx context.Context, senderId string, content *syncproto.Sync) error { + msg := content.GetMessage() + switch { + case msg.GetFullSyncRequest() != nil: + return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), content.GetTreeHeader(), content.GetTreeId()) + case msg.GetFullSyncResponse() != nil: + return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId()) + case msg.GetHeadUpdate() != nil: + return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId()) + case msg.GetAclList() != nil: + return r.HandleACLList(ctx, senderId, msg.GetAclList(), content.GetTreeHeader(), content.GetTreeId()) + } + return nil +} + +func (r *syncService) HandleHeadUpdate( + ctx context.Context, + senderId string, + update *syncproto.SyncHeadUpdate, + header *aclpb.Header, + treeId string) (err error) { + + var ( + fullRequest *syncproto.SyncFullRequest + snapshotPath []string + result tree.AddResult + ) + log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)). + Debug("processing head update") + + err = r.treeCache.Do(ctx, treeId, func(obj any) error { + objTree := obj.(tree.ObjectTree) + objTree.Lock() + defer objTree.Unlock() + + if slice.UnsortedEquals(update.Heads, objTree.Heads()) { + return nil + } + + result, err = objTree.AddRawChanges(ctx, update.Changes...) + if err != nil { + return err + } + + // if we couldn't add all the changes + shouldFullSync := len(update.Changes) != len(result.Added) + snapshotPath = objTree.SnapshotPath() + if shouldFullSync { + fullRequest, err = r.prepareFullSyncRequest(objTree) + if err != nil { + return err + } + } + return nil + }) + + // if there are no such tree + if err == storage.ErrUnknownTreeId { + fullRequest = &syncproto.SyncFullRequest{} + } + // if we have incompatible heads, or we haven't seen the tree at all + if fullRequest != nil { + return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest, header, treeId)) + } + // if error or nothing has changed + if err != nil || len(result.Added) == 0 { + return err + } + + // otherwise sending heads update message + newUpdate := &syncproto.SyncHeadUpdate{ + Heads: result.Heads, + Changes: result.Added, + SnapshotPath: snapshotPath, + } + return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) +} + +func (r *syncService) HandleFullSyncRequest( + ctx context.Context, + senderId string, + request *syncproto.SyncFullRequest, + header *aclpb.Header, + treeId string) (err error) { + + var fullResponse *syncproto.SyncFullResponse + err = r.treeCache.Do(ctx, treeId, func(obj any) error { + objTree := obj.(tree.ObjectTree) + objTree.Lock() + defer objTree.Unlock() + + fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) + if err != nil { + return err + } + return nil + }) + + if err != nil { + return err + } + return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse, header, treeId)) +} + +func (r *syncService) HandleFullSyncResponse( + ctx context.Context, + senderId string, + response *syncproto.SyncFullResponse, + header *aclpb.Header, + treeId string) (err error) { + + var ( + snapshotPath []string + result tree.AddResult + ) + + err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error { + objTree := obj.(tree.ObjectTree) + objTree.Lock() + defer objTree.Unlock() + + // if we already have the heads for whatever reason + if slice.UnsortedEquals(response.Heads, objTree.Heads()) { + return nil + } + + result, err = objTree.AddRawChanges(ctx, response.Changes...) + if err != nil { + return err + } + snapshotPath = objTree.SnapshotPath() + return nil + }) + + // if error or nothing has changed + if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId { + return err + } + // if we have a new tree + if err == storage.ErrUnknownTreeId { + err = r.createTree(ctx, response, header, treeId) + if err != nil { + return err + } + result = tree.AddResult{ + OldHeads: []string{}, + Heads: response.Heads, + Added: response.Changes, + } + } + // sending heads update message + newUpdate := &syncproto.SyncHeadUpdate{ + Heads: result.Heads, + Changes: result.Added, + SnapshotPath: snapshotPath, + } + return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) +} + +func (r *syncService) HandleACLList( + ctx context.Context, + senderId string, + req *syncproto.SyncACLList, + header *aclpb.Header, + id string) (err error) { + + err = r.treeCache.Do(ctx, id, func(obj interface{}) error { + return nil + }) + // do nothing if already added + if err == nil { + return nil + } + // if not found then add to storage + if err == storage.ErrUnknownTreeId { + return r.createACLList(ctx, req, header, id) + } + return err +} + +func (r *syncService) prepareFullSyncRequest(t tree.ObjectTree) (*syncproto.SyncFullRequest, error) { + return &syncproto.SyncFullRequest{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + }, nil +} + +func (r *syncService) prepareFullSyncResponse( + treeId string, + theirPath, theirHeads []string, + t tree.ObjectTree) (*syncproto.SyncFullResponse, error) { + ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads) + if err != nil { + return nil, err + } + + return &syncproto.SyncFullResponse{ + Heads: t.Heads(), + Changes: ourChanges, + SnapshotPath: t.SnapshotPath(), + }, nil +} + +func (r *syncService) createTree( + ctx context.Context, + response *syncproto.SyncFullResponse, + header *aclpb.Header, + treeId string) error { + + return r.treeCache.Add( + ctx, + treeId, + storage.TreeStorageCreatePayload{ + TreeId: treeId, + Header: header, + Changes: response.Changes, + Heads: response.Heads, + }) +} + +func (r *syncService) createACLList( + ctx context.Context, + req *syncproto.SyncACLList, + header *aclpb.Header, + treeId string) error { + + return r.treeCache.Add( + ctx, + treeId, + storage.ACLListStorageCreatePayload{ + ListId: treeId, + Header: header, + Records: req.Records, + }) +} diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go index ecd124b1..60437c7e 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclchanges/aclpb/aclchanges.pb.go @@ -1332,73 +1332,73 @@ func init() { var fileDescriptor_37a022c841a51877 = []byte{ // 1078 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x44, 0x23, - 0x04, 0x51, 0x40, 0x5e, 0x08, 0x2b, 0xf1, 0x77, 0x00, 0xc7, 0x8b, 0xb0, 0x37, 0x11, 0xac,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xed, 0xb2, 0x5f, 0x52, 0xf5, 0x8b, 0xe3, 0xaf, 0x69, 0x20, 0x3a, 0x15, 0x79, 0xda, 0x61, + 0x42, 0x02, 0xda, 0x71, 0xf6, 0xfa, 0x3f, 0x5d, 0x76, 0x9d, 0x17, 0x97, 0x5d, 0xe7, 0xb7, 0xcb, + 0xae, 0xf3, 0xed, 0x55, 0xb7, 0xf2, 0xe2, 0xaa, 0x5b, 0xf9, 0xe5, 0xaa, 0x5b, 0xf9, 0xca, 0xbb, + 0x69, 0xfe, 0x3f, 0x5e, 0x56, 0xe3, 0xfe, 0xbb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x62, + 0x40, 0x97, 0x22, 0x0c, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto index 73a3fc1f..5d69e94f 100644 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto @@ -1,6 +1,6 @@ syntax = "proto3"; package acl; -option go_package = "aclpb"; +option go_package = "pkg/acl/aclchanges/aclpb"; // ACL protos diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index d7a849fb..91b3bb47 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -213,11 +213,12 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { chIdentity := string(ch.Identity) - if _, exists := st.userStates[chIdentity]; !exists { + state, exists := st.userStates[chIdentity] + if !exists { return ErrNoSuchUser } - st.userStates[chIdentity].Permissions = ch.Permissions + state.Permissions = ch.Permissions return nil } @@ -339,12 +340,12 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { func (st *ACLState) applyUserConfirm(ch *aclpb.ACLUserConfirm) error { chIdentity := string(ch.Identity) - if _, exists := st.userStates[chIdentity]; !exists { + state, exists := st.userStates[chIdentity] + if !exists { return ErrNoSuchUser } - userState := st.userStates[chIdentity] - userState.IsConfirmed = true + state.IsConfirmed = true return nil } diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 67985c82..7b478fd8 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -53,7 +53,7 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } } - raw := &aclpb.RawTreeChange{} + raw := &aclpb.RawTreeChange{} // TODO: sync pool err = proto.Unmarshal(rawIdChange.GetRawChange(), raw) if err != nil { return diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index c6ffeca7..31365b87 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -58,7 +58,7 @@ type ObjectTree interface { Storage() storage.TreeStorage DebugDump() (string, error) - AddContent(ctx context.Context, content SignableChangeContent) (*aclpb.RawTreeChangeWithId, error) + AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error) Close() error @@ -67,11 +67,11 @@ type ObjectTree interface { type objectTree struct { treeStorage storage.TreeStorage changeBuilder ChangeBuilder - updateListener ObjectTreeUpdateListener validator ObjectTreeValidator rawChangeLoader *rawChangeLoader treeBuilder *treeBuilder aclList list.ACLList + updateListener ObjectTreeUpdateListener id string header *aclpb.TreeHeader @@ -148,7 +148,7 @@ func (ot *objectTree) Storage() storage.TreeStorage { return ot.treeStorage } -func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (rawChange *aclpb.RawTreeChangeWithId, err error) { +func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (res AddResult, err error) { defer func() { if err == nil && ot.updateListener != nil { ot.updateListener.Update(ot) @@ -160,9 +160,13 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont return } + // saving old heads + oldHeads := make([]string, 0, len(ot.tree.Heads())) + oldHeads = append(oldHeads, ot.tree.Heads()...) + objChange, rawChange, err := ot.changeBuilder.BuildContent(payload) if content.IsSnapshot { - // clearing tree, because we already fixed everything in the last snapshot + // clearing tree, because we already saved everything in the last snapshot ot.tree = &Tree{} } err = ot.tree.AddMergedHead(objChange) @@ -176,6 +180,16 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont } err = ot.treeStorage.SetHeads([]string{objChange.Id}) + if err != nil { + return + } + + res = AddResult{ + OldHeads: oldHeads, + Heads: []string{objChange.Id}, + Added: []*aclpb.RawTreeChangeWithId{rawChange}, + Mode: Append, + } return } From c94a0c94f333ffa6fb45ae3af768bc36119ce5fd Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 16:34:26 +0200 Subject: [PATCH 14/44] Add .idea to gitignore --- .gitignore | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.gitignore b/.gitignore index 66fd13c9..2bc7dc72 100644 --- a/.gitignore +++ b/.gitignore @@ -11,5 +11,12 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Intelli-J files +.idea + +# MacOS file that stores custom attributes of its containing folder, +# such as folder view options, icon positions, and other visual information +.DS_Store + # Dependency directories (remove the comment below to include it) # vendor/ From 206b695e628f7036a3864b192543d60afe6da4b8 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 13 Sep 2022 22:26:51 +0200 Subject: [PATCH 15/44] Add sync handler --- common/commonspace/cache/treecache.go | 17 ++ .../commonspace/spacesyncproto/spacesync.go | 35 +++ common/commonspace/syncservice/synchandler.go | 247 ++++++++++++++++++ 3 files changed, 299 insertions(+) create mode 100644 common/commonspace/cache/treecache.go create mode 100644 common/commonspace/spacesyncproto/spacesync.go create mode 100644 common/commonspace/syncservice/synchandler.go diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go new file mode 100644 index 00000000..342c9042 --- /dev/null +++ b/common/commonspace/cache/treecache.go @@ -0,0 +1,17 @@ +package cache + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" +) + +type TreeResult struct { + Release func() + Tree tree.ObjectTree +} + +type TreeCache interface { + GetTree(ctx context.Context, id string) (TreeResult, error) + AddTree(ctx context.Context, payload storage.TreeStorageCreatePayload) error +} diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go new file mode 100644 index 00000000..66de459d --- /dev/null +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -0,0 +1,35 @@ +package spacesyncproto + +import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + +type SpaceStream = DRPCSpace_StreamStream + +func WrapHeadUpdate(update *ObjectHeadUpdate, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { + return &ObjectSyncMessage{ + Content: &ObjectSyncContentValue{ + Value: &ObjectSyncContentValue_HeadUpdate{HeadUpdate: update}, + }, + TreeHeader: header, + TreeId: treeId, + } +} + +func WrapFullRequest(request *ObjectFullSyncRequest, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { + return &ObjectSyncMessage{ + Content: &ObjectSyncContentValue{ + Value: &ObjectSyncContentValue_FullSyncRequest{FullSyncRequest: request}, + }, + TreeHeader: header, + TreeId: treeId, + } +} + +func WrapFullResponse(response *ObjectFullSyncResponse, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { + return &ObjectSyncMessage{ + Content: &ObjectSyncContentValue{ + Value: &ObjectSyncContentValue_FullSyncResponse{FullSyncResponse: response}, + }, + TreeHeader: header, + TreeId: treeId, + } +} diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go new file mode 100644 index 00000000..fed8f8c9 --- /dev/null +++ b/common/commonspace/syncservice/synchandler.go @@ -0,0 +1,247 @@ +package syncservice + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" +) + +type syncHandler struct { + treeCache cache.TreeCache + syncClient SyncClient +} + +type SyncHandler interface { + HandleSyncMessage(ctx context.Context, senderId string, request *spacesyncproto.ObjectSyncMessage) (err error) +} + +type SyncClient interface { + SendSyncMessage(peerId string, msg *spacesyncproto.ObjectSyncMessage) (err error) +} + +func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandler { + return &syncHandler{ + treeCache: treeCache, + syncClient: syncClient, + } +} + +func (s *syncHandler) HandleSyncMessage(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) error { + msg := message.GetContent() + switch { + case msg.GetFullSyncRequest() != nil: + return s.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), message.GetTreeHeader(), message.GetTreeId()) + case msg.GetFullSyncResponse() != nil: + return s.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), message.GetTreeHeader(), message.GetTreeId()) + case msg.GetHeadUpdate() != nil: + return s.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), message.GetTreeHeader(), message.GetTreeId()) + } + return nil +} + +func (s *syncHandler) HandleHeadUpdate( + ctx context.Context, + senderId string, + update *spacesyncproto.ObjectHeadUpdate, + header *aclpb.TreeHeader, + treeId string) (err error) { + + var ( + fullRequest *spacesyncproto.ObjectFullSyncRequest + snapshotPath []string + result tree.AddResult + // in case update changes are empty then we want to sync the whole tree + sendChangesOnFullSync = len(update.Changes) == 0 + ) + + res, err := s.treeCache.GetTree(ctx, treeId) + if err != nil { + return + } + + err = func() error { + objTree := res.Tree + objTree.Lock() + defer res.Release() + defer objTree.Unlock() + + if slice.UnsortedEquals(update.Heads, objTree.Heads()) { + return nil + } + + result, err = objTree.AddRawChanges(ctx, update.Changes...) + if err != nil { + return err + } + + // if we couldn't add all the changes + shouldFullSync := len(update.Changes) != len(result.Added) + snapshotPath = objTree.SnapshotPath() + if shouldFullSync { + fullRequest, err = s.prepareFullSyncRequest(objTree, sendChangesOnFullSync) + if err != nil { + return err + } + } + return nil + }() + + // if there are no such tree + if err == storage.ErrUnknownTreeId { + fullRequest = &spacesyncproto.ObjectFullSyncRequest{} + } + // if we have incompatible heads, or we haven't seen the tree at all + if fullRequest != nil { + return s.syncClient.SendSyncMessage(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) + } + // if error or nothing has changed + if err != nil || len(result.Added) == 0 { + return err + } + + // otherwise sending heads update message + newUpdate := &spacesyncproto.ObjectHeadUpdate{ + Heads: result.Heads, + Changes: result.Added, + SnapshotPath: snapshotPath, + } + return s.syncClient.SendSyncMessage("", spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) +} + +func (s *syncHandler) HandleFullSyncRequest( + ctx context.Context, + senderId string, + request *spacesyncproto.ObjectFullSyncRequest, + header *aclpb.TreeHeader, + treeId string) (err error) { + + var fullResponse *spacesyncproto.ObjectFullSyncResponse + + res, err := s.treeCache.GetTree(ctx, treeId) + if err != nil { + return + } + + // TODO: check if sync request contains changes and add them (also do head update in this case) + err = func() error { + objTree := res.Tree + objTree.Lock() + defer res.Release() + defer objTree.Unlock() + fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) + if err != nil { + return err + } + return nil + }() + + if err != nil { + return err + } + return s.syncClient.SendSyncMessage(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId)) +} + +func (s *syncHandler) HandleFullSyncResponse( + ctx context.Context, + senderId string, + response *spacesyncproto.ObjectFullSyncResponse, + header *aclpb.TreeHeader, + treeId string) (err error) { + + var ( + snapshotPath []string + result tree.AddResult + ) + + res, err := s.treeCache.GetTree(ctx, treeId) + if err != nil { + return + } + + err = func() error { + objTree := res.Tree + objTree.Lock() + defer res.Release() + defer objTree.Unlock() + + // if we already have the heads for whatever reason + if slice.UnsortedEquals(response.Heads, objTree.Heads()) { + return nil + } + + result, err = objTree.AddRawChanges(ctx, response.Changes...) + if err != nil { + return err + } + snapshotPath = objTree.SnapshotPath() + return nil + }() + + // if error or nothing has changed + if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId { + return err + } + // if we have a new tree + if err == storage.ErrUnknownTreeId { + err = s.addTree(ctx, response, header, treeId) + if err != nil { + return err + } + result = tree.AddResult{ + OldHeads: []string{}, + Heads: response.Heads, + Added: response.Changes, + } + } + // sending heads update message + newUpdate := &spacesyncproto.ObjectHeadUpdate{ + Heads: result.Heads, + Changes: result.Added, + SnapshotPath: snapshotPath, + } + return s.syncClient.SendSyncMessage("", spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) +} + +func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges bool) (*spacesyncproto.ObjectFullSyncRequest, error) { + // TODO: add send own changes logic + return &spacesyncproto.ObjectFullSyncRequest{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + }, nil +} + +func (s *syncHandler) prepareFullSyncResponse( + treeId string, + theirPath, theirHeads []string, + t tree.ObjectTree) (*spacesyncproto.ObjectFullSyncResponse, error) { + ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads) + if err != nil { + return nil, err + } + + return &spacesyncproto.ObjectFullSyncResponse{ + Heads: t.Heads(), + Changes: ourChanges, + SnapshotPath: t.SnapshotPath(), + }, nil +} + +func (s *syncHandler) addTree( + ctx context.Context, + response *spacesyncproto.ObjectFullSyncResponse, + header *aclpb.TreeHeader, + treeId string) error { + + return s.treeCache.AddTree( + ctx, + storage.TreeStorageCreatePayload{ + TreeId: treeId, + Header: header, + Changes: response.Changes, + Heads: response.Heads, + }) +} From f900cbff0ba39c9b3d7c4e43c8fcfe11dbce0303 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 14 Sep 2022 18:54:10 +0200 Subject: [PATCH 16/44] WIP sync --- common/commonspace/rpchandler.go | 1 + common/commonspace/syncservice/streampool.go | 165 ++++++++++ common/commonspace/syncservice/synchandler.go | 27 +- common/commonspace/syncservice/syncservice.go | 293 +----------------- pkg/acl/account/accountdata.go | 2 +- service/sync/requesthandler/requesthandler.go | 2 - 6 files changed, 197 insertions(+), 293 deletions(-) create mode 100644 common/commonspace/syncservice/streampool.go diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index 3ce71e1a..9a2d6993 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -21,5 +21,6 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR } func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error { + return fmt.Errorf("not implemented") } diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go new file mode 100644 index 00000000..03cc6dcd --- /dev/null +++ b/common/commonspace/syncservice/streampool.go @@ -0,0 +1,165 @@ +package syncservice + +import ( + "errors" + "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/libp2p/go-libp2p-core/sec" + "storj.io/drpc" + "storj.io/drpc/drpcctx" + "sync" +) + +var ErrEmptyPeer = errors.New("don't have such a peer") +var ErrStreamClosed = errors.New("stream is already closed") + +const maxSimultaneousOperationsPerStream = 10 + +// StreamPool can be made generic to work with different streams +type StreamPool interface { + AddStream(stream spacesyncproto.SpaceStream) (err error) + SyncClient +} + +type SyncClient interface { + SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) + BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) (err error) +} + +type MessageHandler interface { + HandleMessage(peerId string, message *spacesyncproto.ObjectSyncMessage) +} + +type streamPool struct { + sync.Mutex + peerStreams map[string]spacesyncproto.SpaceStream + messageHandler MessageHandler +} + +func newStreamPool(messageHandler MessageHandler) StreamPool { + return &streamPool{ + peerStreams: make(map[string]spacesyncproto.SpaceStream), + messageHandler: messageHandler, + } +} + +func (s *streamPool) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) { + stream, err := s.getStream(peerId) + if err != nil { + return + } + + return stream.Send(message) +} + +func (s *streamPool) getStream(id string) (stream spacesyncproto.SpaceStream, err error) { + s.Lock() + defer s.Unlock() + stream, exists := s.peerStreams[id] + if !exists { + err = ErrEmptyPeer + return + } + + select { + case <-stream.Context().Done(): + delete(s.peerStreams, id) + err = ErrStreamClosed + default: + } + + return +} + +func (s *streamPool) getAllStreams() (streams []spacesyncproto.SpaceStream) { + s.Lock() + defer s.Unlock() +Loop: + for id, stream := range s.peerStreams { + select { + case <-stream.Context().Done(): + delete(s.peerStreams, id) + continue Loop + default: + } + streams = append(streams, stream) + } + + return +} + +func (s *streamPool) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) (err error) { + streams := s.getAllStreams() + for _, stream := range streams { + if err = stream.Send(message); err != nil { + // TODO: add logging + } + } + + return nil +} + +func (s *streamPool) AddStream(stream spacesyncproto.SpaceStream) (err error) { + s.Lock() + defer s.Unlock() + peerId, err := getPeerIdFromStream(stream) + if err != nil { + return + } + + s.peerStreams[peerId] = stream + go s.readPeerLoop(peerId, stream) + return +} + +func (s *streamPool) readPeerLoop(peerId string, stream spacesyncproto.SpaceStream) (err error) { + limiter := make(chan struct{}, maxSimultaneousOperationsPerStream) + for i := 0; i < maxSimultaneousOperationsPerStream; i++ { + limiter <- struct{}{} + } + +Loop: + for { + msg, err := stream.Recv() + if err != nil { + break + } + select { + case <-limiter: + case <-stream.Context().Done(): + break Loop + } + go func() { + defer func() { + limiter <- struct{}{} + }() + + s.messageHandler.HandleMessage(peerId, msg) + }() + } + if err = s.removePeer(peerId); err != nil { + // TODO: log something + } + return +} + +func (s *streamPool) removePeer(peerId string) (err error) { + s.Lock() + defer s.Unlock() + _, ok := s.peerStreams[peerId] + if !ok { + return ErrEmptyPeer + } + delete(s.peerStreams, peerId) + return +} + +func getPeerIdFromStream(stream drpc.Stream) (string, error) { + ctx := stream.Context() + conn, ok := ctx.Value(drpcctx.TransportKey{}).(sec.SecureConn) + if !ok { + return "", fmt.Errorf("incorrect connection type in stream") + } + + return conn.RemotePeer().String(), nil +} diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index fed8f8c9..2aa2ea9b 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -19,10 +19,6 @@ type SyncHandler interface { HandleSyncMessage(ctx context.Context, senderId string, request *spacesyncproto.ObjectSyncMessage) (err error) } -type SyncClient interface { - SendSyncMessage(peerId string, msg *spacesyncproto.ObjectSyncMessage) (err error) -} - func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandler { return &syncHandler{ treeCache: treeCache, @@ -96,7 +92,7 @@ func (s *syncHandler) HandleHeadUpdate( } // if we have incompatible heads, or we haven't seen the tree at all if fullRequest != nil { - return s.syncClient.SendSyncMessage(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) + return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) } // if error or nothing has changed if err != nil || len(result.Added) == 0 { @@ -109,7 +105,7 @@ func (s *syncHandler) HandleHeadUpdate( Changes: result.Added, SnapshotPath: snapshotPath, } - return s.syncClient.SendSyncMessage("", spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) + return s.syncClient.BroadcastAsync(spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) } func (s *syncHandler) HandleFullSyncRequest( @@ -142,7 +138,7 @@ func (s *syncHandler) HandleFullSyncRequest( if err != nil { return err } - return s.syncClient.SendSyncMessage(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId)) + return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId)) } func (s *syncHandler) HandleFullSyncResponse( @@ -163,21 +159,24 @@ func (s *syncHandler) HandleFullSyncResponse( } err = func() error { - objTree := res.Tree - objTree.Lock() + syncTree := res.Tree + syncTree.Lock() defer res.Release() - defer objTree.Unlock() + defer syncTree.Unlock() // if we already have the heads for whatever reason - if slice.UnsortedEquals(response.Heads, objTree.Heads()) { + if slice.UnsortedEquals(response.Heads, syncTree.Heads()) { return nil } - result, err = objTree.AddRawChanges(ctx, response.Changes...) + // syncTree -> syncService: HeadUpdate() + // AddRawChanges -> syncTree.addRawChanges(); syncService.HeadUpdate() + result, err = syncTree.AddRawChanges(ctx, response.Changes...) + if err != nil { return err } - snapshotPath = objTree.SnapshotPath() + snapshotPath = syncTree.SnapshotPath() return nil }() @@ -203,7 +202,7 @@ func (s *syncHandler) HandleFullSyncResponse( Changes: result.Added, SnapshotPath: snapshotPath, } - return s.syncClient.SendSyncMessage("", spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) + return s.syncClient.BroadcastAsync(spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) } func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges bool) (*spacesyncproto.ObjectFullSyncRequest, error) { diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 0f133fd9..c9ce956d 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -1,291 +1,32 @@ package syncservice import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" - "go.uber.org/zap" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" ) -type syncService struct { - treeCache treecache.Service - account account.Service - messageService MessageSender -} - -var log = logger.NewNamed("requesthandler") - -func New() app.Component { - return &syncService{} -} - type SyncService interface { - HandleSyncMessage(ctx context.Context, senderId string, request *syncproto.Sync) (err error) + NotifyHeadUpdate(treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) + StreamPool() StreamPool } -type MessageSender interface { - SendMessageAsync(peerId string, msg *syncproto.Sync) error - SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error +type syncService struct { + syncHandler SyncHandler + streamPool StreamPool + configuration nodeconf.Configuration } -const CName = "SyncRequestHandler" - -func (r *syncService) Init(a *app.App) (err error) { - r.treeCache = a.MustComponent(treecache.CName).(treecache.Service) - r.account = a.MustComponent(account.CName).(account.Service) - r.messageService = a.MustComponent("MessageService").(MessageSender) - return nil +func (s *syncService) NotifyHeadUpdate(treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { + msg := spacesyncproto.WrapHeadUpdate(update, header, treeId) + all + return s.streamPool.BroadcastAsync(msg) } -func (r *syncService) Name() (name string) { - return CName +func (s *syncService) StreamPool() StreamPool { + return s.streamPool } -func (r *syncService) Run(ctx context.Context) (err error) { - return nil -} - -func (r *syncService) Close(ctx context.Context) (err error) { - return nil -} - -func (r *syncService) HandleSyncMessage(ctx context.Context, senderId string, content *syncproto.Sync) error { - msg := content.GetMessage() - switch { - case msg.GetFullSyncRequest() != nil: - return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetFullSyncResponse() != nil: - return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetHeadUpdate() != nil: - return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetAclList() != nil: - return r.HandleACLList(ctx, senderId, msg.GetAclList(), content.GetTreeHeader(), content.GetTreeId()) - } - return nil -} - -func (r *syncService) HandleHeadUpdate( - ctx context.Context, - senderId string, - update *syncproto.SyncHeadUpdate, - header *aclpb.Header, - treeId string) (err error) { - - var ( - fullRequest *syncproto.SyncFullRequest - snapshotPath []string - result tree.AddResult - ) - log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)). - Debug("processing head update") - - err = r.treeCache.Do(ctx, treeId, func(obj any) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - if slice.UnsortedEquals(update.Heads, objTree.Heads()) { - return nil - } - - result, err = objTree.AddRawChanges(ctx, update.Changes...) - if err != nil { - return err - } - - // if we couldn't add all the changes - shouldFullSync := len(update.Changes) != len(result.Added) - snapshotPath = objTree.SnapshotPath() - if shouldFullSync { - fullRequest, err = r.prepareFullSyncRequest(objTree) - if err != nil { - return err - } - } - return nil - }) - - // if there are no such tree - if err == storage.ErrUnknownTreeId { - fullRequest = &syncproto.SyncFullRequest{} - } - // if we have incompatible heads, or we haven't seen the tree at all - if fullRequest != nil { - return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest, header, treeId)) - } - // if error or nothing has changed - if err != nil || len(result.Added) == 0 { - return err - } - - // otherwise sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) -} - -func (r *syncService) HandleFullSyncRequest( - ctx context.Context, - senderId string, - request *syncproto.SyncFullRequest, - header *aclpb.Header, - treeId string) (err error) { - - var fullResponse *syncproto.SyncFullResponse - err = r.treeCache.Do(ctx, treeId, func(obj any) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) - if err != nil { - return err - } - return nil - }) - - if err != nil { - return err - } - return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse, header, treeId)) -} - -func (r *syncService) HandleFullSyncResponse( - ctx context.Context, - senderId string, - response *syncproto.SyncFullResponse, - header *aclpb.Header, - treeId string) (err error) { - - var ( - snapshotPath []string - result tree.AddResult - ) - - err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - // if we already have the heads for whatever reason - if slice.UnsortedEquals(response.Heads, objTree.Heads()) { - return nil - } - - result, err = objTree.AddRawChanges(ctx, response.Changes...) - if err != nil { - return err - } - snapshotPath = objTree.SnapshotPath() - return nil - }) - - // if error or nothing has changed - if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId { - return err - } - // if we have a new tree - if err == storage.ErrUnknownTreeId { - err = r.createTree(ctx, response, header, treeId) - if err != nil { - return err - } - result = tree.AddResult{ - OldHeads: []string{}, - Heads: response.Heads, - Added: response.Changes, - } - } - // sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) -} - -func (r *syncService) HandleACLList( - ctx context.Context, - senderId string, - req *syncproto.SyncACLList, - header *aclpb.Header, - id string) (err error) { - - err = r.treeCache.Do(ctx, id, func(obj interface{}) error { - return nil - }) - // do nothing if already added - if err == nil { - return nil - } - // if not found then add to storage - if err == storage.ErrUnknownTreeId { - return r.createACLList(ctx, req, header, id) - } - return err -} - -func (r *syncService) prepareFullSyncRequest(t tree.ObjectTree) (*syncproto.SyncFullRequest, error) { - return &syncproto.SyncFullRequest{ - Heads: t.Heads(), - SnapshotPath: t.SnapshotPath(), - }, nil -} - -func (r *syncService) prepareFullSyncResponse( - treeId string, - theirPath, theirHeads []string, - t tree.ObjectTree) (*syncproto.SyncFullResponse, error) { - ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads) - if err != nil { - return nil, err - } - - return &syncproto.SyncFullResponse{ - Heads: t.Heads(), - Changes: ourChanges, - SnapshotPath: t.SnapshotPath(), - }, nil -} - -func (r *syncService) createTree( - ctx context.Context, - response *syncproto.SyncFullResponse, - header *aclpb.Header, - treeId string) error { - - return r.treeCache.Add( - ctx, - treeId, - storage.TreeStorageCreatePayload{ - TreeId: treeId, - Header: header, - Changes: response.Changes, - Heads: response.Heads, - }) -} - -func (r *syncService) createACLList( - ctx context.Context, - req *syncproto.SyncACLList, - header *aclpb.Header, - treeId string) error { - - return r.treeCache.Add( - ctx, - treeId, - storage.ACLListStorageCreatePayload{ - ListId: treeId, - Header: header, - Records: req.Records, - }) +func newSyncService() { + } diff --git a/pkg/acl/account/accountdata.go b/pkg/acl/account/accountdata.go index bc775854..4368a26c 100644 --- a/pkg/acl/account/accountdata.go +++ b/pkg/acl/account/accountdata.go @@ -7,7 +7,7 @@ import ( ) type AccountData struct { // TODO: create a convenient constructor for this - Identity []byte // TODO: this is essentially the same as sign key + Identity []byte // public key SignKey signingkey.PrivKey EncKey encryptionkey.PrivKey Decoder keys.Decoder diff --git a/service/sync/requesthandler/requesthandler.go b/service/sync/requesthandler/requesthandler.go index ca3055a3..9c17171f 100644 --- a/service/sync/requesthandler/requesthandler.go +++ b/service/sync/requesthandler/requesthandler.go @@ -65,8 +65,6 @@ func (r *requestHandler) HandleSyncMessage(ctx context.Context, senderId string, return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId()) case msg.GetHeadUpdate() != nil: return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetAclList() != nil: - return r.HandleACLList(ctx, senderId, msg.GetAclList(), content.GetTreeHeader(), content.GetTreeId()) } return nil } From aecb95bc9264abe96e29c2341f6ac17ae4c3ae29 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 15 Sep 2022 11:35:16 +0200 Subject: [PATCH 17/44] Add more logic re sync service --- common/commonspace/rpchandler.go | 4 +- common/commonspace/service.go | 9 ++-- common/commonspace/space.go | 18 +++++-- common/commonspace/syncservice/streampool.go | 25 +++++----- common/commonspace/syncservice/synchandler.go | 4 +- common/commonspace/syncservice/syncservice.go | 48 +++++++++++++++++-- 6 files changed, 79 insertions(+), 29 deletions(-) diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index 9a2d6993..e94df0b8 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -2,7 +2,6 @@ package commonspace import ( "context" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" ) @@ -21,6 +20,5 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR } func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error { - - return fmt.Errorf("not implemented") + return r.s.SyncService().StreamPool().AddStream(stream) } diff --git a/common/commonspace/service.go b/common/commonspace/service.go index 85dd8ae9..daeb321d 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -4,6 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" ) @@ -37,10 +38,12 @@ func (s *service) Name() (name string) { } func (s *service) CreateSpace(ctx context.Context, id string) (Space, error) { + syncService := syncservice.NewSyncService(id, nil, s.configurationService.GetLast()) sp := &space{ - id: id, - nconf: s.configurationService.GetLast(), - conf: s.config, + id: id, + nconf: s.configurationService.GetLast(), + conf: s.config, + syncService: syncService, } if err := sp.Init(ctx); err != nil { return nil, err diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 4f83dd97..0c223a09 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -5,6 +5,7 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" @@ -19,18 +20,21 @@ type Space interface { Id() string SpaceSyncRpc() RpcHandler + SyncService() syncservice.SyncService Close() error } type space struct { - id string - nconf nodeconf.Configuration - conf config.Space - diff ldiff.Diff + id string + nconf nodeconf.Configuration + conf config.Space + diff ldiff.Diff + mu sync.RWMutex + rpc *rpcHandler periodicSync *periodicSync - mu sync.RWMutex + syncService syncservice.SyncService } func (s *space) Id() string { @@ -49,6 +53,10 @@ func (s *space) SpaceSyncRpc() RpcHandler { return s.rpc } +func (s *space) SyncService() syncservice.SyncService { + return s.syncService +} + func (s *space) testFill() { var n = 1000 var els = make([]ldiff.Element, 0, n) diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 03cc6dcd..47d3063c 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -1,6 +1,7 @@ package syncservice import ( + "context" "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" @@ -18,6 +19,7 @@ const maxSimultaneousOperationsPerStream = 10 // StreamPool can be made generic to work with different streams type StreamPool interface { AddStream(stream spacesyncproto.SpaceStream) (err error) + HasStream(peerId string) bool SyncClient } @@ -26,9 +28,7 @@ type SyncClient interface { BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) (err error) } -type MessageHandler interface { - HandleMessage(peerId string, message *spacesyncproto.ObjectSyncMessage) -} +type MessageHandler func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) type streamPool struct { sync.Mutex @@ -43,6 +43,11 @@ func newStreamPool(messageHandler MessageHandler) StreamPool { } } +func (s *streamPool) HasStream(peerId string) (res bool) { + _, err := s.getStream(peerId) + return err == nil +} + func (s *streamPool) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) { stream, err := s.getStream(peerId) if err != nil { @@ -101,15 +106,16 @@ func (s *streamPool) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) ( func (s *streamPool) AddStream(stream spacesyncproto.SpaceStream) (err error) { s.Lock() - defer s.Unlock() peerId, err := getPeerIdFromStream(stream) if err != nil { + s.Unlock() return } s.peerStreams[peerId] = stream - go s.readPeerLoop(peerId, stream) - return + s.Unlock() + + return s.readPeerLoop(peerId, stream) } func (s *streamPool) readPeerLoop(peerId string, stream spacesyncproto.SpaceStream) (err error) { @@ -134,13 +140,10 @@ Loop: limiter <- struct{}{} }() - s.messageHandler.HandleMessage(peerId, msg) + s.messageHandler(context.Background(), peerId, msg) }() } - if err = s.removePeer(peerId); err != nil { - // TODO: log something - } - return + return s.removePeer(peerId) } func (s *streamPool) removePeer(peerId string) (err error) { diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 2aa2ea9b..fc04468d 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -16,7 +16,7 @@ type syncHandler struct { } type SyncHandler interface { - HandleSyncMessage(ctx context.Context, senderId string, request *spacesyncproto.ObjectSyncMessage) (err error) + HandleMessage(ctx context.Context, senderId string, request *spacesyncproto.ObjectSyncMessage) (err error) } func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandler { @@ -26,7 +26,7 @@ func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandl } } -func (s *syncHandler) HandleSyncMessage(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) error { +func (s *syncHandler) HandleMessage(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) error { msg := message.GetContent() switch { case msg.GetFullSyncRequest() != nil: diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index c9ce956d..4570ce85 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -1,13 +1,15 @@ package syncservice import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" ) type SyncService interface { - NotifyHeadUpdate(treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) + NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) StreamPool() StreamPool } @@ -15,11 +17,29 @@ type syncService struct { syncHandler SyncHandler streamPool StreamPool configuration nodeconf.Configuration + spaceId string } -func (s *syncService) NotifyHeadUpdate(treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { +func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { msg := spacesyncproto.WrapHeadUpdate(update, header, treeId) - all + peers, err := s.configuration.AllPeers(context.Background(), s.spaceId) + if err != nil { + return + } + for _, peer := range peers { + if !s.streamPool.HasStream(peer.Id()) { + cl := spacesyncproto.NewDRPCSpaceClient(peer) + stream, err := cl.Stream(ctx) + if err != nil { + continue + } + + s.streamPool.AddStream(stream) + if err != nil { + continue + } + } + } return s.streamPool.BroadcastAsync(msg) } @@ -27,6 +47,24 @@ func (s *syncService) StreamPool() StreamPool { return s.streamPool } -func newSyncService() { - +func NewSyncService(spaceId string, cache cache.TreeCache, configuration nodeconf.Configuration) SyncService { + var syncHandler SyncHandler + streamPool := newStreamPool(func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) { + return syncHandler.HandleMessage(ctx, senderId, message) + }) + syncHandler = newSyncHandler(cache, streamPool) + return newSyncService(spaceId, syncHandler, streamPool, configuration) +} + +func newSyncService( + spaceId string, + syncHandler SyncHandler, + streamPool StreamPool, + configuration nodeconf.Configuration) *syncService { + return &syncService{ + syncHandler: syncHandler, + streamPool: streamPool, + configuration: configuration, + spaceId: spaceId, + } } From fbdf820734943487b76970276c310f559bc6cad9 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 15 Sep 2022 12:34:28 +0200 Subject: [PATCH 18/44] Add sync tree and remove head send from sync handler --- common/commonspace/syncservice/synchandler.go | 55 ++----- common/commonspace/synctree/synctree.go | 151 ++++++++++++++++++ pkg/acl/tree/objecttree.go | 6 - 3 files changed, 162 insertions(+), 50 deletions(-) create mode 100644 common/commonspace/synctree/synctree.go diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index fc04468d..e53373b5 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -47,9 +47,8 @@ func (s *syncHandler) HandleHeadUpdate( treeId string) (err error) { var ( - fullRequest *spacesyncproto.ObjectFullSyncRequest - snapshotPath []string - result tree.AddResult + fullRequest *spacesyncproto.ObjectFullSyncRequest + result tree.AddResult // in case update changes are empty then we want to sync the whole tree sendChangesOnFullSync = len(update.Changes) == 0 ) @@ -76,7 +75,6 @@ func (s *syncHandler) HandleHeadUpdate( // if we couldn't add all the changes shouldFullSync := len(update.Changes) != len(result.Added) - snapshotPath = objTree.SnapshotPath() if shouldFullSync { fullRequest, err = s.prepareFullSyncRequest(objTree, sendChangesOnFullSync) if err != nil { @@ -94,18 +92,7 @@ func (s *syncHandler) HandleHeadUpdate( if fullRequest != nil { return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) } - // if error or nothing has changed - if err != nil || len(result.Added) == 0 { - return err - } - - // otherwise sending heads update message - newUpdate := &spacesyncproto.ObjectHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return s.syncClient.BroadcastAsync(spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) + return } func (s *syncHandler) HandleFullSyncRequest( @@ -148,10 +135,7 @@ func (s *syncHandler) HandleFullSyncResponse( header *aclpb.TreeHeader, treeId string) (err error) { - var ( - snapshotPath []string - result tree.AddResult - ) + var result tree.AddResult res, err := s.treeCache.GetTree(ctx, treeId) if err != nil { @@ -159,24 +143,21 @@ func (s *syncHandler) HandleFullSyncResponse( } err = func() error { - syncTree := res.Tree - syncTree.Lock() + objTree := res.Tree + objTree.Lock() defer res.Release() - defer syncTree.Unlock() + defer objTree.Unlock() // if we already have the heads for whatever reason - if slice.UnsortedEquals(response.Heads, syncTree.Heads()) { + if slice.UnsortedEquals(response.Heads, objTree.Heads()) { return nil } - // syncTree -> syncService: HeadUpdate() - // AddRawChanges -> syncTree.addRawChanges(); syncService.HeadUpdate() - result, err = syncTree.AddRawChanges(ctx, response.Changes...) + result, err = objTree.AddRawChanges(ctx, response.Changes...) if err != nil { return err } - snapshotPath = syncTree.SnapshotPath() return nil }() @@ -186,23 +167,9 @@ func (s *syncHandler) HandleFullSyncResponse( } // if we have a new tree if err == storage.ErrUnknownTreeId { - err = s.addTree(ctx, response, header, treeId) - if err != nil { - return err - } - result = tree.AddResult{ - OldHeads: []string{}, - Heads: response.Heads, - Added: response.Changes, - } + return s.addTree(ctx, response, header, treeId) } - // sending heads update message - newUpdate := &spacesyncproto.ObjectHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return s.syncClient.BroadcastAsync(spacesyncproto.WrapHeadUpdate(newUpdate, header, treeId)) + return } func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges bool) (*spacesyncproto.ObjectFullSyncRequest, error) { diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go new file mode 100644 index 00000000..8a948735 --- /dev/null +++ b/common/commonspace/synctree/synctree.go @@ -0,0 +1,151 @@ +package synctree + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" +) + +type SyncTree struct { + objTree tree.ObjectTree + syncService syncservice.SyncService +} + +func CreateSyncTree( + syncService syncservice.SyncService, + payload tree.ObjectTreeCreatePayload, + listener tree.ObjectTreeUpdateListener, + aclList list.ACLList, + createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) { + t, err = tree.CreateObjectTree(payload, listener, aclList, createStorage) + if err != nil { + return + } + + // TODO: use context where it is needed + err = syncService.NotifyHeadUpdate(context.Background(), t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + }) + return +} + +func BuildSyncTree( + syncService syncservice.SyncService, + treeStorage storage.TreeStorage, + listener tree.ObjectTreeUpdateListener, + aclList list.ACLList) (t tree.ObjectTree, err error) { + return buildSyncTree(syncService, treeStorage, listener, aclList) +} + +func buildSyncTree( + syncService syncservice.SyncService, + treeStorage storage.TreeStorage, + listener tree.ObjectTreeUpdateListener, + aclList list.ACLList) (t tree.ObjectTree, err error) { + t, err = tree.BuildObjectTree(treeStorage, listener, aclList) + if err != nil { + return + } + + // TODO: use context where it is needed + err = syncService.NotifyHeadUpdate(context.Background(), t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + }) + return +} + +func (s *SyncTree) Lock() { + s.objTree.Lock() +} + +func (s *SyncTree) Unlock() { + s.objTree.Unlock() +} + +func (s *SyncTree) RLock() { + s.objTree.RLock() +} + +func (s *SyncTree) RUnlock() { + s.objTree.RUnlock() +} + +func (s *SyncTree) ID() string { + return s.objTree.ID() +} + +func (s *SyncTree) Header() *aclpb.TreeHeader { + return s.objTree.Header() +} + +func (s *SyncTree) Heads() []string { + return s.objTree.Heads() +} + +func (s *SyncTree) Root() *tree.Change { + return s.objTree.Root() +} + +func (s *SyncTree) HasChange(id string) bool { + return s.objTree.HasChange(id) +} + +func (s *SyncTree) Iterate(convert tree.ChangeConvertFunc, iterate tree.ChangeIterateFunc) error { + return s.objTree.Iterate(convert, iterate) +} + +func (s *SyncTree) IterateFrom(id string, convert tree.ChangeConvertFunc, iterate tree.ChangeIterateFunc) error { + return s.objTree.IterateFrom(id, convert, iterate) +} + +func (s *SyncTree) SnapshotPath() []string { + return s.objTree.SnapshotPath() +} + +func (s *SyncTree) ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) { + return s.objTree.ChangesAfterCommonSnapshot(snapshotPath, heads) +} + +func (s *SyncTree) Storage() storage.TreeStorage { + return s.objTree.Storage() +} + +func (s *SyncTree) DebugDump() (string, error) { + return s.objTree.DebugDump() +} + +func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeContent) (res tree.AddResult, err error) { + res, err = s.objTree.AddContent(ctx, content) + if err != nil { + return + } + err = s.syncService.NotifyHeadUpdate(ctx, s.ID(), s.Header(), &spacesyncproto.ObjectHeadUpdate{ + Heads: res.Heads, + Changes: res.Added, + SnapshotPath: s.SnapshotPath(), + }) + return +} + +func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (res tree.AddResult, err error) { + res, err = s.objTree.AddRawChanges(ctx, changes...) + if err != nil || res.Mode == tree.Nothing { + return + } + err = s.syncService.NotifyHeadUpdate(ctx, s.ID(), s.Header(), &spacesyncproto.ObjectHeadUpdate{ + Heads: res.Heads, + Changes: res.Added, + SnapshotPath: s.SnapshotPath(), + }) + return +} + +func (s *SyncTree) Close() error { + return s.objTree.Close() +} diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 31365b87..186db5af 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -149,12 +149,6 @@ func (ot *objectTree) Storage() storage.TreeStorage { } func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeContent) (res AddResult, err error) { - defer func() { - if err == nil && ot.updateListener != nil { - ot.updateListener.Update(ot) - } - }() - payload, err := ot.prepareBuilderContent(content) if err != nil { return From 34ef43786c88f15506124d946e67ae6d75ed3419 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 15 Sep 2022 13:42:51 +0200 Subject: [PATCH 19/44] Update tree sync logic --- common/commonspace/cache/treecache.go | 12 +++++-- common/commonspace/service.go | 8 +++++ common/commonspace/space.go | 32 +++++++++++++++++++ common/commonspace/storage/storage.go | 13 ++++++++ common/commonspace/syncservice/synchandler.go | 6 ++-- common/commonspace/synctree/synctree.go | 2 +- 6 files changed, 67 insertions(+), 6 deletions(-) create mode 100644 common/commonspace/storage/storage.go diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 342c9042..9d688f50 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -2,16 +2,24 @@ package cache import ( "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) +const CName = "commonspace.cache" + +type TreeContainer interface { + Tree() tree.ObjectTree +} + type TreeResult struct { - Release func() - Tree tree.ObjectTree + Release func() + TreeContainer TreeContainer } type TreeCache interface { + app.ComponentRunnable GetTree(ctx context.Context, id string) (TreeResult, error) AddTree(ctx context.Context, payload storage.TreeStorageCreatePayload) error } diff --git a/common/commonspace/service.go b/common/commonspace/service.go index daeb321d..3c084562 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -4,6 +4,8 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "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/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" @@ -25,11 +27,15 @@ type Service interface { type service struct { config config.Space configurationService nodeconf.Service + storage storage.Storage + cache cache.TreeCache } func (s *service) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(*config.Config).Space s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) + s.storage = a.MustComponent(storage.CName).(storage.Storage) + s.cache = a.MustComponent(cache.CName).(cache.TreeCache) return nil } @@ -44,6 +50,8 @@ func (s *service) CreateSpace(ctx context.Context, id string) (Space, error) { nconf: s.configurationService.GetLast(), conf: s.config, syncService: syncService, + cache: s.cache, + storage: s.storage, } if err := sp.Init(ctx); err != nil { return nil, err diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 0c223a09..58b4391e 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -3,12 +3,17 @@ package commonspace import ( "context" "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "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/synctree" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" "go.uber.org/zap" "math/rand" @@ -22,6 +27,9 @@ type Space interface { SpaceSyncRpc() RpcHandler SyncService() syncservice.SyncService + CreateTree(payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) + BuildTree(id string, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) + Close() error } @@ -35,6 +43,21 @@ type space struct { rpc *rpcHandler periodicSync *periodicSync syncService syncservice.SyncService + storage storage.Storage + cache cache.TreeCache +} + +func (s *space) CreateTree(payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { + return synctree.CreateSyncTree(payload, s.syncService, listener, nil, s.storage.CreateTreeStorage) +} + +func (s *space) BuildTree(id string, listener tree.ObjectTreeUpdateListener) (t tree.ObjectTree, err error) { + store, err := s.storage.Storage(id) + if err != nil { + return + } + + return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, nil) } func (s *space) Id() string { @@ -100,10 +123,19 @@ func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { if err != nil { return nil } + s.pingTreesInCache(ctx, newIds) + s.pingTreesInCache(ctx, changedIds) + log.Info("sync done:", zap.Int("newIds", len(newIds)), zap.Int("changedIds", len(changedIds)), zap.Int("removedIds", len(removedIds))) return } +func (s *space) pingTreesInCache(ctx context.Context, trees []string) { + for _, tId := range trees { + _, _ = s.cache.GetTree(ctx, tId) + } +} + func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { if s.nconf.IsResponsible(s.id) { return s.nconf.AllPeers(ctx, s.id) diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go new file mode 100644 index 00000000..a9694988 --- /dev/null +++ b/common/commonspace/storage/storage.go @@ -0,0 +1,13 @@ +package storage + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" +) + +type Storage interface { + storage.Provider + app.ComponentRunnable +} + +const CName = "commonspace.storage" diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index e53373b5..87d8d445 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -59,7 +59,7 @@ func (s *syncHandler) HandleHeadUpdate( } err = func() error { - objTree := res.Tree + objTree := res.TreeContainer.Tree() objTree.Lock() defer res.Release() defer objTree.Unlock() @@ -111,7 +111,7 @@ func (s *syncHandler) HandleFullSyncRequest( // TODO: check if sync request contains changes and add them (also do head update in this case) err = func() error { - objTree := res.Tree + objTree := res.TreeContainer.Tree() objTree.Lock() defer res.Release() defer objTree.Unlock() @@ -143,7 +143,7 @@ func (s *syncHandler) HandleFullSyncResponse( } err = func() error { - objTree := res.Tree + objTree := res.TreeContainer.Tree() objTree.Lock() defer res.Release() defer objTree.Unlock() diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 8a948735..3b84ee77 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -16,8 +16,8 @@ type SyncTree struct { } func CreateSyncTree( - syncService syncservice.SyncService, payload tree.ObjectTreeCreatePayload, + syncService syncservice.SyncService, listener tree.ObjectTreeUpdateListener, aclList list.ACLList, createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) { From a48e8f357afc2c772d63d570065c30f835a3f13c Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Thu, 15 Sep 2022 14:11:49 +0200 Subject: [PATCH 20/44] Update peer reading logic --- common/commonspace/rpchandler.go | 10 +++++-- common/commonspace/space.go | 2 +- common/commonspace/syncservice/streampool.go | 22 +++++++++++++--- common/commonspace/syncservice/syncservice.go | 26 ++++++++++++------- 4 files changed, 44 insertions(+), 16 deletions(-) diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index e94df0b8..b0d0be69 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -19,6 +19,12 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR return remotediff.HandlerRangeRequest(ctx, r.s.diff, req) } -func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error { - return r.s.SyncService().StreamPool().AddStream(stream) +func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) (err error) { + err = r.s.SyncService().StreamPool().AddAndReadStream(stream) + if err != nil { + return + } + + <-stream.Context().Done() + return } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 58b4391e..757b1f32 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -151,5 +151,5 @@ func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { func (s *space) Close() error { s.periodicSync.Close() - return nil + return s.syncService.Close() } diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 47d3063c..6b402294 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -18,9 +18,10 @@ const maxSimultaneousOperationsPerStream = 10 // StreamPool can be made generic to work with different streams type StreamPool interface { - AddStream(stream spacesyncproto.SpaceStream) (err error) + AddAndReadStream(stream spacesyncproto.SpaceStream) (err error) HasStream(peerId string) bool SyncClient + Close() (err error) } type SyncClient interface { @@ -34,12 +35,14 @@ type streamPool struct { sync.Mutex peerStreams map[string]spacesyncproto.SpaceStream messageHandler MessageHandler + wg *sync.WaitGroup } func newStreamPool(messageHandler MessageHandler) StreamPool { return &streamPool{ peerStreams: make(map[string]spacesyncproto.SpaceStream), messageHandler: messageHandler, + wg: &sync.WaitGroup{}, } } @@ -104,7 +107,7 @@ func (s *streamPool) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) ( return nil } -func (s *streamPool) AddStream(stream spacesyncproto.SpaceStream) (err error) { +func (s *streamPool) AddAndReadStream(stream spacesyncproto.SpaceStream) (err error) { s.Lock() peerId, err := getPeerIdFromStream(stream) if err != nil { @@ -113,12 +116,25 @@ func (s *streamPool) AddStream(stream spacesyncproto.SpaceStream) (err error) { } s.peerStreams[peerId] = stream + s.wg.Add(1) s.Unlock() - return s.readPeerLoop(peerId, stream) + go s.readPeerLoop(peerId, stream) + return +} + +func (s *streamPool) Close() (err error) { + s.Lock() + wg := s.wg + s.Unlock() + if wg != nil { + wg.Wait() + } + return nil } func (s *streamPool) readPeerLoop(peerId string, stream spacesyncproto.SpaceStream) (err error) { + defer s.wg.Done() limiter := make(chan struct{}, maxSimultaneousOperationsPerStream) for i := 0; i < maxSimultaneousOperationsPerStream; i++ { limiter <- struct{}{} diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 4570ce85..c3f85101 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -11,6 +11,7 @@ import ( type SyncService interface { NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) StreamPool() StreamPool + Close() (err error) } type syncService struct { @@ -20,6 +21,10 @@ type syncService struct { spaceId string } +func (s *syncService) Close() (err error) { + return s.streamPool.Close() +} + func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { msg := spacesyncproto.WrapHeadUpdate(update, header, treeId) peers, err := s.configuration.AllPeers(context.Background(), s.spaceId) @@ -27,17 +32,18 @@ func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, heade return } for _, peer := range peers { - if !s.streamPool.HasStream(peer.Id()) { - cl := spacesyncproto.NewDRPCSpaceClient(peer) - stream, err := cl.Stream(ctx) - if err != nil { - continue - } + if s.streamPool.HasStream(peer.Id()) { + continue + } + cl := spacesyncproto.NewDRPCSpaceClient(peer) + stream, err := cl.Stream(ctx) + if err != nil { + continue + } - s.streamPool.AddStream(stream) - if err != nil { - continue - } + err = s.streamPool.AddAndReadStream(stream) + if err != nil { + continue } } return s.streamPool.BroadcastAsync(msg) From 91aacdd95592594308397f498f8db59b1aae77ce Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 16 Sep 2022 00:22:22 +0200 Subject: [PATCH 21/44] Add build tree sync request --- common/commonspace/rpchandler.go | 8 +-- common/commonspace/space.go | 45 ++++++++++-- common/commonspace/syncservice/streampool.go | 73 +++++++++++++++++--- common/commonspace/synctree/synctree.go | 70 +------------------ 4 files changed, 109 insertions(+), 87 deletions(-) diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index b0d0be69..be83b43c 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -20,11 +20,5 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR } func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) (err error) { - err = r.s.SyncService().StreamPool().AddAndReadStream(stream) - if err != nil { - return - } - - <-stream.Context().Done() - return + return r.s.SyncService().StreamPool().AddAndReadStream(stream) } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 757b1f32..69cac657 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -27,8 +27,8 @@ type Space interface { SpaceSyncRpc() RpcHandler SyncService() syncservice.SyncService - CreateTree(payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) - BuildTree(id string, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) + CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) + BuildTree(ctx context.Context, id string, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) Close() error } @@ -47,16 +47,51 @@ type space struct { cache cache.TreeCache } -func (s *space) CreateTree(payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { +func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { return synctree.CreateSyncTree(payload, s.syncService, listener, nil, s.storage.CreateTreeStorage) } -func (s *space) BuildTree(id string, listener tree.ObjectTreeUpdateListener) (t tree.ObjectTree, err error) { +func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTreeUpdateListener) (t tree.ObjectTree, err error) { + getTreeRemote := func() (*spacesyncproto.ObjectSyncMessage, error) { + // TODO: add empty context handling (when this is not happening due to head update) + peerId, err := syncservice.GetPeerIdFromStreamContext(ctx) + if err != nil { + return nil, err + } + + return s.syncService.StreamPool().SendSync( + peerId, + spacesyncproto.WrapFullRequest(&spacesyncproto.ObjectFullSyncRequest{}, nil, id), + func(syncMessage *spacesyncproto.ObjectSyncMessage) bool { + return syncMessage.GetContent().GetFullSyncResponse() != nil + }, + ) + } + store, err := s.storage.Storage(id) - if err != nil { + if err != nil && err != treestorage.ErrUnknownTreeId { return } + if err == treestorage.ErrUnknownTreeId { + var resp *spacesyncproto.ObjectSyncMessage + resp, err = getTreeRemote() + if err != nil { + return + } + fullSyncResp := resp.GetContent().GetFullSyncResponse() + + payload := treestorage.TreeStorageCreatePayload{ + TreeId: resp.TreeId, + Header: resp.TreeHeader, + Changes: fullSyncResp.Changes, + Heads: fullSyncResp.Heads, + } + store, err = s.storage.CreateTreeStorage(payload) + if err != nil { + return + } + } return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, nil) } diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 6b402294..0ccd2d6b 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/libp2p/go-libp2p-core/sec" - "storj.io/drpc" "storj.io/drpc/drpcctx" "sync" ) @@ -25,17 +24,27 @@ type StreamPool interface { } type SyncClient interface { + SendSync(peerId string, + message *spacesyncproto.ObjectSyncMessage, + msgCheck func(syncMessage *spacesyncproto.ObjectSyncMessage) bool) (reply *spacesyncproto.ObjectSyncMessage, err error) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) (err error) } type MessageHandler func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) +type responseWaiter struct { + ch chan *spacesyncproto.ObjectSyncMessage + msgCheck func(message *spacesyncproto.ObjectSyncMessage) bool +} + type streamPool struct { sync.Mutex peerStreams map[string]spacesyncproto.SpaceStream messageHandler MessageHandler wg *sync.WaitGroup + waiters map[string]responseWaiter + waitersMx sync.Mutex } func newStreamPool(messageHandler MessageHandler) StreamPool { @@ -51,6 +60,41 @@ func (s *streamPool) HasStream(peerId string) (res bool) { return err == nil } +func (s *streamPool) SendSync( + peerId string, + message *spacesyncproto.ObjectSyncMessage, + msgCheck func(syncMessage *spacesyncproto.ObjectSyncMessage) bool) (reply *spacesyncproto.ObjectSyncMessage, err error) { + + sendAndWait := func(waiter responseWaiter) (err error) { + err = s.SendAsync(peerId, message) + if err != nil { + return + } + + reply = <-waiter.ch + return + } + + key := fmt.Sprintf("%s.%s", peerId, message.TreeId) + s.waitersMx.Lock() + waiter, exists := s.waiters[key] + if exists { + s.waitersMx.Unlock() + + err = sendAndWait(waiter) + return + } + + waiter = responseWaiter{ + ch: make(chan *spacesyncproto.ObjectSyncMessage), + msgCheck: msgCheck, + } + s.waiters[key] = waiter + s.waitersMx.Unlock() + err = sendAndWait(waiter) + return +} + func (s *streamPool) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) { stream, err := s.getStream(peerId) if err != nil { @@ -109,7 +153,7 @@ func (s *streamPool) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) ( func (s *streamPool) AddAndReadStream(stream spacesyncproto.SpaceStream) (err error) { s.Lock() - peerId, err := getPeerIdFromStream(stream) + peerId, err := GetPeerIdFromStreamContext(stream.Context()) if err != nil { s.Unlock() return @@ -119,8 +163,7 @@ func (s *streamPool) AddAndReadStream(stream spacesyncproto.SpaceStream) (err er s.wg.Add(1) s.Unlock() - go s.readPeerLoop(peerId, stream) - return + return s.readPeerLoop(peerId, stream) } func (s *streamPool) Close() (err error) { @@ -140,6 +183,22 @@ func (s *streamPool) readPeerLoop(peerId string, stream spacesyncproto.SpaceStre limiter <- struct{}{} } + process := func(msg *spacesyncproto.ObjectSyncMessage) { + key := fmt.Sprintf("%s.%s", peerId, msg.TreeId) + s.waitersMx.Lock() + waiter, exists := s.waiters[key] + + if !exists || !waiter.msgCheck(msg) { + s.waitersMx.Unlock() + s.messageHandler(stream.Context(), peerId, msg) + return + } + + delete(s.waiters, key) + s.waitersMx.Unlock() + waiter.ch <- msg + } + Loop: for { msg, err := stream.Recv() @@ -155,8 +214,7 @@ Loop: defer func() { limiter <- struct{}{} }() - - s.messageHandler(context.Background(), peerId, msg) + process(msg) }() } return s.removePeer(peerId) @@ -173,8 +231,7 @@ func (s *streamPool) removePeer(peerId string) (err error) { return } -func getPeerIdFromStream(stream drpc.Stream) (string, error) { - ctx := stream.Context() +func GetPeerIdFromStreamContext(ctx context.Context) (string, error) { conn, ok := ctx.Value(drpcctx.TransportKey{}).(sec.SecureConn) if !ok { return "", fmt.Errorf("incorrect connection type in stream") diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 3b84ee77..d9dcb4e4 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -11,7 +11,7 @@ import ( ) type SyncTree struct { - objTree tree.ObjectTree + tree.ObjectTree syncService syncservice.SyncService } @@ -60,68 +60,8 @@ func buildSyncTree( return } -func (s *SyncTree) Lock() { - s.objTree.Lock() -} - -func (s *SyncTree) Unlock() { - s.objTree.Unlock() -} - -func (s *SyncTree) RLock() { - s.objTree.RLock() -} - -func (s *SyncTree) RUnlock() { - s.objTree.RUnlock() -} - -func (s *SyncTree) ID() string { - return s.objTree.ID() -} - -func (s *SyncTree) Header() *aclpb.TreeHeader { - return s.objTree.Header() -} - -func (s *SyncTree) Heads() []string { - return s.objTree.Heads() -} - -func (s *SyncTree) Root() *tree.Change { - return s.objTree.Root() -} - -func (s *SyncTree) HasChange(id string) bool { - return s.objTree.HasChange(id) -} - -func (s *SyncTree) Iterate(convert tree.ChangeConvertFunc, iterate tree.ChangeIterateFunc) error { - return s.objTree.Iterate(convert, iterate) -} - -func (s *SyncTree) IterateFrom(id string, convert tree.ChangeConvertFunc, iterate tree.ChangeIterateFunc) error { - return s.objTree.IterateFrom(id, convert, iterate) -} - -func (s *SyncTree) SnapshotPath() []string { - return s.objTree.SnapshotPath() -} - -func (s *SyncTree) ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) { - return s.objTree.ChangesAfterCommonSnapshot(snapshotPath, heads) -} - -func (s *SyncTree) Storage() storage.TreeStorage { - return s.objTree.Storage() -} - -func (s *SyncTree) DebugDump() (string, error) { - return s.objTree.DebugDump() -} - func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeContent) (res tree.AddResult, err error) { - res, err = s.objTree.AddContent(ctx, content) + res, err = s.AddContent(ctx, content) if err != nil { return } @@ -134,7 +74,7 @@ func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeCo } func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (res tree.AddResult, err error) { - res, err = s.objTree.AddRawChanges(ctx, changes...) + res, err = s.AddRawChanges(ctx, changes...) if err != nil || res.Mode == tree.Nothing { return } @@ -145,7 +85,3 @@ func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeC }) return } - -func (s *SyncTree) Close() error { - return s.objTree.Close() -} From eb36eed4c03a455c308f0e6bc76407e2451253f8 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 16 Sep 2022 07:47:36 +0200 Subject: [PATCH 22/44] Add tree validation before saving --- common/commonspace/space.go | 14 ++++++++++++-- pkg/acl/tree/rawtreevalidator.go | 17 +++++++++++++++++ 2 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 pkg/acl/tree/rawtreevalidator.go diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 69cac657..bece7ca7 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -12,6 +12,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" @@ -45,6 +46,7 @@ type space struct { syncService syncservice.SyncService storage storage.Storage cache cache.TreeCache + aclList list.ACLList } func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { @@ -63,7 +65,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTr peerId, spacesyncproto.WrapFullRequest(&spacesyncproto.ObjectFullSyncRequest{}, nil, id), func(syncMessage *spacesyncproto.ObjectSyncMessage) bool { - return syncMessage.GetContent().GetFullSyncResponse() != nil + return syncMessage.TreeId == id && syncMessage.GetContent().GetFullSyncResponse() != nil }, ) } @@ -87,12 +89,20 @@ func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTr Changes: fullSyncResp.Changes, Heads: fullSyncResp.Heads, } + + // basically building tree with inmemory storage and validating that it was without errors + err = tree.ValidateRawTree(payload, s.aclList) + if err != nil { + return + } + // TODO: maybe it is better to use the tree that we already built and just replace the storage + // now we are sure that we can save it to the storage store, err = s.storage.CreateTreeStorage(payload) if err != nil { return } } - return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, nil) + return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, s.aclList) } func (s *space) Id() string { diff --git a/pkg/acl/tree/rawtreevalidator.go b/pkg/acl/tree/rawtreevalidator.go new file mode 100644 index 00000000..86a0082f --- /dev/null +++ b/pkg/acl/tree/rawtreevalidator.go @@ -0,0 +1,17 @@ +package tree + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" +) + +func ValidateRawTree(payload storage.TreeStorageCreatePayload, aclList list.ACLList) (err error) { + provider := storage.NewInMemoryTreeStorageProvider() + treeStorage, err := provider.CreateTreeStorage(payload) + if err != nil { + return + } + + _, err = BuildObjectTree(treeStorage, nil, aclList) + return +} From 1bc9242644d14d88092832ca92ae16a71c6399e4 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 16 Sep 2022 10:17:54 +0200 Subject: [PATCH 23/44] Update sync handler --- .../spacesyncproto/protos/spacesync.proto | 6 +- .../spacesyncproto/spacesync.pb.go | 264 ++++++++++++++---- common/commonspace/syncservice/synchandler.go | 77 ++--- 3 files changed, 247 insertions(+), 100 deletions(-) diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 25c5fefb..7fd7d411 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -51,6 +51,9 @@ message ObjectSyncMessage { ObjectSyncContentValue content = 2; acl.TreeHeader treeHeader = 3; string treeId = 4; + + string identity = 5; + string peerSignature = 6; } // ObjectSyncContentValue provides different types for object sync @@ -72,7 +75,8 @@ message ObjectHeadUpdate { // ObjectHeadUpdate is a message sent when document needs full sync message ObjectFullSyncRequest { repeated string heads = 1; - repeated string snapshotPath = 2; + repeated acl.RawTreeChangeWithId changes = 2; + repeated string snapshotPath = 3; } // ObjectFullSyncResponse is a message sent as a response for a specific full sync diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index b23dcf9b..64419bb0 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -320,10 +320,12 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + Identity string `protobuf:"bytes,5,opt,name=identity,proto3" json:"identity,omitempty"` + PeerSignature string `protobuf:"bytes,6,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -387,6 +389,20 @@ func (m *ObjectSyncMessage) GetTreeId() string { return "" } +func (m *ObjectSyncMessage) GetIdentity() string { + if m != nil { + return m.Identity + } + return "" +} + +func (m *ObjectSyncMessage) GetPeerSignature() string { + if m != nil { + return m.PeerSignature + } + return "" +} + // ObjectSyncContentValue provides different types for object sync type ObjectSyncContentValue struct { // Types that are valid to be assigned to Value: @@ -549,8 +565,9 @@ func (m *ObjectHeadUpdate) GetSnapshotPath() []string { // ObjectHeadUpdate is a message sent when document needs full sync type ObjectFullSyncRequest struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - SnapshotPath []string `protobuf:"bytes,2,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} } @@ -593,6 +610,13 @@ func (m *ObjectFullSyncRequest) GetHeads() []string { return nil } +func (m *ObjectFullSyncRequest) GetChanges() []*aclpb.RawTreeChangeWithId { + if m != nil { + return m.Changes + } + return nil +} + func (m *ObjectFullSyncRequest) GetSnapshotPath() []string { if m != nil { return m.SnapshotPath @@ -680,49 +704,51 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 666 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x54, 0x4f, 0x6f, 0xd3, 0x4e, - 0x10, 0xf5, 0xa6, 0x6d, 0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 0x54, 0x23, 0x5f, 0x1b, 0xae, 0xbe, - 0x54, 0x7d, 0xe2, 0x5a, 0x12, 0xb4, 0xe6, 0x5b, 0x50, 0x46, 0x1f, 0x87, 0x18, 0x68, 0x65, 0x17, - 0x1a, 0x73, 0xcd, 0x4a, 0x67, 0xa3, 0x95, 0xe9, 0x6f, 0x5d, 0xc6, 0xef, 0x26, 0x75, 0x62, 0x0c, - 0x30, 0x07, 0xbb, 0xe1, 0x28, 0x18, 0x1f, 0x4c, 0x81, 0xb3, 0x05, 0x6b, 0xb9, 0x40, 0xa3, 0x7b, - 0xe0, 0xd1, 0xe9, 0x8b, 0xa2, 0x30, 0xf0, 0x48, 0x0f, 0x4a, 0x8f, 0x3a, 0x59, 0x14, 0xb4, 0x76, - 0xde, 0xc0, 0xea, 0x04, 0xfc, 0x7e, 0x84, 0x4a, 0x73, 0x1b, 0x4a, 0x64, 0x71, 0x2f, 0xc3, 0x66, - 0x21, 0x6f, 0x43, 0x31, 0x26, 0xf7, 0x52, 0xe9, 0x37, 0x72, 0xa4, 0x9b, 0x7d, 0x91, 0x96, 0x39, - 0x7b, 0x50, 0x9d, 0x92, 0x16, 0x85, 0x81, 0x42, 0xde, 0x81, 0x52, 0x4c, 0x32, 0x95, 0xcd, 0x88, - 0xc5, 0xbe, 0xca, 0x00, 0x91, 0x15, 0x3a, 0xdf, 0x18, 0xfc, 0xf7, 0xf4, 0xf0, 0x2d, 0xba, 0xda, - 0xec, 0x3e, 0x46, 0xa5, 0xe4, 0x31, 0x5e, 0x23, 0xf4, 0x3e, 0x94, 0xdc, 0x30, 0xd0, 0x18, 0x68, - 0x6a, 0xb6, 0xd2, 0x69, 0x4c, 0xce, 0x98, 0xf0, 0xec, 0x24, 0x25, 0x2f, 0xa5, 0x3f, 0x42, 0x91, - 0x01, 0x78, 0x1b, 0x40, 0xc7, 0x88, 0x46, 0x0a, 0xc6, 0xe4, 0x74, 0xa5, 0xb3, 0xda, 0x92, 0xae, - 0xdf, 0x7a, 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, 0xe0, 0xc7, 0x08, 0x5d, 0x8d, 0x5e, 0xd5, 0xea, - 0x7c, 0x65, 0xb0, 0x40, 0x17, 0xc7, 0x1f, 0x42, 0x39, 0x9b, 0x29, 0x7e, 0x33, 0x6f, 0xce, 0xc8, - 0x8f, 0x5a, 0x2d, 0x77, 0x04, 0x93, 0xb6, 0xf6, 0xa0, 0xb8, 0xaf, 0x63, 0x94, 0x43, 0x7e, 0x2b, - 0x6f, 0x88, 0xd2, 0x61, 0xac, 0x5d, 0xb7, 0xd9, 0x64, 0x9b, 0x6c, 0x7b, 0xeb, 0xfb, 0x79, 0x9d, - 0x9d, 0x9d, 0xd7, 0xd9, 0xcf, 0xf3, 0x3a, 0xfb, 0x72, 0x51, 0xb7, 0xce, 0x2e, 0xea, 0xd6, 0x8f, - 0x8b, 0xba, 0xf5, 0xfa, 0xf6, 0x5f, 0xff, 0xfa, 0x0f, 0x8b, 0xf4, 0xba, 0xfb, 0x3b, 0x00, 0x00, - 0xff, 0xff, 0xcf, 0x4f, 0x53, 0x3d, 0x26, 0x06, 0x00, 0x00, + // 695 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcb, 0x6f, 0xd3, 0x4e, + 0x10, 0x8e, 0xd3, 0xe6, 0xd1, 0x49, 0x1f, 0xf9, 0xad, 0x7e, 0x2d, 0x26, 0x48, 0x69, 0xb0, 0x38, + 0x44, 0x1c, 0x92, 0x2a, 0x5c, 0x10, 0xe5, 0x42, 0xab, 0x56, 0x89, 0x10, 0x0f, 0x6d, 0x28, 0x48, + 0x88, 0xcb, 0xd6, 0x9e, 0x26, 0x06, 0xc7, 0x36, 0xde, 0x0d, 0x25, 0x37, 0x2e, 0x70, 0x46, 0xfc, + 0x55, 0x1c, 0x7b, 0xe4, 0x88, 0xda, 0x7f, 0x81, 0x23, 0x07, 0xb4, 0x63, 0x3b, 0x2f, 0xd2, 0x72, +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1, 0x59, 0xd7, 0x21, 0x3d, 0x28, 0x1c, 0xca, 0x64, 0x85, 0xd3, 0xda, 0x7a, + 0x03, 0x1b, 0x13, 0xf2, 0xfb, 0x21, 0x4a, 0xc5, 0x4c, 0x28, 0x50, 0x89, 0x3b, 0x29, 0x37, 0x35, + 0x59, 0x13, 0xf2, 0x11, 0x55, 0x2f, 0x91, 0x7e, 0x63, 0x81, 0x74, 0xbd, 0xcf, 0x13, 0x98, 0x75, + 0x08, 0xe5, 0x29, 0x69, 0x61, 0xe0, 0x4b, 0x64, 0x2d, 0x28, 0x44, 0x24, 0x53, 0x9a, 0x06, 0x45, + 0x31, 0x2f, 0x2b, 0x00, 0x4f, 0x81, 0xd6, 0x2f, 0x03, 0xfe, 0x7b, 0x76, 0xfc, 0x16, 0x6d, 0xa5, + 0x77, 0x9f, 0xa0, 0x94, 0xa2, 0x87, 0x57, 0x08, 0x7d, 0x00, 0x05, 0x3b, 0xf0, 0x15, 0xfa, 0x8a, + 0x92, 0x2d, 0xb5, 0x6a, 0x93, 0x33, 0x26, 0x71, 0xf6, 0x63, 0xc8, 0x4b, 0xe1, 0x0d, 0x91, 0xa7, + 0x04, 0xd6, 0x04, 0x50, 0x11, 0xa2, 0x96, 0x82, 0x11, 0x55, 0xba, 0xd4, 0xda, 0x68, 0x08, 0xdb, + 0x6b, 0xbc, 0x18, 0xbb, 0xf9, 0x14, 0x84, 0x6d, 0x41, 0x5e, 0x5b, 0x1d, 0xc7, 0x5c, 0x26, 0x15, + 0x89, 0xc5, 0x2a, 0x50, 0x74, 0x1d, 0xf4, 0x95, 0xab, 0x46, 0x66, 0x8e, 0x76, 0xc6, 0x36, 0xbb, + 0x03, 0x6b, 0x21, 0x62, 0xd4, 0x75, 0x7b, 0xbe, 0x50, 0xc3, 0x08, 0xcd, 0x3c, 0x01, 0x66, 0x9d, + 0xd6, 0x6f, 0x03, 0xb6, 0x16, 0xcb, 0x65, 0x0f, 0x01, 0x74, 0xff, 0x8e, 0x42, 0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xbe, 0xab, 0x22, 0x14, 0x03, 0x76, 0x6b, 0xd1, 0xec, 0x26, 0xff, 0x01, + 0x95, 0xab, 0x36, 0xeb, 0xc6, 0x8e, 0xb1, 0xb7, 0xfb, 0xfd, 0xbc, 0x6a, 0x9c, 0x9d, 0x57, 0x8d, + 0x9f, 0xe7, 0x55, 0xe3, 0xeb, 0x45, 0x35, 0x73, 0x76, 0x51, 0xcd, 0xfc, 0xb8, 0xa8, 0x66, 0x5e, + 0xdf, 0xfe, 0xe7, 0x17, 0xe7, 0x38, 0x4f, 0xaf, 0x7b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x57, + 0xb9, 0x93, 0x47, 0x9d, 0x06, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -950,6 +976,20 @@ func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if len(m.PeerSignature) > 0 { + i -= len(m.PeerSignature) + copy(dAtA[i:], m.PeerSignature) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.PeerSignature))) + i-- + dAtA[i] = 0x32 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x2a + } if len(m.TreeId) > 0 { i -= len(m.TreeId) copy(dAtA[i:], m.TreeId) @@ -1167,6 +1207,20 @@ func (m *ObjectFullSyncRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { copy(dAtA[i:], m.SnapshotPath[iNdEx]) i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx]))) i-- + dAtA[i] = 0x1a + } + } + if len(m.Changes) > 0 { + for iNdEx := len(m.Changes) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Changes[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- dAtA[i] = 0x12 } } @@ -1361,6 +1415,14 @@ func (m *ObjectSyncMessage) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + l = len(m.PeerSignature) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } return n } @@ -1451,6 +1513,12 @@ func (m *ObjectFullSyncRequest) Size() (n int) { n += 1 + l + sovSpacesync(uint64(l)) } } + if len(m.Changes) > 0 { + for _, e := range m.Changes { + l = e.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + } if len(m.SnapshotPath) > 0 { for _, s := range m.SnapshotPath { l = len(s) @@ -2216,6 +2284,70 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { } m.TreeId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", 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.Identity = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field PeerSignature", 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.PeerSignature = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) @@ -2602,6 +2734,40 @@ func (m *ObjectFullSyncRequest) Unmarshal(dAtA []byte) error { m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex])) iNdEx = postIndex case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Changes", 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 + } + m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType) } diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 87d8d445..9627f7a0 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -5,7 +5,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" ) @@ -49,8 +48,6 @@ func (s *syncHandler) HandleHeadUpdate( var ( fullRequest *spacesyncproto.ObjectFullSyncRequest result tree.AddResult - // in case update changes are empty then we want to sync the whole tree - sendChangesOnFullSync = len(update.Changes) == 0 ) res, err := s.treeCache.GetTree(ctx, treeId) @@ -74,9 +71,8 @@ func (s *syncHandler) HandleHeadUpdate( } // if we couldn't add all the changes - shouldFullSync := len(update.Changes) != len(result.Added) - if shouldFullSync { - fullRequest, err = s.prepareFullSyncRequest(objTree, sendChangesOnFullSync) + if len(update.Changes) != len(result.Added) { + fullRequest, err = s.prepareFullSyncRequest(objTree, update) if err != nil { return err } @@ -84,11 +80,6 @@ func (s *syncHandler) HandleHeadUpdate( return nil }() - // if there are no such tree - if err == storage.ErrUnknownTreeId { - fullRequest = &spacesyncproto.ObjectFullSyncRequest{} - } - // if we have incompatible heads, or we haven't seen the tree at all if fullRequest != nil { return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) } @@ -109,21 +100,23 @@ func (s *syncHandler) HandleFullSyncRequest( return } - // TODO: check if sync request contains changes and add them (also do head update in this case) err = func() error { objTree := res.TreeContainer.Tree() objTree.Lock() defer res.Release() defer objTree.Unlock() - fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) + + _, err = objTree.AddRawChanges(ctx, request.Changes...) if err != nil { return err } - return nil + + fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) + return err }() if err != nil { - return err + return } return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId)) } @@ -135,8 +128,6 @@ func (s *syncHandler) HandleFullSyncResponse( header *aclpb.TreeHeader, treeId string) (err error) { - var result tree.AddResult - res, err := s.treeCache.GetTree(ctx, treeId) if err != nil { return @@ -153,27 +144,28 @@ func (s *syncHandler) HandleFullSyncResponse( return nil } - result, err = objTree.AddRawChanges(ctx, response.Changes...) - - if err != nil { - return err - } - return nil + _, err = objTree.AddRawChanges(ctx, response.Changes...) + return err }() - // if error or nothing has changed - if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId { - return err - } - // if we have a new tree - if err == storage.ErrUnknownTreeId { - return s.addTree(ctx, response, header, treeId) - } return } -func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges bool) (*spacesyncproto.ObjectFullSyncRequest, error) { - // TODO: add send own changes logic +func (s *syncHandler) prepareFullSyncRequest( + t tree.ObjectTree, + update *spacesyncproto.ObjectHeadUpdate) (req *spacesyncproto.ObjectFullSyncRequest, err error) { + req = &spacesyncproto.ObjectFullSyncRequest{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + } + if len(update.Changes) != 0 { + var changesAfterSnapshot []*aclpb.RawTreeChangeWithId + changesAfterSnapshot, err = t.ChangesAfterCommonSnapshot(update.SnapshotPath, update.Heads) + if err != nil { + return + } + req.Changes = changesAfterSnapshot + } return &spacesyncproto.ObjectFullSyncRequest{ Heads: t.Heads(), SnapshotPath: t.SnapshotPath(), @@ -182,7 +174,8 @@ func (s *syncHandler) prepareFullSyncRequest(t tree.ObjectTree, sendOwnChanges b func (s *syncHandler) prepareFullSyncResponse( treeId string, - theirPath, theirHeads []string, + theirPath, + theirHeads []string, t tree.ObjectTree) (*spacesyncproto.ObjectFullSyncResponse, error) { ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads) if err != nil { @@ -195,19 +188,3 @@ func (s *syncHandler) prepareFullSyncResponse( SnapshotPath: t.SnapshotPath(), }, nil } - -func (s *syncHandler) addTree( - ctx context.Context, - response *spacesyncproto.ObjectFullSyncResponse, - header *aclpb.TreeHeader, - treeId string) error { - - return s.treeCache.AddTree( - ctx, - storage.TreeStorageCreatePayload{ - TreeId: treeId, - Header: header, - Changes: response.Changes, - Heads: response.Heads, - }) -} From f420ac144cd37464765103f7630e9e0ad701a5bf Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Fri, 16 Sep 2022 11:20:43 +0200 Subject: [PATCH 24/44] Update stream configuration and sync service --- common/commonspace/rpchandler.go | 2 +- common/commonspace/space.go | 17 +----- common/commonspace/syncservice/streampool.go | 9 ++- common/commonspace/syncservice/syncservice.go | 58 ++++++++++++------- common/nodeconf/configuration.go | 16 +++++ 5 files changed, 65 insertions(+), 37 deletions(-) diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index be83b43c..8d8aacac 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -20,5 +20,5 @@ func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncR } func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) (err error) { - return r.s.SyncService().StreamPool().AddAndReadStream(stream) + return r.s.SyncService().StreamPool().AddAndReadStreamSync(stream) } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index bece7ca7..5723201b 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -148,7 +148,8 @@ func (s *space) testFill() { func (s *space) sync(ctx context.Context) error { st := time.Now() - peers, err := s.getPeers(ctx) + // diffing with responsible peers according to configuration + peers, err := s.nconf.ResponsiblePeers(ctx, s.id) if err != nil { return err } @@ -168,6 +169,7 @@ func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { if err != nil { return nil } + s.pingTreesInCache(ctx, newIds) s.pingTreesInCache(ctx, changedIds) @@ -181,19 +183,6 @@ func (s *space) pingTreesInCache(ctx context.Context, trees []string) { } } -func (s *space) getPeers(ctx context.Context) (peers []peer.Peer, err error) { - if s.nconf.IsResponsible(s.id) { - return s.nconf.AllPeers(ctx, s.id) - } else { - var p peer.Peer - p, err = s.nconf.OnePeer(ctx, s.id) - if err != nil { - return nil, err - } - return []peer.Peer{p}, nil - } -} - func (s *space) Close() error { s.periodicSync.Close() return s.syncService.Close() diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 0ccd2d6b..cbfb7424 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -17,7 +17,8 @@ const maxSimultaneousOperationsPerStream = 10 // StreamPool can be made generic to work with different streams type StreamPool interface { - AddAndReadStream(stream spacesyncproto.SpaceStream) (err error) + AddAndReadStreamSync(stream spacesyncproto.SpaceStream) (err error) + AddAndReadStreamAsync(stream spacesyncproto.SpaceStream) HasStream(peerId string) bool SyncClient Close() (err error) @@ -151,7 +152,11 @@ func (s *streamPool) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) ( return nil } -func (s *streamPool) AddAndReadStream(stream spacesyncproto.SpaceStream) (err error) { +func (s *streamPool) AddAndReadStreamAsync(stream spacesyncproto.SpaceStream) { + go s.AddAndReadStreamSync(stream) +} + +func (s *streamPool) AddAndReadStreamSync(stream spacesyncproto.SpaceStream) (err error) { s.Lock() peerId, err := GetPeerIdFromStreamContext(stream.Context()) if err != nil { diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index c3f85101..2c155fea 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -6,6 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "time" ) type SyncService interface { @@ -14,39 +15,56 @@ type SyncService interface { Close() (err error) } +const respPeersStreamCheckInterval = time.Second * 10 + type syncService struct { - syncHandler SyncHandler - streamPool StreamPool - configuration nodeconf.Configuration - spaceId string + syncHandler SyncHandler + streamPool StreamPool + configuration nodeconf.Configuration + spaceId string + streamLoopCtx context.Context + stopStreamLoop context.CancelFunc +} + +func (s *syncService) Run() { + s.streamLoopCtx, s.stopStreamLoop = context.WithCancel(context.Background()) + s.streamCheckLoop(s.streamLoopCtx) } func (s *syncService) Close() (err error) { + s.stopStreamLoop() return s.streamPool.Close() } func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { - msg := spacesyncproto.WrapHeadUpdate(update, header, treeId) - peers, err := s.configuration.AllPeers(context.Background(), s.spaceId) - if err != nil { - return - } - for _, peer := range peers { - if s.streamPool.HasStream(peer.Id()) { - continue - } - cl := spacesyncproto.NewDRPCSpaceClient(peer) - stream, err := cl.Stream(ctx) - if err != nil { - continue - } + return s.streamPool.BroadcastAsync(spacesyncproto.WrapHeadUpdate(update, header, treeId)) +} - err = s.streamPool.AddAndReadStream(stream) +func (s *syncService) streamCheckLoop(ctx context.Context) { + for { + respPeers, err := s.configuration.ResponsiblePeers(ctx, s.spaceId) if err != nil { continue } + for _, peer := range respPeers { + if s.streamPool.HasStream(peer.Id()) { + continue + } + cl := spacesyncproto.NewDRPCSpaceClient(peer) + stream, err := cl.Stream(ctx) + if err != nil { + continue + } + + s.streamPool.AddAndReadStreamAsync(stream) + } + select { + case <-time.After(respPeersStreamCheckInterval): + break + case <-ctx.Done(): + return + } } - return s.streamPool.BroadcastAsync(msg) } func (s *syncService) StreamPool() StreamPool { diff --git a/common/nodeconf/configuration.go b/common/nodeconf/configuration.go index 5c055bbb..597d1018 100644 --- a/common/nodeconf/configuration.go +++ b/common/nodeconf/configuration.go @@ -19,6 +19,8 @@ type Configuration interface { AllPeers(ctx context.Context, spaceId string) (peers []peer.Peer, err error) // OnePeer returns one of peer for spaceId OnePeer(ctx context.Context, spaceId string) (p peer.Peer, err error) + // ResponsiblePeers returns peers for the space id that are responsible for the space + ResponsiblePeers(ctx context.Context, spaceId string) (peers []peer.Peer, err error) // NodeIds returns list of peerId for given spaceId NodeIds(spaceId string) []string // IsResponsible checks if current account responsible for given spaceId @@ -51,6 +53,20 @@ func (c *configuration) AllPeers(ctx context.Context, spaceId string) (peers []p return } +func (c *configuration) ResponsiblePeers(ctx context.Context, spaceId string) (peers []peer.Peer, err error) { + if c.IsResponsible(spaceId) { + return c.AllPeers(ctx, spaceId) + } else { + var one peer.Peer + one, err = c.OnePeer(ctx, spaceId) + if err != nil { + return + } + peers = []peer.Peer{one} + return + } +} + func (c *configuration) OnePeer(ctx context.Context, spaceId string) (p peer.Peer, err error) { nodeIds := c.NodeIds(spaceId) return c.pool.GetOneOf(ctx, nodeIds) From 70dabf70dddf39112c9ff145c0c07286075b9f7c Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sat, 17 Sep 2022 20:54:23 +0200 Subject: [PATCH 25/44] Move diff logic to separate service, simplify send sync --- common/commonspace/diffservice/diffservice.go | 155 +++++++ .../{ => diffservice}/periodicsync.go | 2 +- common/commonspace/remotediff/remotediff.go | 2 +- .../commonspace/remotediff/remotediff_test.go | 2 +- common/commonspace/rpchandler.go | 3 +- common/commonspace/service.go | 7 +- common/commonspace/space.go | 138 ++---- .../spacesyncproto/protos/spacesync.proto | 12 +- .../commonspace/spacesyncproto/spacesync.go | 16 +- .../spacesyncproto/spacesync.pb.go | 421 +++++++++++++----- common/commonspace/syncservice/streampool.go | 68 ++- common/commonspace/syncservice/synchandler.go | 57 +-- common/commonspace/syncservice/syncservice.go | 86 ++-- 13 files changed, 652 insertions(+), 317 deletions(-) create mode 100644 common/commonspace/diffservice/diffservice.go rename common/commonspace/{ => diffservice}/periodicsync.go (98%) diff --git a/common/commonspace/diffservice/diffservice.go b/common/commonspace/diffservice/diffservice.go new file mode 100644 index 00000000..b530d05f --- /dev/null +++ b/common/commonspace/diffservice/diffservice.go @@ -0,0 +1,155 @@ +package diffservice + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" + "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/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" + treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" + "go.uber.org/zap" + "strings" + "time" +) + +type DiffService interface { + HandleRangeRequest(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) + UpdateHeads(id string, heads []string) + RemoveObject(id string) + + Init(objectIds []string) + Close() (err error) +} + +type diffService struct { + spaceId string + periodicSync *periodicSync + storage storage.Storage + nconf nodeconf.Configuration + diff ldiff.Diff + cache cache.TreeCache + log *zap.Logger + + syncPeriod int +} + +func NewDiffService( + spaceId string, + syncPeriod int, + storage storage.Storage, + nconf nodeconf.Configuration, + cache cache.TreeCache, + log *zap.Logger) DiffService { + return &diffService{ + spaceId: spaceId, + storage: storage, + nconf: nconf, + cache: cache, + log: log, + syncPeriod: syncPeriod, + } +} + +func (d *diffService) Init(objectIds []string) { + d.periodicSync = newPeriodicSync(d.syncPeriod, d.sync, d.log.With(zap.String("spaceId", d.spaceId))) + d.diff = ldiff.New(16, 16) + d.fillDiff(objectIds) +} + +func (d *diffService) HandleRangeRequest(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) { + return remotediff.HandleRangeRequest(ctx, d.diff, req) +} + +func (d *diffService) UpdateHeads(id string, heads []string) { + d.diff.Set(ldiff.Element{ + Id: id, + Head: concatStrings(heads), + }) +} + +func (d *diffService) RemoveObject(id string) { + // TODO: add space document to remove ids + d.diff.RemoveId(id) +} + +func (d *diffService) Close() (err error) { + d.periodicSync.Close() + return nil +} + +func (d *diffService) sync(ctx context.Context) error { + st := time.Now() + // diffing with responsible peers according to configuration + peers, err := d.nconf.ResponsiblePeers(ctx, d.spaceId) + if err != nil { + return err + } + for _, p := range peers { + if err := d.syncWithPeer(ctx, p); err != nil { + d.log.Error("can't sync with peer", zap.String("peer", p.Id()), zap.Error(err)) + } + } + d.log.Info("synced", zap.String("spaceId", d.spaceId), zap.Duration("dur", time.Since(st))) + return nil +} + +func (d *diffService) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { + cl := spacesyncproto.NewDRPCSpaceClient(p) + rdiff := remotediff.NewRemoteDiff(d.spaceId, cl) + newIds, changedIds, removedIds, err := d.diff.Diff(ctx, rdiff) + if err != nil { + return nil + } + + d.pingTreesInCache(ctx, newIds) + d.pingTreesInCache(ctx, changedIds) + + d.log.Info("sync done:", zap.Int("newIds", len(newIds)), + zap.Int("changedIds", len(changedIds)), + zap.Int("removedIds", len(removedIds))) + return +} + +func (d *diffService) pingTreesInCache(ctx context.Context, trees []string) { + for _, tId := range trees { + _, _ = d.cache.GetTree(ctx, tId) + } +} + +func (d *diffService) fillDiff(objectIds []string) { + var els = make([]ldiff.Element, 0, len(objectIds)) + for _, id := range objectIds { + st, err := d.storage.Storage(id) + if err != nil { + continue + } + heads, err := st.(treestorage.TreeStorage).Heads() + if err != nil { + continue + } + els = append(els, ldiff.Element{ + Id: id, + Head: concatStrings(heads), + }) + } + d.diff.Set(els...) +} + +func concatStrings(strs []string) string { + var ( + b strings.Builder + totalLen int + ) + for _, s := range strs { + totalLen += len(s) + } + + b.Grow(totalLen) + for _, s := range strs { + b.WriteString(s) + } + return b.String() +} diff --git a/common/commonspace/periodicsync.go b/common/commonspace/diffservice/periodicsync.go similarity index 98% rename from common/commonspace/periodicsync.go rename to common/commonspace/diffservice/periodicsync.go index 219f953e..59616eab 100644 --- a/common/commonspace/periodicsync.go +++ b/common/commonspace/diffservice/periodicsync.go @@ -1,4 +1,4 @@ -package commonspace +package diffservice import ( "context" diff --git a/common/commonspace/remotediff/remotediff.go b/common/commonspace/remotediff/remotediff.go index 1a01814c..8121b1c1 100644 --- a/common/commonspace/remotediff/remotediff.go +++ b/common/commonspace/remotediff/remotediff.go @@ -60,7 +60,7 @@ func (r remote) Ranges(ctx context.Context, ranges []ldiff.Range, resBuf []ldiff return } -func HandlerRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) { +func HandleRangeRequest(ctx context.Context, d ldiff.Diff, req *spacesyncproto.HeadSyncRequest) (resp *spacesyncproto.HeadSyncResponse, err error) { ranges := make([]ldiff.Range, 0, len(req.Ranges)) for _, reqRange := range req.Ranges { ranges = append(ranges, ldiff.Range{ diff --git a/common/commonspace/remotediff/remotediff_test.go b/common/commonspace/remotediff/remotediff_test.go index d209b753..f6b3e7e5 100644 --- a/common/commonspace/remotediff/remotediff_test.go +++ b/common/commonspace/remotediff/remotediff_test.go @@ -37,5 +37,5 @@ type mockClient struct { } func (m *mockClient) HeadSync(ctx context.Context, in *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { - return HandlerRangeRequest(ctx, m.l, in) + return HandleRangeRequest(ctx, m.l, in) } diff --git a/common/commonspace/rpchandler.go b/common/commonspace/rpchandler.go index 8d8aacac..dbc5b7aa 100644 --- a/common/commonspace/rpchandler.go +++ b/common/commonspace/rpchandler.go @@ -2,7 +2,6 @@ package commonspace import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" ) @@ -16,7 +15,7 @@ type rpcHandler struct { } func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { - return remotediff.HandlerRangeRequest(ctx, r.s.diff, req) + return r.s.DiffService().HandleRangeRequest(ctx, req) } func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) (err error) { diff --git a/common/commonspace/service.go b/common/commonspace/service.go index 3c084562..9598d53a 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -5,6 +5,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice" "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/nodeconf" @@ -44,12 +45,14 @@ func (s *service) Name() (name string) { } func (s *service) CreateSpace(ctx context.Context, id string) (Space, error) { - syncService := syncservice.NewSyncService(id, nil, s.configurationService.GetLast()) + lastConfiguration := s.configurationService.GetLast() + diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, s.storage, lastConfiguration, s.cache, log) + syncService := syncservice.NewSyncService(id, diffService, s.cache, lastConfiguration) sp := &space{ id: id, - nconf: s.configurationService.GetLast(), conf: s.config, syncService: syncService, + diffService: diffService, cache: s.cache, storage: s.storage, } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 5723201b..91657bb7 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -2,24 +2,17 @@ package commonspace import ( "context" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/remotediff" + "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/synctree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/peer" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" - "go.uber.org/zap" - "math/rand" "sync" - "time" ) type Space interface { @@ -27,6 +20,7 @@ type Space interface { SpaceSyncRpc() RpcHandler SyncService() syncservice.SyncService + DiffService() diffservice.DiffService CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) BuildTree(ctx context.Context, id string, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) @@ -35,18 +29,40 @@ type Space interface { } type space struct { - id string - nconf nodeconf.Configuration - conf config.Space - diff ldiff.Diff - mu sync.RWMutex + id string + conf config.Space + mu sync.RWMutex - rpc *rpcHandler - periodicSync *periodicSync - syncService syncservice.SyncService - storage storage.Storage - cache cache.TreeCache - aclList list.ACLList + rpc *rpcHandler + + syncService syncservice.SyncService + diffService diffservice.DiffService + storage storage.Storage + cache cache.TreeCache + aclList list.ACLList +} + +func (s *space) Id() string { + return s.id +} + +func (s *space) Init(ctx context.Context) error { + s.rpc = &rpcHandler{s: s} + s.diffService.Init(s.getObjectIds()) + s.syncService.Init() + return nil +} + +func (s *space) SpaceSyncRpc() RpcHandler { + return s.rpc +} + +func (s *space) SyncService() syncservice.SyncService { + return s.syncService +} + +func (s *space) DiffService() diffservice.DiffService { + return s.diffService } func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { @@ -63,10 +79,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTr return s.syncService.StreamPool().SendSync( peerId, - spacesyncproto.WrapFullRequest(&spacesyncproto.ObjectFullSyncRequest{}, nil, id), - func(syncMessage *spacesyncproto.ObjectSyncMessage) bool { - return syncMessage.TreeId == id && syncMessage.GetContent().GetFullSyncResponse() != nil - }, + spacesyncproto.WrapFullRequest(&spacesyncproto.ObjectFullSyncRequest{}, nil, id, ""), ) } @@ -105,85 +118,12 @@ func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTr return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, s.aclList) } -func (s *space) Id() string { - return s.id -} - -func (s *space) Init(ctx context.Context) error { - s.diff = ldiff.New(16, 16) - s.periodicSync = newPeriodicSync(s.conf.SyncPeriod, s.sync, log.With(zap.String("spaceId", s.id))) - s.rpc = &rpcHandler{s: s} - s.testFill() +func (s *space) getObjectIds() []string { + // TODO: add space object logic return nil } -func (s *space) SpaceSyncRpc() RpcHandler { - return s.rpc -} - -func (s *space) SyncService() syncservice.SyncService { - return s.syncService -} - -func (s *space) testFill() { - var n = 1000 - var els = make([]ldiff.Element, 0, n) - rand.Seed(time.Now().UnixNano()) - for i := 0; i < n; i++ { - if rand.Intn(n) > 2 { - id := fmt.Sprintf("%s.%d", s.id, i) - head := "head." + id - if rand.Intn(n) > n-10 { - head += ".modified" - } - el := ldiff.Element{ - Id: id, - Head: head, - } - els = append(els, el) - } - } - s.diff.Set(els...) -} - -func (s *space) sync(ctx context.Context) error { - st := time.Now() - // diffing with responsible peers according to configuration - peers, err := s.nconf.ResponsiblePeers(ctx, s.id) - if err != nil { - return err - } - for _, p := range peers { - if err := s.syncWithPeer(ctx, p); err != nil { - log.Error("can't sync with peer", zap.String("peer", p.Id()), zap.Error(err)) - } - } - log.Info("synced", zap.String("spaceId", s.id), zap.Duration("dur", time.Since(st))) - return nil -} - -func (s *space) syncWithPeer(ctx context.Context, p peer.Peer) (err error) { - cl := spacesyncproto.NewDRPCSpaceClient(p) - rdiff := remotediff.NewRemoteDiff(s.id, cl) - newIds, changedIds, removedIds, err := s.diff.Diff(ctx, rdiff) - if err != nil { - return nil - } - - s.pingTreesInCache(ctx, newIds) - s.pingTreesInCache(ctx, changedIds) - - log.Info("sync done:", zap.Int("newIds", len(newIds)), zap.Int("changedIds", len(changedIds)), zap.Int("removedIds", len(removedIds))) - return -} - -func (s *space) pingTreesInCache(ctx context.Context, trees []string) { - for _, tId := range trees { - _, _ = s.cache.GetTree(ctx, tId) - } -} - func (s *space) Close() error { - s.periodicSync.Close() + s.diffService.Close() return s.syncService.Close() } diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 7fd7d411..22f7e82d 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -51,9 +51,10 @@ message ObjectSyncMessage { ObjectSyncContentValue content = 2; acl.TreeHeader treeHeader = 3; string treeId = 4; - - string identity = 5; - string peerSignature = 6; + string trackingId = 5; +// +// string identity = 5; +// string peerSignature = 6; } // ObjectSyncContentValue provides different types for object sync @@ -62,6 +63,7 @@ message ObjectSyncContentValue { ObjectHeadUpdate headUpdate = 1; ObjectFullSyncRequest fullSyncRequest = 2; ObjectFullSyncResponse fullSyncResponse = 3; + ObjectErrorResponse errorResponse = 4; } } @@ -85,3 +87,7 @@ message ObjectFullSyncResponse { repeated acl.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } + +message ObjectErrorResponse { + string error = 1; +} diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go index 66de459d..25ec1ba6 100644 --- a/common/commonspace/spacesyncproto/spacesync.go +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -4,7 +4,7 @@ import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclch type SpaceStream = DRPCSpace_StreamStream -func WrapHeadUpdate(update *ObjectHeadUpdate, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { +func WrapHeadUpdate(update *ObjectHeadUpdate, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_HeadUpdate{HeadUpdate: update}, @@ -14,7 +14,7 @@ func WrapHeadUpdate(update *ObjectHeadUpdate, header *aclpb.TreeHeader, treeId s } } -func WrapFullRequest(request *ObjectFullSyncRequest, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { +func WrapFullRequest(request *ObjectFullSyncRequest, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_FullSyncRequest{FullSyncRequest: request}, @@ -24,7 +24,7 @@ func WrapFullRequest(request *ObjectFullSyncRequest, header *aclpb.TreeHeader, t } } -func WrapFullResponse(response *ObjectFullSyncResponse, header *aclpb.TreeHeader, treeId string) *ObjectSyncMessage { +func WrapFullResponse(response *ObjectFullSyncResponse, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_FullSyncResponse{FullSyncResponse: response}, @@ -33,3 +33,13 @@ func WrapFullResponse(response *ObjectFullSyncResponse, header *aclpb.TreeHeader TreeId: treeId, } } + +func WrapError(err error, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { + return &ObjectSyncMessage{ + Content: &ObjectSyncContentValue{ + Value: &ObjectSyncContentValue_ErrorResponse{ErrorResponse: &ObjectErrorResponse{Error: err.Error()}}, + }, + TreeHeader: header, + TreeId: treeId, + } +} diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 64419bb0..04b77518 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -320,12 +320,11 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` - Identity string `protobuf:"bytes,5,opt,name=identity,proto3" json:"identity,omitempty"` - PeerSignature string `protobuf:"bytes,6,opt,name=peerSignature,proto3" json:"peerSignature,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -389,16 +388,9 @@ func (m *ObjectSyncMessage) GetTreeId() string { return "" } -func (m *ObjectSyncMessage) GetIdentity() string { +func (m *ObjectSyncMessage) GetTrackingId() string { if m != nil { - return m.Identity - } - return "" -} - -func (m *ObjectSyncMessage) GetPeerSignature() string { - if m != nil { - return m.PeerSignature + return m.TrackingId } return "" } @@ -409,6 +401,7 @@ type ObjectSyncContentValue struct { // *ObjectSyncContentValue_HeadUpdate // *ObjectSyncContentValue_FullSyncRequest // *ObjectSyncContentValue_FullSyncResponse + // *ObjectSyncContentValue_ErrorResponse Value isObjectSyncContentValue_Value `protobuf_oneof:"value"` } @@ -460,10 +453,14 @@ type ObjectSyncContentValue_FullSyncRequest struct { type ObjectSyncContentValue_FullSyncResponse struct { FullSyncResponse *ObjectFullSyncResponse `protobuf:"bytes,3,opt,name=fullSyncResponse,proto3,oneof" json:"fullSyncResponse,omitempty"` } +type ObjectSyncContentValue_ErrorResponse struct { + ErrorResponse *ObjectErrorResponse `protobuf:"bytes,4,opt,name=errorResponse,proto3,oneof" json:"errorResponse,omitempty"` +} func (*ObjectSyncContentValue_HeadUpdate) isObjectSyncContentValue_Value() {} func (*ObjectSyncContentValue_FullSyncRequest) isObjectSyncContentValue_Value() {} func (*ObjectSyncContentValue_FullSyncResponse) isObjectSyncContentValue_Value() {} +func (*ObjectSyncContentValue_ErrorResponse) isObjectSyncContentValue_Value() {} func (m *ObjectSyncContentValue) GetValue() isObjectSyncContentValue_Value { if m != nil { @@ -493,12 +490,20 @@ func (m *ObjectSyncContentValue) GetFullSyncResponse() *ObjectFullSyncResponse { return nil } +func (m *ObjectSyncContentValue) GetErrorResponse() *ObjectErrorResponse { + if x, ok := m.GetValue().(*ObjectSyncContentValue_ErrorResponse); ok { + return x.ErrorResponse + } + return nil +} + // XXX_OneofWrappers is for the internal use of the proto package. func (*ObjectSyncContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ (*ObjectSyncContentValue_HeadUpdate)(nil), (*ObjectSyncContentValue_FullSyncRequest)(nil), (*ObjectSyncContentValue_FullSyncResponse)(nil), + (*ObjectSyncContentValue_ErrorResponse)(nil), } } @@ -685,6 +690,50 @@ func (m *ObjectFullSyncResponse) GetSnapshotPath() []string { return nil } +type ObjectErrorResponse struct { + Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` +} + +func (m *ObjectErrorResponse) Reset() { *m = ObjectErrorResponse{} } +func (m *ObjectErrorResponse) String() string { return proto.CompactTextString(m) } +func (*ObjectErrorResponse) ProtoMessage() {} +func (*ObjectErrorResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{10} +} +func (m *ObjectErrorResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ObjectErrorResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ObjectErrorResponse.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 *ObjectErrorResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_ObjectErrorResponse.Merge(m, src) +} +func (m *ObjectErrorResponse) XXX_Size() int { + return m.Size() +} +func (m *ObjectErrorResponse) XXX_DiscardUnknown() { + xxx_messageInfo_ObjectErrorResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_ObjectErrorResponse proto.InternalMessageInfo + +func (m *ObjectErrorResponse) GetError() string { + if m != nil { + return m.Error + } + return "" +} + func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") @@ -697,6 +746,7 @@ func init() { proto.RegisterType((*ObjectHeadUpdate)(nil), "anySpace.ObjectHeadUpdate") proto.RegisterType((*ObjectFullSyncRequest)(nil), "anySpace.ObjectFullSyncRequest") proto.RegisterType((*ObjectFullSyncResponse)(nil), "anySpace.ObjectFullSyncResponse") + proto.RegisterType((*ObjectErrorResponse)(nil), "anySpace.ObjectErrorResponse") } func init() { @@ -704,51 +754,52 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 695 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0xcb, 0x6f, 0xd3, 0x4e, - 0x10, 0x8e, 0xd3, 0xe6, 0xd1, 0x49, 0x1f, 0xf9, 0xad, 0x7e, 0x2d, 0x26, 0x48, 0x69, 0xb0, 0x38, - 0x44, 0x1c, 0x92, 0x2a, 0x5c, 0x10, 0xe5, 0x42, 0xab, 0x56, 0x89, 0x10, 0x0f, 0x6d, 0x28, 0x48, - 0x88, 0xcb, 0xd6, 0x9e, 0x26, 0x06, 0xc7, 0x36, 0xde, 0x0d, 0x25, 0x37, 0x2e, 0x70, 0x46, 0xfc, - 0x55, 0x1c, 0x7b, 0xe4, 0x88, 0xda, 0x7f, 0x81, 0x23, 0x07, 0xb4, 0x63, 0x3b, 0x2f, 0xd2, 0x72, - 0xeb, 0x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xd7, 0x21, 0x3d, 0x28, 0x1c, 0xca, 0x64, 0x85, 0xd3, 0xda, 0x7a, - 0x03, 0x1b, 0x13, 0xf2, 0xfb, 0x21, 0x4a, 0xc5, 0x4c, 0x28, 0x50, 0x89, 0x3b, 0x29, 0x37, 0x35, - 0x59, 0x13, 0xf2, 0x11, 0x55, 0x2f, 0x91, 0x7e, 0x63, 0x81, 0x74, 0xbd, 0xcf, 0x13, 0x98, 0x75, - 0x08, 0xe5, 0x29, 0x69, 0x61, 0xe0, 0x4b, 0x64, 0x2d, 0x28, 0x44, 0x24, 0x53, 0x9a, 0x06, 0x45, - 0x31, 0x2f, 0x2b, 0x00, 0x4f, 0x81, 0xd6, 0x2f, 0x03, 0xfe, 0x7b, 0x76, 0xfc, 0x16, 0x6d, 0xa5, - 0x77, 0x9f, 0xa0, 0x94, 0xa2, 0x87, 0x57, 0x08, 0x7d, 0x00, 0x05, 0x3b, 0xf0, 0x15, 0xfa, 0x8a, - 0x92, 0x2d, 0xb5, 0x6a, 0x93, 0x33, 0x26, 0x71, 0xf6, 0x63, 0xc8, 0x4b, 0xe1, 0x0d, 0x91, 0xa7, - 0x04, 0xd6, 0x04, 0x50, 0x11, 0xa2, 0x96, 0x82, 0x11, 0x55, 0xba, 0xd4, 0xda, 0x68, 0x08, 0xdb, - 0x6b, 0xbc, 0x18, 0xbb, 0xf9, 0x14, 0x84, 0x6d, 0x41, 0x5e, 0x5b, 0x1d, 0xc7, 0x5c, 0x26, 0x15, - 0x89, 0xc5, 0x2a, 0x50, 0x74, 0x1d, 0xf4, 0x95, 0xab, 0x46, 0x66, 0x8e, 0x76, 0xc6, 0x36, 0xbb, - 0x03, 0x6b, 0x21, 0x62, 0xd4, 0x75, 0x7b, 0xbe, 0x50, 0xc3, 0x08, 0xcd, 0x3c, 0x01, 0x66, 0x9d, - 0xd6, 0x6f, 0x03, 0xb6, 0x16, 0xcb, 0x65, 0x0f, 0x01, 0x74, 0xff, 0x8e, 0x42, 0x47, 0x28, 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 0x22, 0x14, 0x03, 0x76, 0x6b, 0xd1, 0xec, 0x26, 0xff, 0x01, - 0x95, 0xab, 0x36, 0xeb, 0xc6, 0x8e, 0xb1, 0xb7, 0xfb, 0xfd, 0xbc, 0x6a, 0x9c, 0x9d, 0x57, 0x8d, - 0x9f, 0xe7, 0x55, 0xe3, 0xeb, 0x45, 0x35, 0x73, 0x76, 0x51, 0xcd, 0xfc, 0xb8, 0xa8, 0x66, 0x5e, - 0xdf, 0xfe, 0xe7, 0x17, 0xe7, 0x38, 0x4f, 0xaf, 0x7b, 0x7f, 0x02, 0x00, 0x00, 0xff, 0xff, 0x57, - 0xb9, 0x93, 0x47, 0x9d, 0x06, 0x00, 0x00, + // 712 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4b, 0x6f, 0xd3, 0x40, + 0x10, 0xf6, 0xa6, 0x79, 0x75, 0xd2, 0x47, 0x58, 0x68, 0x31, 0x41, 0xa4, 0xc1, 0xa7, 0x08, 0xa4, + 0xa4, 0x0a, 0x17, 0x44, 0xb9, 0xd0, 0x2a, 0x55, 0x22, 0xc4, 0x43, 0x5b, 0x0a, 0x12, 0xe2, 0xb2, + 0xb5, 0xb7, 0x49, 0xa8, 0x63, 0x1b, 0xef, 0x86, 0xd2, 0x1b, 0x17, 0x38, 0x23, 0xfe, 0x12, 0x17, + 0x8e, 0x15, 0x27, 0x8e, 0xa8, 0xfd, 0x23, 0x68, 0xc7, 0x76, 0x5e, 0xb8, 0xe5, 0xd6, 0x43, 0xec, + 0x9d, 0xd9, 0xf9, 0xbe, 0xfd, 0xf6, 0x9b, 0xf5, 0x06, 0x1e, 0xda, 0xfe, 0x70, 0xe8, 0x7b, 0xcd, + 0xe8, 0x25, 0x03, 0x6e, 0x8b, 0x26, 0x3e, 0xe5, 0x89, 0x67, 0x07, 0xa1, 0xaf, 0xfc, 0x26, 0x3e, + 0xe5, 0x24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0x4d, 0xd6, 0xc9, 0x26, 0xd9, 0xde, 0xfa, 0x79, 0x56, 0x25, 0xa7, 0x67, + 0x55, 0xf2, 0xe7, 0xac, 0x4a, 0xbe, 0x9d, 0x57, 0x8d, 0xd3, 0xf3, 0xaa, 0xf1, 0xfb, 0xbc, 0x6a, + 0xbc, 0xbd, 0xfb, 0xdf, 0xff, 0xb0, 0x83, 0x3c, 0xbe, 0x1e, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, + 0x93, 0x27, 0x56, 0x41, 0xef, 0x06, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -976,17 +1027,10 @@ func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.PeerSignature) > 0 { - i -= len(m.PeerSignature) - copy(dAtA[i:], m.PeerSignature) - i = encodeVarintSpacesync(dAtA, i, uint64(len(m.PeerSignature))) - i-- - dAtA[i] = 0x32 - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity))) + if len(m.TrackingId) > 0 { + i -= len(m.TrackingId) + copy(dAtA[i:], m.TrackingId) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.TrackingId))) i-- dAtA[i] = 0x2a } @@ -1126,6 +1170,27 @@ func (m *ObjectSyncContentValue_FullSyncResponse) MarshalToSizedBuffer(dAtA []by } return len(dAtA) - i, nil } +func (m *ObjectSyncContentValue_ErrorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectSyncContentValue_ErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.ErrorResponse != nil { + { + size, err := m.ErrorResponse.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x22 + } + return len(dAtA) - i, nil +} func (m *ObjectHeadUpdate) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1291,6 +1356,36 @@ func (m *ObjectFullSyncResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) return len(dAtA) - i, nil } +func (m *ObjectErrorResponse) 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 *ObjectErrorResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ObjectErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Error) > 0 { + i -= len(m.Error) + copy(dAtA[i:], m.Error) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Error))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -1415,11 +1510,7 @@ func (m *ObjectSyncMessage) Size() (n int) { if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovSpacesync(uint64(l)) - } - l = len(m.PeerSignature) + l = len(m.TrackingId) if l > 0 { n += 1 + l + sovSpacesync(uint64(l)) } @@ -1474,6 +1565,18 @@ func (m *ObjectSyncContentValue_FullSyncResponse) Size() (n int) { } return n } +func (m *ObjectSyncContentValue_ErrorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.ErrorResponse != nil { + l = m.ErrorResponse.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} func (m *ObjectHeadUpdate) Size() (n int) { if m == nil { return 0 @@ -1555,6 +1658,19 @@ func (m *ObjectFullSyncResponse) Size() (n int) { return n } +func (m *ObjectErrorResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Error) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2286,7 +2402,7 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 5: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field TrackingId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { @@ -2314,39 +2430,7 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Identity = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field PeerSignature", 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.PeerSignature = string(dAtA[iNdEx:postIndex]) + m.TrackingId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex default: iNdEx = preIndex @@ -2503,6 +2587,41 @@ func (m *ObjectSyncContentValue) Unmarshal(dAtA []byte) error { } m.Value = &ObjectSyncContentValue_FullSyncResponse{v} iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ErrorResponse", 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 + } + v := &ObjectErrorResponse{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ObjectSyncContentValue_ErrorResponse{v} + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipSpacesync(dAtA[iNdEx:]) @@ -2968,6 +3087,88 @@ func (m *ObjectFullSyncResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *ObjectErrorResponse) 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: ObjectErrorResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ObjectErrorResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Error", 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.Error = 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) { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index cbfb7424..65197270 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -8,6 +8,7 @@ import ( "github.com/libp2p/go-libp2p-core/sec" "storj.io/drpc/drpcctx" "sync" + "sync/atomic" ) var ErrEmptyPeer = errors.New("don't have such a peer") @@ -17,17 +18,15 @@ const maxSimultaneousOperationsPerStream = 10 // StreamPool can be made generic to work with different streams type StreamPool interface { + SyncClient AddAndReadStreamSync(stream spacesyncproto.SpaceStream) (err error) AddAndReadStreamAsync(stream spacesyncproto.SpaceStream) HasStream(peerId string) bool - SyncClient Close() (err error) } type SyncClient interface { - SendSync(peerId string, - message *spacesyncproto.ObjectSyncMessage, - msgCheck func(syncMessage *spacesyncproto.ObjectSyncMessage) bool) (reply *spacesyncproto.ObjectSyncMessage, err error) + SendSync(peerId string, message *spacesyncproto.ObjectSyncMessage) (reply *spacesyncproto.ObjectSyncMessage, err error) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) BroadcastAsync(message *spacesyncproto.ObjectSyncMessage) (err error) } @@ -35,8 +34,7 @@ type SyncClient interface { type MessageHandler func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) type responseWaiter struct { - ch chan *spacesyncproto.ObjectSyncMessage - msgCheck func(message *spacesyncproto.ObjectSyncMessage) bool + ch chan *spacesyncproto.ObjectSyncMessage } type streamPool struct { @@ -46,6 +44,7 @@ type streamPool struct { wg *sync.WaitGroup waiters map[string]responseWaiter waitersMx sync.Mutex + counter uint64 } func newStreamPool(messageHandler MessageHandler) StreamPool { @@ -63,36 +62,23 @@ func (s *streamPool) HasStream(peerId string) (res bool) { func (s *streamPool) SendSync( peerId string, - message *spacesyncproto.ObjectSyncMessage, - msgCheck func(syncMessage *spacesyncproto.ObjectSyncMessage) bool) (reply *spacesyncproto.ObjectSyncMessage, err error) { + msg *spacesyncproto.ObjectSyncMessage) (reply *spacesyncproto.ObjectSyncMessage, err error) { + newCounter := atomic.AddUint64(&s.counter, 1) + msg.TrackingId = genStreamPoolKey(peerId, msg.TreeId, newCounter) - sendAndWait := func(waiter responseWaiter) (err error) { - err = s.SendAsync(peerId, message) - if err != nil { - return - } - - reply = <-waiter.ch - return - } - - key := fmt.Sprintf("%s.%s", peerId, message.TreeId) s.waitersMx.Lock() - waiter, exists := s.waiters[key] - if exists { - s.waitersMx.Unlock() + waiter := responseWaiter{ + ch: make(chan *spacesyncproto.ObjectSyncMessage), + } + s.waiters[msg.TrackingId] = waiter + s.waitersMx.Unlock() - err = sendAndWait(waiter) + err = s.SendAsync(peerId, msg) + if err != nil { return } - waiter = responseWaiter{ - ch: make(chan *spacesyncproto.ObjectSyncMessage), - msgCheck: msgCheck, - } - s.waiters[key] = waiter - s.waitersMx.Unlock() - err = sendAndWait(waiter) + reply = <-waiter.ch return } @@ -189,17 +175,21 @@ func (s *streamPool) readPeerLoop(peerId string, stream spacesyncproto.SpaceStre } process := func(msg *spacesyncproto.ObjectSyncMessage) { - key := fmt.Sprintf("%s.%s", peerId, msg.TreeId) - s.waitersMx.Lock() - waiter, exists := s.waiters[key] + if msg.TrackingId == "" { + s.messageHandler(stream.Context(), peerId, msg) + return + } - if !exists || !waiter.msgCheck(msg) { + s.waitersMx.Lock() + waiter, exists := s.waiters[msg.TrackingId] + + if !exists { s.waitersMx.Unlock() s.messageHandler(stream.Context(), peerId, msg) return } - delete(s.waiters, key) + delete(s.waiters, msg.TrackingId) s.waitersMx.Unlock() waiter.ch <- msg } @@ -216,10 +206,8 @@ Loop: break Loop } go func() { - defer func() { - limiter <- struct{}{} - }() process(msg) + limiter <- struct{}{} }() } return s.removePeer(peerId) @@ -244,3 +232,7 @@ func GetPeerIdFromStreamContext(ctx context.Context) (string, error) { return conn.RemotePeer().String(), nil } + +func genStreamPoolKey(peerId, treeId string, counter uint64) string { + return fmt.Sprintf("%s.%s.%d", peerId, treeId, counter) +} diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 9627f7a0..12798bc3 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -25,15 +25,15 @@ func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandl } } -func (s *syncHandler) HandleMessage(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) error { - msg := message.GetContent() +func (s *syncHandler) HandleMessage(ctx context.Context, senderId string, msg *spacesyncproto.ObjectSyncMessage) error { + content := msg.GetContent() switch { - case msg.GetFullSyncRequest() != nil: - return s.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), message.GetTreeHeader(), message.GetTreeId()) - case msg.GetFullSyncResponse() != nil: - return s.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), message.GetTreeHeader(), message.GetTreeId()) - case msg.GetHeadUpdate() != nil: - return s.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), message.GetTreeHeader(), message.GetTreeId()) + case content.GetFullSyncRequest() != nil: + return s.HandleFullSyncRequest(ctx, senderId, content.GetFullSyncRequest(), msg) + case content.GetFullSyncResponse() != nil: + return s.HandleFullSyncResponse(ctx, senderId, content.GetFullSyncResponse(), msg) + case content.GetHeadUpdate() != nil: + return s.HandleHeadUpdate(ctx, senderId, content.GetHeadUpdate(), msg) } return nil } @@ -42,15 +42,13 @@ func (s *syncHandler) HandleHeadUpdate( ctx context.Context, senderId string, update *spacesyncproto.ObjectHeadUpdate, - header *aclpb.TreeHeader, - treeId string) (err error) { + msg *spacesyncproto.ObjectSyncMessage) (err error) { var ( fullRequest *spacesyncproto.ObjectFullSyncRequest result tree.AddResult ) - - res, err := s.treeCache.GetTree(ctx, treeId) + res, err := s.treeCache.GetTree(ctx, msg.TreeId) if err != nil { return } @@ -81,7 +79,8 @@ func (s *syncHandler) HandleHeadUpdate( }() if fullRequest != nil { - return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullRequest(fullRequest, header, treeId)) + return s.syncClient.SendAsync(senderId, + spacesyncproto.WrapFullRequest(fullRequest, msg.TreeHeader, msg.TreeId, msg.TrackingId)) } return } @@ -90,12 +89,18 @@ func (s *syncHandler) HandleFullSyncRequest( ctx context.Context, senderId string, request *spacesyncproto.ObjectFullSyncRequest, - header *aclpb.TreeHeader, - treeId string) (err error) { + msg *spacesyncproto.ObjectSyncMessage) (err error) { + var ( + fullResponse *spacesyncproto.ObjectFullSyncResponse + header = msg.TreeHeader + ) + defer func() { + if err != nil { + s.syncClient.SendAsync(senderId, spacesyncproto.WrapError(err, header, msg.TreeId, msg.TrackingId)) + } + }() - var fullResponse *spacesyncproto.ObjectFullSyncResponse - - res, err := s.treeCache.GetTree(ctx, treeId) + res, err := s.treeCache.GetTree(ctx, msg.TreeId) if err != nil { return } @@ -106,29 +111,32 @@ func (s *syncHandler) HandleFullSyncRequest( defer res.Release() defer objTree.Unlock() + if header == nil { + header = objTree.Header() + } + _, err = objTree.AddRawChanges(ctx, request.Changes...) if err != nil { return err } - fullResponse, err = s.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) + fullResponse, err = s.prepareFullSyncResponse(request.SnapshotPath, request.Heads, objTree) return err }() if err != nil { return } - return s.syncClient.SendAsync(senderId, spacesyncproto.WrapFullResponse(fullResponse, header, treeId)) + return s.syncClient.SendAsync(senderId, + spacesyncproto.WrapFullResponse(fullResponse, header, msg.TreeId, msg.TrackingId)) } func (s *syncHandler) HandleFullSyncResponse( ctx context.Context, senderId string, response *spacesyncproto.ObjectFullSyncResponse, - header *aclpb.TreeHeader, - treeId string) (err error) { - - res, err := s.treeCache.GetTree(ctx, treeId) + msg *spacesyncproto.ObjectSyncMessage) (err error) { + res, err := s.treeCache.GetTree(ctx, msg.TreeId) if err != nil { return } @@ -173,7 +181,6 @@ func (s *syncHandler) prepareFullSyncRequest( } func (s *syncHandler) prepareFullSyncResponse( - treeId string, theirPath, theirHeads []string, t tree.ObjectTree) (*spacesyncproto.ObjectFullSyncResponse, error) { diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 2c155fea..736d40b7 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -12,39 +12,77 @@ import ( type SyncService interface { NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) StreamPool() StreamPool + + Init() Close() (err error) } +type HeadNotifiable interface { + UpdateHeads(id string, heads []string) +} + const respPeersStreamCheckInterval = time.Second * 10 type syncService struct { + spaceId string + syncHandler SyncHandler streamPool StreamPool + headNotifiable HeadNotifiable configuration nodeconf.Configuration - spaceId string + streamLoopCtx context.Context stopStreamLoop context.CancelFunc + streamLoopDone chan struct{} } -func (s *syncService) Run() { +func NewSyncService(spaceId string, headNotifiable HeadNotifiable, cache cache.TreeCache, configuration nodeconf.Configuration) SyncService { + var syncHandler SyncHandler + streamPool := newStreamPool(func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) { + return syncHandler.HandleMessage(ctx, senderId, message) + }) + syncHandler = newSyncHandler(cache, streamPool) + return newSyncService(spaceId, headNotifiable, syncHandler, streamPool, configuration) +} + +func newSyncService( + spaceId string, + headNotifiable HeadNotifiable, + syncHandler SyncHandler, + streamPool StreamPool, + configuration nodeconf.Configuration) *syncService { + return &syncService{ + syncHandler: syncHandler, + streamPool: streamPool, + headNotifiable: headNotifiable, + configuration: configuration, + spaceId: spaceId, + streamLoopDone: make(chan struct{}), + } +} + +func (s *syncService) Init() { s.streamLoopCtx, s.stopStreamLoop = context.WithCancel(context.Background()) - s.streamCheckLoop(s.streamLoopCtx) + go s.responsibleStreamCheckLoop(s.streamLoopCtx) } func (s *syncService) Close() (err error) { s.stopStreamLoop() + <-s.streamLoopDone return s.streamPool.Close() } func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { - return s.streamPool.BroadcastAsync(spacesyncproto.WrapHeadUpdate(update, header, treeId)) + s.headNotifiable.UpdateHeads(treeId, update.Heads) + return s.streamPool.BroadcastAsync(spacesyncproto.WrapHeadUpdate(update, header, treeId, "")) } -func (s *syncService) streamCheckLoop(ctx context.Context) { - for { +func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) { + defer close(s.streamLoopDone) + checkResponsiblePeers := func() { respPeers, err := s.configuration.ResponsiblePeers(ctx, s.spaceId) if err != nil { - continue + return } for _, peer := range respPeers { if s.streamPool.HasStream(peer.Id()) { @@ -58,11 +96,17 @@ func (s *syncService) streamCheckLoop(ctx context.Context) { s.streamPool.AddAndReadStreamAsync(stream) } + } + + checkResponsiblePeers() + ticker := time.NewTicker(respPeersStreamCheckInterval) + defer ticker.Stop() + for { select { - case <-time.After(respPeersStreamCheckInterval): - break - case <-ctx.Done(): + case <-s.streamLoopCtx.Done(): return + case <-ticker.C: + checkResponsiblePeers() } } } @@ -70,25 +114,3 @@ func (s *syncService) streamCheckLoop(ctx context.Context) { func (s *syncService) StreamPool() StreamPool { return s.streamPool } - -func NewSyncService(spaceId string, cache cache.TreeCache, configuration nodeconf.Configuration) SyncService { - var syncHandler SyncHandler - streamPool := newStreamPool(func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) { - return syncHandler.HandleMessage(ctx, senderId, message) - }) - syncHandler = newSyncHandler(cache, streamPool) - return newSyncService(spaceId, syncHandler, streamPool, configuration) -} - -func newSyncService( - spaceId string, - syncHandler SyncHandler, - streamPool StreamPool, - configuration nodeconf.Configuration) *syncService { - return &syncService{ - syncHandler: syncHandler, - streamPool: streamPool, - configuration: configuration, - spaceId: spaceId, - } -} From 04184b158240aa57d9f9352cdf9ef7a93a7dc36b Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sat, 17 Sep 2022 21:39:17 +0200 Subject: [PATCH 26/44] Remove responsibility of objecttree to notify and move to synctree --- common/commonspace/cache/treecache.go | 2 - common/commonspace/space.go | 12 +- common/commonspace/syncservice/streampool.go | 1 + common/commonspace/synctree/synctree.go | 52 +++- pkg/acl/tree/objecttree.go | 30 +- pkg/acl/tree/objecttreefactory.go | 8 +- service/sync/message/service.go | 128 -------- service/sync/requesthandler/requesthandler.go | 291 ------------------ 8 files changed, 53 insertions(+), 471 deletions(-) delete mode 100644 service/sync/message/service.go delete mode 100644 service/sync/requesthandler/requesthandler.go diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 9d688f50..6703d004 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -3,7 +3,6 @@ package cache import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) @@ -21,5 +20,4 @@ type TreeResult struct { type TreeCache interface { app.ComponentRunnable GetTree(ctx context.Context, id string) (TreeResult, error) - AddTree(ctx context.Context, payload storage.TreeStorageCreatePayload) error } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 91657bb7..1d6e981f 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -22,8 +22,8 @@ type Space interface { SyncService() syncservice.SyncService DiffService() diffservice.DiffService - CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) - BuildTree(ctx context.Context, id string, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) + CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) + BuildTree(ctx context.Context, id string, listener synctree.UpdateListener) (tree.ObjectTree, error) Close() error } @@ -65,11 +65,11 @@ func (s *space) DiffService() diffservice.DiffService { return s.diffService } -func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener tree.ObjectTreeUpdateListener) (tree.ObjectTree, error) { - return synctree.CreateSyncTree(payload, s.syncService, listener, nil, s.storage.CreateTreeStorage) +func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) { + return synctree.CreateSyncTree(ctx, payload, s.syncService, listener, nil, s.storage.CreateTreeStorage) } -func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTreeUpdateListener) (t tree.ObjectTree, err error) { +func (s *space) BuildTree(ctx context.Context, id string, listener synctree.UpdateListener) (t tree.ObjectTree, err error) { getTreeRemote := func() (*spacesyncproto.ObjectSyncMessage, error) { // TODO: add empty context handling (when this is not happening due to head update) peerId, err := syncservice.GetPeerIdFromStreamContext(ctx) @@ -115,7 +115,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener tree.ObjectTr return } } - return synctree.BuildSyncTree(s.syncService, store.(treestorage.TreeStorage), listener, s.aclList) + return synctree.BuildSyncTree(ctx, s.syncService, store.(treestorage.TreeStorage), listener, s.aclList) } func (s *space) getObjectIds() []string { diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 65197270..0e2626e9 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -120,6 +120,7 @@ Loop: delete(s.peerStreams, id) continue Loop default: + break } streams = append(streams, stream) } diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index d9dcb4e4..e45c3ffa 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -10,24 +10,35 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) +type UpdateListener interface { + Update(tree tree.ObjectTree) + Rebuild(tree tree.ObjectTree) +} + type SyncTree struct { tree.ObjectTree syncService syncservice.SyncService + listener UpdateListener } func CreateSyncTree( + ctx context.Context, payload tree.ObjectTreeCreatePayload, syncService syncservice.SyncService, - listener tree.ObjectTreeUpdateListener, + listener UpdateListener, aclList list.ACLList, createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) { - t, err = tree.CreateObjectTree(payload, listener, aclList, createStorage) + t, err = tree.CreateObjectTree(payload, aclList, createStorage) if err != nil { return } + t = &SyncTree{ + ObjectTree: t, + syncService: syncService, + listener: listener, + } - // TODO: use context where it is needed - err = syncService.NotifyHeadUpdate(context.Background(), t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ + err = syncService.NotifyHeadUpdate(ctx, t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ Heads: t.Heads(), SnapshotPath: t.SnapshotPath(), }) @@ -35,25 +46,31 @@ func CreateSyncTree( } func BuildSyncTree( + ctx context.Context, syncService syncservice.SyncService, treeStorage storage.TreeStorage, - listener tree.ObjectTreeUpdateListener, + listener UpdateListener, aclList list.ACLList) (t tree.ObjectTree, err error) { - return buildSyncTree(syncService, treeStorage, listener, aclList) + return buildSyncTree(ctx, syncService, treeStorage, listener, aclList) } func buildSyncTree( + ctx context.Context, syncService syncservice.SyncService, treeStorage storage.TreeStorage, - listener tree.ObjectTreeUpdateListener, + listener UpdateListener, aclList list.ACLList) (t tree.ObjectTree, err error) { - t, err = tree.BuildObjectTree(treeStorage, listener, aclList) + t, err = tree.BuildObjectTree(treeStorage, aclList) if err != nil { return } + t = &SyncTree{ + ObjectTree: t, + syncService: syncService, + listener: listener, + } - // TODO: use context where it is needed - err = syncService.NotifyHeadUpdate(context.Background(), t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ + err = syncService.NotifyHeadUpdate(ctx, t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ Heads: t.Heads(), SnapshotPath: t.SnapshotPath(), }) @@ -75,9 +92,18 @@ func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeCo func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (res tree.AddResult, err error) { res, err = s.AddRawChanges(ctx, changes...) - if err != nil || res.Mode == tree.Nothing { + if err != nil { return } + switch res.Mode { + case tree.Nothing: + return + case tree.Append: + s.listener.Update(s) + case tree.Rebuild: + s.listener.Rebuild(s) + } + err = s.syncService.NotifyHeadUpdate(ctx, s.ID(), s.Header(), &spacesyncproto.ObjectHeadUpdate{ Heads: res.Heads, Changes: res.Added, @@ -85,3 +111,7 @@ func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeC }) return } + +func (s *SyncTree) Tree() tree.ObjectTree { + return s +} diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 186db5af..c2b3e0b9 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -11,11 +11,6 @@ import ( "sync" ) -type ObjectTreeUpdateListener interface { - Update(tree ObjectTree) - Rebuild(tree ObjectTree) -} - type RWLocker interface { sync.Locker RLock() @@ -71,7 +66,6 @@ type objectTree struct { rawChangeLoader *rawChangeLoader treeBuilder *treeBuilder aclList list.ACLList - updateListener ObjectTreeUpdateListener id string header *aclpb.TreeHeader @@ -94,7 +88,6 @@ type objectTreeDeps struct { changeBuilder ChangeBuilder treeBuilder *treeBuilder treeStorage storage.TreeStorage - updateListener ObjectTreeUpdateListener validator ObjectTreeValidator rawChangeLoader *rawChangeLoader aclList list.ACLList @@ -102,7 +95,6 @@ type objectTreeDeps struct { func defaultObjectTreeDeps( treeStorage storage.TreeStorage, - listener ObjectTreeUpdateListener, aclList list.ACLList) objectTreeDeps { keychain := common.NewKeychain() @@ -112,7 +104,6 @@ func defaultObjectTreeDeps( changeBuilder: changeBuilder, treeBuilder: treeBuilder, treeStorage: treeStorage, - updateListener: listener, validator: newTreeValidator(), rawChangeLoader: newRawChangeLoader(treeStorage, changeBuilder), aclList: aclList, @@ -211,8 +202,7 @@ func (ot *objectTree) prepareBuilderContent(content SignableChangeContent) (cnt } func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { - var mode Mode - mode, addResult, err = ot.addRawChanges(ctx, rawChanges...) + addResult, err = ot.addRawChanges(ctx, rawChanges...) if err != nil { return } @@ -230,26 +220,10 @@ func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra // setting heads err = ot.treeStorage.SetHeads(ot.tree.Heads()) - if err != nil { - return - } - - if ot.updateListener == nil { - return - } - - switch mode { - case Append: - ot.updateListener.Update(ot) - case Rebuild: - ot.updateListener.Rebuild(ot) - default: - break - } return } -func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (mode Mode, addResult AddResult, err error) { +func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { // resetting buffers ot.tmpChangesBuf = ot.tmpChangesBuf[:0] ot.notSeenIdxBuf = ot.notSeenIdxBuf[:0] diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index a62c8add..44dc1fb5 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -19,19 +19,18 @@ type ObjectTreeCreatePayload struct { TreeType aclpb.TreeHeaderType } -func BuildObjectTree(treeStorage storage.TreeStorage, listener ObjectTreeUpdateListener, aclList list.ACLList) (ObjectTree, error) { - deps := defaultObjectTreeDeps(treeStorage, listener, aclList) +func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (ObjectTree, error) { + deps := defaultObjectTreeDeps(treeStorage, aclList) return buildObjectTree(deps) } func CreateObjectTree( payload ObjectTreeCreatePayload, - listener ObjectTreeUpdateListener, aclList list.ACLList, createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { aclList.RLock() var ( - deps = defaultObjectTreeDeps(nil, listener, aclList) + deps = defaultObjectTreeDeps(nil, aclList) state = aclList.ACLState() aclId = aclList.ID() aclHeadId = aclList.Head().Id @@ -91,7 +90,6 @@ func CreateObjectTree( func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { objTree := &objectTree{ treeStorage: deps.treeStorage, - updateListener: deps.updateListener, treeBuilder: deps.treeBuilder, validator: deps.validator, aclList: deps.aclList, diff --git a/service/sync/message/service.go b/service/sync/message/service.go deleted file mode 100644 index 6abf9b82..00000000 --- a/service/sync/message/service.go +++ /dev/null @@ -1,128 +0,0 @@ -package message - -import "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - -//import ( -// "context" -// "fmt" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/app" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" -// pool2 "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/service/net/pool" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/requesthandler" -// "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" -// "github.com/gogo/protobuf/proto" -// "sync" -// "time" -//) - -var log = logger.NewNamed("messageservice") - -const CName = "MessageService" - -// -//type service struct { -// nodes []*node.Node -// requestHandler requesthandler.RequestHandler -// pool pool2.Pool -// sync.RWMutex -//} -// -//func New() app.Component { -// return &service{} -//} -// -//type Service interface { -// SendMessageAsync(peerId string, msg *syncproto.Sync) error -// SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error -//} -// -//func (s *service) Init(a *app.App) (err error) { -// s.requestHandler = a.MustComponent(requesthandler.CName).(requesthandler.RequestHandler) -// s.nodes = a.MustComponent(node.CName).(node.Service).Nodes() -// s.pool = a.MustComponent(pool2.CName).(pool2.Pool) -// s.pool.AddHandler(syncproto.MessageType_MessageTypeSync, s.HandleMessage) -// return nil -//} -// -//func (s *service) Name() (name string) { -// return CName -//} -// -//func (s *service) Run(ctx context.Context) (err error) { -// return nil -//} -// -//func (s *service) Close(ctx context.Context) (err error) { -// return nil -//} -// -//func (s *service) HandleMessage(ctx context.Context, msg *pool.Message) (err error) { -// defer func() { -// if err != nil { -// msg.AckError(syncproto.System_Error_UNKNOWN, err.Error()) -// } else { -// msg.Ack() -// } -// }() -// -// syncMsg := &syncproto.Sync{} -// err = proto.Unmarshal(msg.Data, syncMsg) -// if err != nil { -// return -// } -// -// timeoutCtx, cancel := context.WithTimeout(ctx, time.Second*30) -// defer cancel() -// err = s.requestHandler.HandleSyncMessage(timeoutCtx, msg.Peer().Id(), syncMsg) -// return -//} -// -//func (s *service) SendMessageAsync(peerId string, msg *syncproto.Sync) (err error) { -// _, err = s.pool.DialAndAddPeer(context.Background(), peerId) -// if err != nil { -// return -// } -// -// marshalled, err := proto.Marshal(msg) -// if err != nil { -// return -// } -// -// go s.sendAsync(peerId, msgInfo(msg), marshalled) -// return -//} -// -//func (s *service) SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error { -// for _, rp := range s.nodes { -// s.SendMessageAsync(rp.PeerId, msg) -// } -// return nil -//} -// -//func (s *service) sendAsync(peerId string, msgTypeStr string, marshalled []byte) error { -// ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) -// defer cancel() -// return s.pool.SendAndWait(ctx, peerId, &syncproto.Message{ -// Header: &syncproto.Header{ -// Type: syncproto.MessageType_MessageTypeSync, -// DebugInfo: msgTypeStr, -// }, -// Data: marshalled, -// }) -//} -// -//func msgInfo(content *syncproto.Sync) (syncMethod string) { -// msg := content.GetMessage() -// switch { -// case msg.GetFullSyncRequest() != nil: -// syncMethod = "FullSyncRequest" -// case msg.GetFullSyncResponse() != nil: -// syncMethod = "FullSyncResponse" -// case msg.GetHeadUpdate() != nil: -// syncMethod = "HeadUpdate" -// } -// syncMethod = fmt.Sprintf("method: %s, treeType: %s", syncMethod, content.TreeHeader.DocType.String()) -// return -//} diff --git a/service/sync/requesthandler/requesthandler.go b/service/sync/requesthandler/requesthandler.go deleted file mode 100644 index 9c17171f..00000000 --- a/service/sync/requesthandler/requesthandler.go +++ /dev/null @@ -1,291 +0,0 @@ -package requesthandler - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" - "go.uber.org/zap" -) - -type requestHandler struct { - treeCache treecache.Service - account account.Service - messageService MessageSender -} - -var log = logger.NewNamed("requesthandler") - -func New() app.Component { - return &requestHandler{} -} - -type RequestHandler interface { - HandleSyncMessage(ctx context.Context, senderId string, request *syncproto.Sync) (err error) -} - -type MessageSender interface { - SendMessageAsync(peerId string, msg *syncproto.Sync) error - SendToSpaceAsync(spaceId string, msg *syncproto.Sync) error -} - -const CName = "SyncRequestHandler" - -func (r *requestHandler) Init(a *app.App) (err error) { - r.treeCache = a.MustComponent(treecache.CName).(treecache.Service) - r.account = a.MustComponent(account.CName).(account.Service) - r.messageService = a.MustComponent("MessageService").(MessageSender) - return nil -} - -func (r *requestHandler) Name() (name string) { - return CName -} - -func (r *requestHandler) Run(ctx context.Context) (err error) { - return nil -} - -func (r *requestHandler) Close(ctx context.Context) (err error) { - return nil -} - -func (r *requestHandler) HandleSyncMessage(ctx context.Context, senderId string, content *syncproto.Sync) error { - msg := content.GetMessage() - switch { - case msg.GetFullSyncRequest() != nil: - return r.HandleFullSyncRequest(ctx, senderId, msg.GetFullSyncRequest(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetFullSyncResponse() != nil: - return r.HandleFullSyncResponse(ctx, senderId, msg.GetFullSyncResponse(), content.GetTreeHeader(), content.GetTreeId()) - case msg.GetHeadUpdate() != nil: - return r.HandleHeadUpdate(ctx, senderId, msg.GetHeadUpdate(), content.GetTreeHeader(), content.GetTreeId()) - } - return nil -} - -func (r *requestHandler) HandleHeadUpdate( - ctx context.Context, - senderId string, - update *syncproto.SyncHeadUpdate, - header *aclpb.Header, - treeId string) (err error) { - - var ( - fullRequest *syncproto.SyncFullRequest - snapshotPath []string - result tree.AddResult - ) - log.With(zap.String("peerId", senderId), zap.String("treeId", treeId)). - Debug("processing head update") - - err = r.treeCache.Do(ctx, treeId, func(obj any) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - if slice.UnsortedEquals(update.Heads, objTree.Heads()) { - return nil - } - - result, err = objTree.AddRawChanges(ctx, update.Changes...) - if err != nil { - return err - } - - // if we couldn't add all the changes - shouldFullSync := len(update.Changes) != len(result.Added) - snapshotPath = objTree.SnapshotPath() - if shouldFullSync { - fullRequest, err = r.prepareFullSyncRequest(objTree) - if err != nil { - return err - } - } - return nil - }) - - // if there are no such tree - if err == storage.ErrUnknownTreeId { - fullRequest = &syncproto.SyncFullRequest{} - } - // if we have incompatible heads, or we haven't seen the tree at all - if fullRequest != nil { - return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullRequest(fullRequest, header, treeId)) - } - // if error or nothing has changed - if err != nil || len(result.Added) == 0 { - return err - } - - // otherwise sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) -} - -func (r *requestHandler) HandleFullSyncRequest( - ctx context.Context, - senderId string, - request *syncproto.SyncFullRequest, - header *aclpb.Header, - treeId string) (err error) { - - var fullResponse *syncproto.SyncFullResponse - err = r.treeCache.Do(ctx, treeId, func(obj any) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - fullResponse, err = r.prepareFullSyncResponse(treeId, request.SnapshotPath, request.Heads, objTree) - if err != nil { - return err - } - return nil - }) - - if err != nil { - return err - } - return r.messageService.SendMessageAsync(senderId, syncproto.WrapFullResponse(fullResponse, header, treeId)) -} - -func (r *requestHandler) HandleFullSyncResponse( - ctx context.Context, - senderId string, - response *syncproto.SyncFullResponse, - header *aclpb.Header, - treeId string) (err error) { - - var ( - snapshotPath []string - result tree.AddResult - ) - - err = r.treeCache.Do(ctx, treeId, func(obj interface{}) error { - objTree := obj.(tree.ObjectTree) - objTree.Lock() - defer objTree.Unlock() - - // if we already have the heads for whatever reason - if slice.UnsortedEquals(response.Heads, objTree.Heads()) { - return nil - } - - result, err = objTree.AddRawChanges(ctx, response.Changes...) - if err != nil { - return err - } - snapshotPath = objTree.SnapshotPath() - return nil - }) - - // if error or nothing has changed - if (err != nil || len(result.Added) == 0) && err != storage.ErrUnknownTreeId { - return err - } - // if we have a new tree - if err == storage.ErrUnknownTreeId { - err = r.createTree(ctx, response, header, treeId) - if err != nil { - return err - } - result = tree.AddResult{ - OldHeads: []string{}, - Heads: response.Heads, - Added: response.Changes, - } - } - // sending heads update message - newUpdate := &syncproto.SyncHeadUpdate{ - Heads: result.Heads, - Changes: result.Added, - SnapshotPath: snapshotPath, - } - return r.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(newUpdate, header, treeId)) -} - -func (r *requestHandler) HandleACLList( - ctx context.Context, - senderId string, - req *syncproto.SyncACLList, - header *aclpb.Header, - id string) (err error) { - - err = r.treeCache.Do(ctx, id, func(obj interface{}) error { - return nil - }) - // do nothing if already added - if err == nil { - return nil - } - // if not found then add to storage - if err == storage.ErrUnknownTreeId { - return r.createACLList(ctx, req, header, id) - } - return err -} - -func (r *requestHandler) prepareFullSyncRequest(t tree.ObjectTree) (*syncproto.SyncFullRequest, error) { - return &syncproto.SyncFullRequest{ - Heads: t.Heads(), - SnapshotPath: t.SnapshotPath(), - }, nil -} - -func (r *requestHandler) prepareFullSyncResponse( - treeId string, - theirPath, theirHeads []string, - t tree.ObjectTree) (*syncproto.SyncFullResponse, error) { - ourChanges, err := t.ChangesAfterCommonSnapshot(theirPath, theirHeads) - if err != nil { - return nil, err - } - - return &syncproto.SyncFullResponse{ - Heads: t.Heads(), - Changes: ourChanges, - SnapshotPath: t.SnapshotPath(), - }, nil -} - -func (r *requestHandler) createTree( - ctx context.Context, - response *syncproto.SyncFullResponse, - header *aclpb.Header, - treeId string) error { - - return r.treeCache.Add( - ctx, - treeId, - storage.TreeStorageCreatePayload{ - TreeId: treeId, - Header: header, - Changes: response.Changes, - Heads: response.Heads, - }) -} - -func (r *requestHandler) createACLList( - ctx context.Context, - req *syncproto.SyncACLList, - header *aclpb.Header, - treeId string) error { - - return r.treeCache.Add( - ctx, - treeId, - storage.ACLListStorageCreatePayload{ - ListId: treeId, - Header: header, - Records: req.Records, - }) -} From 832d0d5bfa1ecd3f01b9d84d7c06283c82127421 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sat, 17 Sep 2022 22:18:11 +0200 Subject: [PATCH 27/44] Add treecache to node --- common/commonspace/cache/treecache.go | 8 +++- common/commonspace/service.go | 21 ++++++----- common/commonspace/space.go | 2 + common/commonspace/storage/storage.go | 2 - node/nodespace/nodecache/treecache.go | 54 +++++++++++++++++++++++++++ node/nodespace/service.go | 16 +++++--- 6 files changed, 84 insertions(+), 19 deletions(-) create mode 100644 node/nodespace/nodecache/treecache.go diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 6703d004..1a6305b7 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -2,7 +2,7 @@ package cache import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) @@ -17,7 +17,11 @@ type TreeResult struct { TreeContainer TreeContainer } +type BuildFunc = func(ctx context.Context, id string, listener synctree.UpdateListener) (tree.ObjectTree, error) + type TreeCache interface { - app.ComponentRunnable GetTree(ctx context.Context, id string) (TreeResult, error) + SetBuildFunc(f BuildFunc) + + Close() error } diff --git a/common/commonspace/service.go b/common/commonspace/service.go index 9598d53a..1ddf8dd0 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -21,22 +21,23 @@ func New() Service { } type Service interface { - CreateSpace(ctx context.Context, id string) (sp Space, err error) + CreateSpace(ctx context.Context, id string, deps SpaceDeps) (sp Space, err error) app.Component } type service struct { config config.Space configurationService nodeconf.Service - storage storage.Storage - cache cache.TreeCache +} + +type SpaceDeps struct { + Cache cache.TreeCache + Storage storage.Storage } func (s *service) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(*config.Config).Space s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) - s.storage = a.MustComponent(storage.CName).(storage.Storage) - s.cache = a.MustComponent(cache.CName).(cache.TreeCache) return nil } @@ -44,17 +45,17 @@ func (s *service) Name() (name string) { return CName } -func (s *service) CreateSpace(ctx context.Context, id string) (Space, error) { +func (s *service) CreateSpace(ctx context.Context, id string, deps SpaceDeps) (Space, error) { lastConfiguration := s.configurationService.GetLast() - diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, s.storage, lastConfiguration, s.cache, log) - syncService := syncservice.NewSyncService(id, diffService, s.cache, lastConfiguration) + diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, deps.Storage, lastConfiguration, deps.Cache, log) + syncService := syncservice.NewSyncService(id, diffService, deps.Cache, lastConfiguration) sp := &space{ id: id, conf: s.config, syncService: syncService, diffService: diffService, - cache: s.cache, - storage: s.storage, + cache: deps.Cache, + storage: deps.Storage, } if err := sp.Init(ctx); err != nil { return nil, err diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 1d6e981f..3d181f52 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -50,6 +50,7 @@ func (s *space) Init(ctx context.Context) error { s.rpc = &rpcHandler{s: s} s.diffService.Init(s.getObjectIds()) s.syncService.Init() + s.cache.SetBuildFunc(s.BuildTree) return nil } @@ -125,5 +126,6 @@ func (s *space) getObjectIds() []string { func (s *space) Close() error { s.diffService.Close() + s.cache.Close() return s.syncService.Close() } diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index a9694988..b58d06d1 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -1,13 +1,11 @@ package storage import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" ) type Storage interface { storage.Provider - app.ComponentRunnable } const CName = "commonspace.storage" diff --git a/node/nodespace/nodecache/treecache.go b/node/nodespace/nodecache/treecache.go new file mode 100644 index 00000000..af195df9 --- /dev/null +++ b/node/nodespace/nodecache/treecache.go @@ -0,0 +1,54 @@ +package nodecache + +import ( + "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" + "time" +) + +var log = logger.NewNamed("treecache") + +type treeCache struct { + gcttl int + cache ocache.OCache +} + +func NewNodeCache(ttl int) cache.TreeCache { + return &treeCache{ + gcttl: ttl, + } +} + +func (c *treeCache) SetBuildFunc(buildFunc cache.BuildFunc) { + c.cache = ocache.New( + func(ctx context.Context, id string) (value ocache.Object, err error) { + return buildFunc(ctx, id, nil) + }, + ocache.WithLogger(log.Sugar()), + ocache.WithGCPeriod(time.Minute), + ocache.WithTTL(time.Duration(c.gcttl)*time.Second), + ocache.WithRefCounter(false), + ) +} + +func (c *treeCache) Close() (err error) { + return c.cache.Close() +} + +func (c *treeCache) GetTree(ctx context.Context, id string) (res cache.TreeResult, err error) { + var cacheRes ocache.Object + cacheRes, err = c.cache.Get(ctx, id) + if err != nil { + return cache.TreeResult{}, err + } + + res = cache.TreeResult{ + Release: func() { + c.cache.Release(id) + }, + TreeContainer: cacheRes.(cache.TreeContainer), + } + return +} diff --git a/node/nodespace/service.go b/node/nodespace/service.go index 27226bc2..9602a18b 100644 --- a/node/nodespace/service.go +++ b/node/nodespace/service.go @@ -8,6 +8,8 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace/nodecache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "time" ) @@ -27,16 +29,20 @@ type Service interface { type service struct { conf config.Space - cache ocache.OCache + spaceCache ocache.OCache commonSpace commonspace.Service } func (s *service) Init(a *app.App) (err error) { s.conf = a.MustComponent(config.CName).(*config.Config).Space s.commonSpace = a.MustComponent(commonspace.CName).(commonspace.Service) - s.cache = ocache.New( + s.spaceCache = ocache.New( func(ctx context.Context, id string) (value ocache.Object, err error) { - return s.commonSpace.CreateSpace(ctx, id) + deps := commonspace.SpaceDeps{ + Cache: nodecache.NewNodeCache(s.conf.GCTTL), + Storage: storage.NewInMemoryTreeStorageProvider(), + } + return s.commonSpace.CreateSpace(ctx, id, deps) }, ocache.WithLogger(log.Sugar()), ocache.WithGCPeriod(time.Minute), @@ -59,7 +65,7 @@ func (s *service) Run(ctx context.Context) (err error) { } func (s *service) GetSpace(ctx context.Context, id string) (commonspace.Space, error) { - v, err := s.cache.Get(ctx, id) + v, err := s.spaceCache.Get(ctx, id) if err != nil { return nil, err } @@ -67,5 +73,5 @@ func (s *service) GetSpace(ctx context.Context, id string) (commonspace.Space, e } func (s *service) Close(ctx context.Context) (err error) { - return s.cache.Close() + return s.spaceCache.Close() } From dc69e93064afe8611fd0edcfa19cd0b831d57160 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sun, 18 Sep 2022 11:23:01 +0200 Subject: [PATCH 28/44] Some renamings and fixes --- common/commonspace/space.go | 4 ++-- common/commonspace/spacetree/spacetree.go | 1 + common/commonspace/syncservice/streampool.go | 10 +++++----- common/commonspace/syncservice/syncservice.go | 2 +- common/commonspace/synctree/synctree.go | 1 + pkg/acl/tree/objecttree.go | 2 +- pkg/acl/tree/rawtreevalidator.go | 2 +- 7 files changed, 12 insertions(+), 10 deletions(-) create mode 100644 common/commonspace/spacetree/spacetree.go diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 3d181f52..5fbc675b 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -50,6 +50,7 @@ func (s *space) Init(ctx context.Context) error { s.rpc = &rpcHandler{s: s} s.diffService.Init(s.getObjectIds()) s.syncService.Init() + // basically this provides access for the external cache to use space's tree building functions s.cache.SetBuildFunc(s.BuildTree) return nil } @@ -67,7 +68,7 @@ func (s *space) DiffService() diffservice.DiffService { } func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) { - return synctree.CreateSyncTree(ctx, payload, s.syncService, listener, nil, s.storage.CreateTreeStorage) + return synctree.CreateSyncTree(ctx, payload, s.syncService, listener, s.aclList, s.storage.CreateTreeStorage) } func (s *space) BuildTree(ctx context.Context, id string, listener synctree.UpdateListener) (t tree.ObjectTree, err error) { @@ -109,7 +110,6 @@ func (s *space) BuildTree(ctx context.Context, id string, listener synctree.Upda if err != nil { return } - // TODO: maybe it is better to use the tree that we already built and just replace the storage // now we are sure that we can save it to the storage store, err = s.storage.CreateTreeStorage(payload) if err != nil { diff --git a/common/commonspace/spacetree/spacetree.go b/common/commonspace/spacetree/spacetree.go new file mode 100644 index 00000000..9cb4ff16 --- /dev/null +++ b/common/commonspace/spacetree/spacetree.go @@ -0,0 +1 @@ +package spacetree diff --git a/common/commonspace/syncservice/streampool.go b/common/commonspace/syncservice/streampool.go index 0e2626e9..5eb97170 100644 --- a/common/commonspace/syncservice/streampool.go +++ b/common/commonspace/syncservice/streampool.go @@ -21,7 +21,7 @@ type StreamPool interface { SyncClient AddAndReadStreamSync(stream spacesyncproto.SpaceStream) (err error) AddAndReadStreamAsync(stream spacesyncproto.SpaceStream) - HasStream(peerId string) bool + HasActiveStream(peerId string) bool Close() (err error) } @@ -55,8 +55,8 @@ func newStreamPool(messageHandler MessageHandler) StreamPool { } } -func (s *streamPool) HasStream(peerId string) (res bool) { - _, err := s.getStream(peerId) +func (s *streamPool) HasActiveStream(peerId string) (res bool) { + _, err := s.getOrDeleteStream(peerId) return err == nil } @@ -83,7 +83,7 @@ func (s *streamPool) SendSync( } func (s *streamPool) SendAsync(peerId string, message *spacesyncproto.ObjectSyncMessage) (err error) { - stream, err := s.getStream(peerId) + stream, err := s.getOrDeleteStream(peerId) if err != nil { return } @@ -91,7 +91,7 @@ func (s *streamPool) SendAsync(peerId string, message *spacesyncproto.ObjectSync return stream.Send(message) } -func (s *streamPool) getStream(id string) (stream spacesyncproto.SpaceStream, err error) { +func (s *streamPool) getOrDeleteStream(id string) (stream spacesyncproto.SpaceStream, err error) { s.Lock() defer s.Unlock() stream, exists := s.peerStreams[id] diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 736d40b7..ed88f8ab 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -85,7 +85,7 @@ func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) { return } for _, peer := range respPeers { - if s.streamPool.HasStream(peer.Id()) { + if s.streamPool.HasActiveStream(peer.Id()) { continue } cl := spacesyncproto.NewDRPCSpaceClient(peer) diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index e45c3ffa..7e4341e2 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -15,6 +15,7 @@ type UpdateListener interface { Rebuild(tree tree.ObjectTree) } +// SyncTree sends head updates to sync service and also sends new changes to update listener type SyncTree struct { tree.ObjectTree syncService syncservice.SyncService diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index c2b3e0b9..7c1df882 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -43,6 +43,7 @@ type ObjectTree interface { Heads() []string Root() *Change HasChange(string) bool + DebugDump() (string, error) Iterate(convert ChangeConvertFunc, iterate ChangeIterateFunc) error IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error @@ -51,7 +52,6 @@ type ObjectTree interface { ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) Storage() storage.TreeStorage - DebugDump() (string, error) AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error) diff --git a/pkg/acl/tree/rawtreevalidator.go b/pkg/acl/tree/rawtreevalidator.go index 86a0082f..01cb1105 100644 --- a/pkg/acl/tree/rawtreevalidator.go +++ b/pkg/acl/tree/rawtreevalidator.go @@ -12,6 +12,6 @@ func ValidateRawTree(payload storage.TreeStorageCreatePayload, aclList list.ACLL return } - _, err = BuildObjectTree(treeStorage, nil, aclList) + _, err = BuildObjectTree(treeStorage, aclList) return } From e768e835072ae0483016aca72971b7a2d16ddcd0 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 21 Sep 2022 09:26:33 +0200 Subject: [PATCH 29/44] Update gitignore to include vendor --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 2bc7dc72..97927dad 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,9 @@ # Output of the go coverage tool, specifically when used with LiteIDE *.out +# Golang vendor folder +vendor + # Intelli-J files .idea From 58812a568fa10ac847bee16f6daee397cb41a27a Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Sun, 25 Sep 2022 13:50:35 +0200 Subject: [PATCH 30/44] WIP root change refactoring --- Makefile | 17 +- .../spacesyncproto/protos/spacesync.proto | 18 +- .../commonspace/spacesyncproto/spacesync.go | 2 +- .../spacesyncproto/spacesync.pb.go | 489 +- common/commonspace/syncservice/synchandler.go | 2 +- common/commonspace/syncservice/syncservice.go | 2 +- common/commonspace/synctree/synctree.go | 2 +- go.mod | 6 +- go.sum | 10 - .../aclchanges/aclpb/protos/aclchanges.proto | 143 - pkg/acl/aclchanges/change.go | 12 - .../aclrecord.pb.go} | 6053 +++++++---------- pkg/acl/aclrecordproto/protos/aclrecord.proto | 102 + pkg/acl/list/aclstate.go | 54 +- pkg/acl/list/changebuilder.go | 2 +- pkg/acl/list/list.go | 4 +- pkg/acl/list/list_test.go | 2 +- pkg/acl/list/record.go | 48 +- pkg/acl/storage/inmemory.go | 48 +- pkg/acl/storage/liststorage.go | 10 +- pkg/acl/storage/provider.go | 15 +- pkg/acl/storage/treestorage.go | 8 +- pkg/acl/tree/change.go | 76 +- pkg/acl/tree/changebuilder.go | 165 +- pkg/acl/tree/changevalidator.go | 12 +- pkg/acl/tree/objecttree.go | 75 +- pkg/acl/tree/objecttree_test.go | 97 +- pkg/acl/tree/objecttreefactory.go | 108 +- pkg/acl/tree/rawloader.go | 16 +- pkg/acl/tree/treegraph_nix.go | 2 +- .../treechangeproto/protos/treechange.proto | 55 + pkg/acl/treechangeproto/treechange.pb.go | 1537 +++++ service/document/service.go | 2 +- service/storage/service.go | 2 +- service/treecache/service.go | 2 +- syncproto/proto/sync.proto | 2 +- 36 files changed, 4935 insertions(+), 4265 deletions(-) delete mode 100644 pkg/acl/aclchanges/aclpb/protos/aclchanges.proto delete mode 100644 pkg/acl/aclchanges/change.go rename pkg/acl/{aclchanges/aclpb/aclchanges.pb.go => aclrecordproto/aclrecord.pb.go} (60%) create mode 100644 pkg/acl/aclrecordproto/protos/aclrecord.proto create mode 100644 pkg/acl/treechangeproto/protos/treechange.proto create mode 100644 pkg/acl/treechangeproto/treechange.pb.go diff --git a/Makefile b/Makefile index b75d2d22..e9143f01 100644 --- a/Makefile +++ b/Makefile @@ -12,26 +12,25 @@ endif export PATH=$(GOPATH)/bin:$(shell echo $$PATH) -# TODO: folders were changed, so we should update Makefile and protos generation proto: @echo 'Generating protobuf packages (Go)...' # Uncomment if needed @$(eval ROOT_PKG := pkg) @$(eval GOGO_START := GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1) - @$(eval P_ACL_CHANGES_PATH_PB := $(ROOT_PKG)/acl/aclchanges/aclpb) + @$(eval P_ACL_RECORDS_PATH_PB := $(ROOT_PKG)/acl/aclrecordproto) + @$(eval P_TREE_CHANGES_PATH_PB := $(ROOT_PKG)/acl/treechangeproto) @$(eval P_SYNC_CHANGES_PATH_PB := syncproto) @$(eval P_TEST_CHANGES_PATH_PB := $(ROOT_PKG)/acl/testutils/testchanges) - @$(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types) - @$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types) - @$(eval P_ACL_CHANGES := M$(P_ACL_CHANGES_PATH_PB)/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_CHANGES_PATH_PB)) + @$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_RECORDS_PATH_PB)) + @$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_TREE_CHANGES_PATH_PB)) - # use if needed $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT)) - $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_CHANGES_PATH_PB)/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_RECORDS_PATH_PB)/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=:. $(P_TREE_CHANGES_PATH_PB)/protos/*.proto $(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto - $(eval PKGMAP := $$(P_ACL_CHANGES)) - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto + $(eval PKGMAP := $$(P_TREE_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto + build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) go build -v -o bin/anytype-node -ldflags "$(FLAGS)" cmd/node/node.go \ No newline at end of file diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 22f7e82d..a4bb3171 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package anySpace; option go_package = "common/commonspace/spacesyncproto"; -import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto"; +import "pkg/acl/treechangeproto/protos/treechange.proto"; enum ErrCodes { Unexpected = 0; @@ -49,7 +49,7 @@ message HeadSyncResponse { message ObjectSyncMessage { string spaceId = 1; ObjectSyncContentValue content = 2; - acl.TreeHeader treeHeader = 3; + treechange.RootChange treeHeader = 3; string treeId = 4; string trackingId = 5; // @@ -70,24 +70,32 @@ message ObjectSyncContentValue { // ObjectHeadUpdate is a message sent on document head update message ObjectHeadUpdate { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } // ObjectHeadUpdate is a message sent when document needs full sync message ObjectFullSyncRequest { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } // ObjectFullSyncResponse is a message sent as a response for a specific full sync message ObjectFullSyncResponse { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } message ObjectErrorResponse { string error = 1; } + +message SpaceHeader { + bytes identity = 1; + int64 timestamp = 2; + string spaceType = 3; + uint64 replicationKey = 4; + bytes seed = 5; +} diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go index 25ec1ba6..6ac07962 100644 --- a/common/commonspace/spacesyncproto/spacesync.go +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -1,6 +1,6 @@ package spacesyncproto -import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" +import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" type SpaceStream = DRPCSpace_StreamStream diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 04b77518..a0e6bf89 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -5,7 +5,7 @@ package spacesyncproto import ( fmt "fmt" - aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -320,11 +320,11 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` - TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + TreeHeader *treechangeproto.RootChange `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -374,7 +374,7 @@ func (m *ObjectSyncMessage) GetContent() *ObjectSyncContentValue { return nil } -func (m *ObjectSyncMessage) GetTreeHeader() *aclpb.TreeHeader { +func (m *ObjectSyncMessage) GetTreeHeader() *treechangeproto.RootChange { if m != nil { return m.TreeHeader } @@ -509,9 +509,9 @@ func (*ObjectSyncContentValue) XXX_OneofWrappers() []interface{} { // ObjectHeadUpdate is a message sent on document head update type ObjectHeadUpdate struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectHeadUpdate) Reset() { *m = ObjectHeadUpdate{} } @@ -554,7 +554,7 @@ func (m *ObjectHeadUpdate) GetHeads() []string { return nil } -func (m *ObjectHeadUpdate) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectHeadUpdate) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -570,9 +570,9 @@ func (m *ObjectHeadUpdate) GetSnapshotPath() []string { // ObjectHeadUpdate is a message sent when document needs full sync type ObjectFullSyncRequest struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} } @@ -615,7 +615,7 @@ func (m *ObjectFullSyncRequest) GetHeads() []string { return nil } -func (m *ObjectFullSyncRequest) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectFullSyncRequest) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -631,9 +631,9 @@ func (m *ObjectFullSyncRequest) GetSnapshotPath() []string { // ObjectFullSyncResponse is a message sent as a response for a specific full sync type ObjectFullSyncResponse struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectFullSyncResponse) Reset() { *m = ObjectFullSyncResponse{} } @@ -676,7 +676,7 @@ func (m *ObjectFullSyncResponse) GetHeads() []string { return nil } -func (m *ObjectFullSyncResponse) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectFullSyncResponse) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -734,6 +734,82 @@ func (m *ObjectErrorResponse) GetError() string { return "" } +type SpaceHeader struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + SpaceType string `protobuf:"bytes,3,opt,name=spaceType,proto3" json:"spaceType,omitempty"` + ReplicationKey uint64 `protobuf:"varint,4,opt,name=replicationKey,proto3" json:"replicationKey,omitempty"` + Seed []byte `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"` +} + +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_5855f4ef9cf24cdb, []int{11} +} +func (m *SpaceHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceHeader.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 *SpaceHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceHeader.Merge(m, src) +} +func (m *SpaceHeader) XXX_Size() int { + return m.Size() +} +func (m *SpaceHeader) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceHeader proto.InternalMessageInfo + +func (m *SpaceHeader) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *SpaceHeader) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *SpaceHeader) GetSpaceType() string { + if m != nil { + return m.SpaceType + } + return "" +} + +func (m *SpaceHeader) GetReplicationKey() uint64 { + if m != nil { + return m.ReplicationKey + } + return 0 +} + +func (m *SpaceHeader) GetSeed() []byte { + if m != nil { + return m.Seed + } + return nil +} + func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") @@ -747,6 +823,7 @@ func init() { proto.RegisterType((*ObjectFullSyncRequest)(nil), "anySpace.ObjectFullSyncRequest") proto.RegisterType((*ObjectFullSyncResponse)(nil), "anySpace.ObjectFullSyncResponse") proto.RegisterType((*ObjectErrorResponse)(nil), "anySpace.ObjectErrorResponse") + proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader") } func init() { @@ -754,52 +831,57 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 712 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4b, 0x6f, 0xd3, 0x40, - 0x10, 0xf6, 0xa6, 0x79, 0x75, 0xd2, 0x47, 0x58, 0x68, 0x31, 0x41, 0xa4, 0xc1, 0xa7, 0x08, 0xa4, - 0xa4, 0x0a, 0x17, 0x44, 0xb9, 0xd0, 0x2a, 0x55, 0x22, 0xc4, 0x43, 0x5b, 0x0a, 0x12, 0xe2, 0xb2, - 0xb5, 0xb7, 0x49, 0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d6, 0x28, 0xb8, 0x57, 0x81, 0x62, 0x3b, 0x0c, 0x77, 0x7c, 0x47, 0x48, - 0xba, 0x02, 0xb0, 0xef, 0x89, 0x4f, 0x81, 0xb0, 0x95, 0x70, 0xca, 0x46, 0xeb, 0x3b, 0x81, 0x1c, - 0x1e, 0x0a, 0xfa, 0x04, 0x8a, 0xc9, 0xe5, 0x40, 0x6f, 0xa5, 0x5d, 0x18, 0x68, 0x78, 0xa5, 0x92, - 0x7a, 0x97, 0x44, 0xcb, 0xef, 0x42, 0x7e, 0x4f, 0x85, 0x82, 0x0f, 0xe9, 0xed, 0xb4, 0xdb, 0x20, - 0xbe, 0x55, 0x2a, 0x97, 0x4d, 0xd6, 0xc9, 0x26, 0xd9, 0xde, 0xfa, 0x79, 0x56, 0x25, 0xa7, 0x67, - 0x55, 0xf2, 0xe7, 0xac, 0x4a, 0xbe, 0x9d, 0x57, 0x8d, 0xd3, 0xf3, 0xaa, 0xf1, 0xfb, 0xbc, 0x6a, - 0xbc, 0xbd, 0xfb, 0xdf, 0xff, 0xb0, 0x83, 0x3c, 0xbe, 0x1e, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, - 0x93, 0x27, 0x56, 0x41, 0xef, 0x06, 0x00, 0x00, + // 797 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x8e, 0xe3, 0x44, + 0x10, 0xb6, 0x33, 0x99, 0x49, 0x52, 0x99, 0x99, 0x0d, 0x0d, 0x3b, 0x98, 0x00, 0xd9, 0xe0, 0x03, + 0x8a, 0x40, 0x4a, 0x50, 0x90, 0x10, 0x30, 0x5c, 0xd8, 0x51, 0x46, 0x89, 0x56, 0xfc, 0xa8, 0x67, + 0x17, 0x24, 0xc4, 0xa5, 0xd7, 0xae, 0x4d, 0xcc, 0xda, 0x6e, 0xe3, 0xee, 0xb0, 0xe4, 0x09, 0xb8, + 0x80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ff, 0xff, 0x7b, 0x1f, 0x02, 0x55, 0xae, 0x07, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -1386,6 +1468,60 @@ func (m *ObjectErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SpaceHeader) 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 *SpaceHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Seed) > 0 { + i -= len(m.Seed) + copy(dAtA[i:], m.Seed) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Seed))) + i-- + dAtA[i] = 0x2a + } + if m.ReplicationKey != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.ReplicationKey)) + i-- + dAtA[i] = 0x20 + } + if len(m.SpaceType) > 0 { + i -= len(m.SpaceType) + copy(dAtA[i:], m.SpaceType) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceType))) + i-- + dAtA[i] = 0x1a + } + if m.Timestamp != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x10 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -1671,6 +1807,33 @@ func (m *ObjectErrorResponse) Size() (n int) { return n } +func (m *SpaceHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovSpacesync(uint64(m.Timestamp)) + } + l = len(m.SpaceType) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.ReplicationKey != 0 { + n += 1 + sovSpacesync(uint64(m.ReplicationKey)) + } + l = len(m.Seed) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2362,7 +2525,7 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.TreeHeader == nil { - m.TreeHeader = &aclpb.TreeHeader{} + m.TreeHeader = &treechangeproto.RootChange{} } if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2733,7 +2896,7 @@ func (m *ObjectHeadUpdate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2881,7 +3044,7 @@ func (m *ObjectFullSyncRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3029,7 +3192,7 @@ func (m *ObjectFullSyncResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3169,6 +3332,194 @@ func (m *ObjectErrorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *SpaceHeader) 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: SpaceHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", 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.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceType", 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.SpaceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReplicationKey", wireType) + } + m.ReplicationKey = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReplicationKey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Seed", 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.Seed = append(m.Seed[:0], dAtA[iNdEx:postIndex]...) + if m.Seed == nil { + m.Seed = []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 skipSpacesync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 12798bc3..0d3be042 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" ) diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index ed88f8ab..c7039a73 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -5,7 +5,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "time" ) diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 7e4341e2..149c7c9b 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/go.mod b/go.mod index 47537c53..9c60aa54 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/anytypeio/go-anytype-infrastructure-experiments go 1.18 require ( + github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab github.com/cespare/xxhash v1.1.0 github.com/goccy/go-graphviz v0.0.9 @@ -16,6 +17,7 @@ require ( github.com/multiformats/go-multihash v0.1.0 github.com/stretchr/testify v1.8.0 github.com/zeebo/blake3 v0.2.3 + github.com/zeebo/errs v1.3.0 go.uber.org/zap v1.21.0 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/yaml.v3 v3.0.1 @@ -24,7 +26,6 @@ require ( require ( github.com/OneOfOne/xxhash v1.2.8 // indirect - github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 // indirect github.com/btcsuite/btcd v0.22.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect @@ -32,7 +33,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fogleman/gg v1.3.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/golang/protobuf v1.5.2 // indirect github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/libp2p/go-openssl v0.0.7 // indirect @@ -47,13 +47,11 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/zeebo/errs v1.3.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect - google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect lukechampine.com/blake3 v1.1.6 // indirect diff --git a/go.sum b/go.sum index ba61ef8a..34c05834 100644 --- a/go.sum +++ b/go.sum @@ -32,10 +32,6 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= @@ -117,8 +113,6 @@ github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= -github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= -github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= @@ -184,10 +178,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto deleted file mode 100644 index 5d69e94f..00000000 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ /dev/null @@ -1,143 +0,0 @@ -syntax = "proto3"; -package acl; -option go_package = "pkg/acl/aclchanges/aclpb"; - -// ACL protos - -message RawACLRecord { - bytes payload = 1; - bytes signature = 2; - string id = 3; // this field is only used on user side for convenience, it should be empty when saving to db -} - -message ACLContentValue { - oneof value { - ACLUserAdd userAdd = 1; - ACLUserRemove userRemove = 2; - ACLUserPermissionChange userPermissionChange = 3; - ACLUserInvite userInvite = 4; - ACLUserJoin userJoin = 5; - ACLUserConfirm userConfirm = 6; - } -} - -message ACLData { - repeated ACLContentValue aclContent = 1; -} - -message ACLState { - repeated uint64 readKeyHashes = 1; - repeated ACLUserState userStates = 2; - map invites = 3; // TODO: later - // repeated string unconfirmedUsers = 4; // TODO: later -} - -message ACLUserState { - bytes identity = 1; - bytes encryptionKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know - ACLUserPermissions permissions = 4; - bool isConfirmed = 5; -} - -// we already know identity and encryptionKey -message ACLUserAdd { - bytes identity = 1; // public signing key - bytes encryptionKey = 2; // public encryption key - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - ACLUserPermissions permissions = 4; -} - -// TODO: this is not used as of now -message ACLUserConfirm { // not needed for read permissions - bytes identity = 1; // not needed - string userAddId = 2; -} - -message ACLUserInvite { - bytes acceptPublicKey = 1; - bytes encryptPublicKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - ACLUserPermissions permissions = 4; - string inviteId = 5; -} - -message ACLUserJoin { - bytes identity = 1; - bytes encryptionKey = 2; - bytes acceptSignature = 3; // sign acceptPublicKey - string userInviteId = 4; - repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key -} - -message ACLUserRemove { - bytes identity = 1; - repeated ACLReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users -} - -message ACLReadKeyReplace { - bytes identity = 1; - bytes encryptionKey = 2; - bytes encryptedReadKey = 3; -} - -message ACLUserPermissionChange { - bytes identity = 1; - ACLUserPermissions permissions = 2; -} - -enum ACLUserPermissions { - Admin = 0; - Writer = 1; - Reader = 2; - Removed = 3; -} - -message ACLRecord { - string prevId = 1; - bytes identity = 2; - bytes data = 3; - uint64 currentReadKeyHash = 4; - int64 timestamp = 5; -} - -message ACLHeader { - string firstId = 1; - bytes identity = 2; // the identity of the creator -} - -// Tree protos - -message RawTreeChange { - bytes payload = 1; - bytes signature = 2; -} - -message RawTreeChangeWithId { - bytes rawChange = 1; - string id = 2; -} - -message TreeChange { - repeated string treeHeadIds = 1; - string aclHeadId = 2; - string snapshotBaseId = 3; - bytes changesData = 4; - uint64 currentReadKeyHash = 5; - int64 timestamp = 6; - bytes identity = 7; - bool isSnapshot = 8; -} - -enum TreeHeaderType { - Object = 0; - Space = 1; -} - -message TreeHeader { - string firstId = 1; - string aclId = 2; - TreeHeaderType treeHeaderType = 3; - bytes identity = 4; - bytes data = 5; // this should be reserved for the client to add the data it needs -} diff --git a/pkg/acl/aclchanges/change.go b/pkg/acl/aclchanges/change.go deleted file mode 100644 index 3d3b4376..00000000 --- a/pkg/acl/aclchanges/change.go +++ /dev/null @@ -1,12 +0,0 @@ -package aclchanges - -import ( - "github.com/gogo/protobuf/proto" -) - -type Change interface { - ProtoChange() proto.Marshaler - DecryptedChangeContent() []byte - Signature() []byte - CID() string -} diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclrecordproto/aclrecord.pb.go similarity index 60% rename from pkg/acl/aclchanges/aclpb/aclchanges.pb.go rename to pkg/acl/aclrecordproto/aclrecord.pb.go index 60437c7e..69035b70 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclrecordproto/aclrecord.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +// source: pkg/acl/aclrecordproto/protos/aclrecord.proto -package aclpb +package aclrecordproto import ( fmt "fmt" @@ -25,24 +25,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ACLUserPermissions int32 const ( - ACLUserPermissions_Admin ACLUserPermissions = 0 - ACLUserPermissions_Writer ACLUserPermissions = 1 - ACLUserPermissions_Reader ACLUserPermissions = 2 - ACLUserPermissions_Removed ACLUserPermissions = 3 + ACLUserPermissions_Admin ACLUserPermissions = 0 + ACLUserPermissions_Writer ACLUserPermissions = 1 + ACLUserPermissions_Reader ACLUserPermissions = 2 ) var ACLUserPermissions_name = map[int32]string{ 0: "Admin", 1: "Writer", 2: "Reader", - 3: "Removed", } var ACLUserPermissions_value = map[string]int32{ - "Admin": 0, - "Writer": 1, - "Reader": 2, - "Removed": 3, + "Admin": 0, + "Writer": 1, + "Reader": 2, } func (x ACLUserPermissions) String() string { @@ -50,45 +47,19 @@ func (x ACLUserPermissions) String() string { } func (ACLUserPermissions) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{0} -} - -type TreeHeaderType int32 - -const ( - TreeHeaderType_Object TreeHeaderType = 0 - TreeHeaderType_Space TreeHeaderType = 1 -) - -var TreeHeaderType_name = map[int32]string{ - 0: "Object", - 1: "Space", -} - -var TreeHeaderType_value = map[string]int32{ - "Object": 0, - "Space": 1, -} - -func (x TreeHeaderType) String() string { - return proto.EnumName(TreeHeaderType_name, int32(x)) -} - -func (TreeHeaderType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{1} + return fileDescriptor_14abe0d1b4206d54, []int{0} } type RawACLRecord struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` } func (m *RawACLRecord) Reset() { *m = RawACLRecord{} } func (m *RawACLRecord) String() string { return proto.CompactTextString(m) } func (*RawACLRecord) ProtoMessage() {} func (*RawACLRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{0} + return fileDescriptor_14abe0d1b4206d54, []int{0} } func (m *RawACLRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -131,13 +102,210 @@ func (m *RawACLRecord) GetSignature() []byte { return nil } -func (m *RawACLRecord) GetId() string { +type RawACLRecordWithId struct { + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *RawACLRecordWithId) Reset() { *m = RawACLRecordWithId{} } +func (m *RawACLRecordWithId) String() string { return proto.CompactTextString(m) } +func (*RawACLRecordWithId) ProtoMessage() {} +func (*RawACLRecordWithId) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{1} +} +func (m *RawACLRecordWithId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawACLRecordWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawACLRecordWithId.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 *RawACLRecordWithId) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawACLRecordWithId.Merge(m, src) +} +func (m *RawACLRecordWithId) XXX_Size() int { + return m.Size() +} +func (m *RawACLRecordWithId) XXX_DiscardUnknown() { + xxx_messageInfo_RawACLRecordWithId.DiscardUnknown(m) +} + +var xxx_messageInfo_RawACLRecordWithId proto.InternalMessageInfo + +func (m *RawACLRecordWithId) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + +func (m *RawACLRecordWithId) GetId() string { if m != nil { return m.Id } return "" } +type ACLRecord struct { + PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *ACLRecord) Reset() { *m = ACLRecord{} } +func (m *ACLRecord) String() string { return proto.CompactTextString(m) } +func (*ACLRecord) ProtoMessage() {} +func (*ACLRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{2} +} +func (m *ACLRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLRecord.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 *ACLRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLRecord.Merge(m, src) +} +func (m *ACLRecord) XXX_Size() int { + return m.Size() +} +func (m *ACLRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ACLRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLRecord proto.InternalMessageInfo + +func (m *ACLRecord) GetPrevId() string { + if m != nil { + return m.PrevId + } + return "" +} + +func (m *ACLRecord) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *ACLRecord) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *ACLRecord) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *ACLRecord) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type ACLRoot struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + SpaceId string `protobuf:"bytes,3,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + EncryptedReadKey []byte `protobuf:"bytes,4,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` + DerivationScheme string `protobuf:"bytes,5,opt,name=derivationScheme,proto3" json:"derivationScheme,omitempty"` +} + +func (m *ACLRoot) Reset() { *m = ACLRoot{} } +func (m *ACLRoot) String() string { return proto.CompactTextString(m) } +func (*ACLRoot) ProtoMessage() {} +func (*ACLRoot) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{3} +} +func (m *ACLRoot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLRoot.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 *ACLRoot) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLRoot.Merge(m, src) +} +func (m *ACLRoot) XXX_Size() int { + return m.Size() +} +func (m *ACLRoot) XXX_DiscardUnknown() { + xxx_messageInfo_ACLRoot.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLRoot proto.InternalMessageInfo + +func (m *ACLRoot) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *ACLRoot) GetEncryptionKey() []byte { + if m != nil { + return m.EncryptionKey + } + return nil +} + +func (m *ACLRoot) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *ACLRoot) GetEncryptedReadKey() []byte { + if m != nil { + return m.EncryptedReadKey + } + return nil +} + +func (m *ACLRoot) GetDerivationScheme() string { + if m != nil { + return m.DerivationScheme + } + return "" +} + type ACLContentValue struct { // Types that are valid to be assigned to Value: // *ACLContentValue_UserAdd @@ -145,7 +313,6 @@ type ACLContentValue struct { // *ACLContentValue_UserPermissionChange // *ACLContentValue_UserInvite // *ACLContentValue_UserJoin - // *ACLContentValue_UserConfirm Value isACLContentValue_Value `protobuf_oneof:"value"` } @@ -153,7 +320,7 @@ func (m *ACLContentValue) Reset() { *m = ACLContentValue{} } func (m *ACLContentValue) String() string { return proto.CompactTextString(m) } func (*ACLContentValue) ProtoMessage() {} func (*ACLContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{1} + return fileDescriptor_14abe0d1b4206d54, []int{4} } func (m *ACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,16 +370,12 @@ type ACLContentValue_UserInvite struct { type ACLContentValue_UserJoin struct { UserJoin *ACLUserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` } -type ACLContentValue_UserConfirm struct { - UserConfirm *ACLUserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` -} func (*ACLContentValue_UserAdd) isACLContentValue_Value() {} func (*ACLContentValue_UserRemove) isACLContentValue_Value() {} func (*ACLContentValue_UserPermissionChange) isACLContentValue_Value() {} func (*ACLContentValue_UserInvite) isACLContentValue_Value() {} func (*ACLContentValue_UserJoin) isACLContentValue_Value() {} -func (*ACLContentValue_UserConfirm) isACLContentValue_Value() {} func (m *ACLContentValue) GetValue() isACLContentValue_Value { if m != nil { @@ -256,13 +419,6 @@ func (m *ACLContentValue) GetUserJoin() *ACLUserJoin { return nil } -func (m *ACLContentValue) GetUserConfirm() *ACLUserConfirm { - if x, ok := m.GetValue().(*ACLContentValue_UserConfirm); ok { - return x.UserConfirm - } - return nil -} - // XXX_OneofWrappers is for the internal use of the proto package. func (*ACLContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -271,7 +427,6 @@ func (*ACLContentValue) XXX_OneofWrappers() []interface{} { (*ACLContentValue_UserPermissionChange)(nil), (*ACLContentValue_UserInvite)(nil), (*ACLContentValue_UserJoin)(nil), - (*ACLContentValue_UserConfirm)(nil), } } @@ -283,7 +438,7 @@ func (m *ACLData) Reset() { *m = ACLData{} } func (m *ACLData) String() string { return proto.CompactTextString(m) } func (*ACLData) ProtoMessage() {} func (*ACLData) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2} + return fileDescriptor_14abe0d1b4206d54, []int{5} } func (m *ACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -329,7 +484,7 @@ func (m *ACLState) Reset() { *m = ACLState{} } func (m *ACLState) String() string { return proto.CompactTextString(m) } func (*ACLState) ProtoMessage() {} func (*ACLState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{3} + return fileDescriptor_14abe0d1b4206d54, []int{6} } func (m *ACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,7 +538,7 @@ type ACLUserState struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` IsConfirmed bool `protobuf:"varint,5,opt,name=isConfirmed,proto3" json:"isConfirmed,omitempty"` } @@ -391,7 +546,7 @@ func (m *ACLUserState) Reset() { *m = ACLUserState{} } func (m *ACLUserState) String() string { return proto.CompactTextString(m) } func (*ACLUserState) ProtoMessage() {} func (*ACLUserState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{4} + return fileDescriptor_14abe0d1b4206d54, []int{7} } func (m *ACLUserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,19 +610,18 @@ func (m *ACLUserState) GetIsConfirmed() bool { return false } -// we already know identity and encryptionKey type ACLUserAdd struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` } func (m *ACLUserAdd) Reset() { *m = ACLUserAdd{} } func (m *ACLUserAdd) String() string { return proto.CompactTextString(m) } func (*ACLUserAdd) ProtoMessage() {} func (*ACLUserAdd) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{5} + return fileDescriptor_14abe0d1b4206d54, []int{8} } func (m *ACLUserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -524,64 +678,11 @@ func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } -// TODO: this is not used as of now -type ACLUserConfirm struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` -} - -func (m *ACLUserConfirm) Reset() { *m = ACLUserConfirm{} } -func (m *ACLUserConfirm) String() string { return proto.CompactTextString(m) } -func (*ACLUserConfirm) ProtoMessage() {} -func (*ACLUserConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{6} -} -func (m *ACLUserConfirm) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLUserConfirm.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 *ACLUserConfirm) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLUserConfirm.Merge(m, src) -} -func (m *ACLUserConfirm) XXX_Size() int { - return m.Size() -} -func (m *ACLUserConfirm) XXX_DiscardUnknown() { - xxx_messageInfo_ACLUserConfirm.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLUserConfirm proto.InternalMessageInfo - -func (m *ACLUserConfirm) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *ACLUserConfirm) GetUserAddId() string { - if m != nil { - return m.UserAddId - } - return "" -} - type ACLUserInvite struct { AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` InviteId string `protobuf:"bytes,5,opt,name=inviteId,proto3" json:"inviteId,omitempty"` } @@ -589,7 +690,7 @@ func (m *ACLUserInvite) Reset() { *m = ACLUserInvite{} } func (m *ACLUserInvite) String() string { return proto.CompactTextString(m) } func (*ACLUserInvite) ProtoMessage() {} func (*ACLUserInvite) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{7} + return fileDescriptor_14abe0d1b4206d54, []int{9} } func (m *ACLUserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -657,7 +758,7 @@ type ACLUserJoin struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` - UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"` + InviteId string `protobuf:"bytes,4,opt,name=inviteId,proto3" json:"inviteId,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` } @@ -665,7 +766,7 @@ func (m *ACLUserJoin) Reset() { *m = ACLUserJoin{} } func (m *ACLUserJoin) String() string { return proto.CompactTextString(m) } func (*ACLUserJoin) ProtoMessage() {} func (*ACLUserJoin) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{8} + return fileDescriptor_14abe0d1b4206d54, []int{10} } func (m *ACLUserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -715,9 +816,9 @@ func (m *ACLUserJoin) GetAcceptSignature() []byte { return nil } -func (m *ACLUserJoin) GetUserInviteId() string { +func (m *ACLUserJoin) GetInviteId() string { if m != nil { - return m.UserInviteId + return m.InviteId } return "" } @@ -738,7 +839,7 @@ func (m *ACLUserRemove) Reset() { *m = ACLUserRemove{} } func (m *ACLUserRemove) String() string { return proto.CompactTextString(m) } func (*ACLUserRemove) ProtoMessage() {} func (*ACLUserRemove) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{9} + return fileDescriptor_14abe0d1b4206d54, []int{11} } func (m *ACLUserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -791,7 +892,7 @@ func (m *ACLReadKeyReplace) Reset() { *m = ACLReadKeyReplace{} } func (m *ACLReadKeyReplace) String() string { return proto.CompactTextString(m) } func (*ACLReadKeyReplace) ProtoMessage() {} func (*ACLReadKeyReplace) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{10} + return fileDescriptor_14abe0d1b4206d54, []int{12} } func (m *ACLReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -843,14 +944,14 @@ func (m *ACLReadKeyReplace) GetEncryptedReadKey() []byte { type ACLUserPermissionChange struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` } func (m *ACLUserPermissionChange) Reset() { *m = ACLUserPermissionChange{} } func (m *ACLUserPermissionChange) String() string { return proto.CompactTextString(m) } func (*ACLUserPermissionChange) ProtoMessage() {} func (*ACLUserPermissionChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{11} + return fileDescriptor_14abe0d1b4206d54, []int{13} } func (m *ACLUserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,512 +994,85 @@ func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } -type ACLRecord struct { - PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (m *ACLRecord) Reset() { *m = ACLRecord{} } -func (m *ACLRecord) String() string { return proto.CompactTextString(m) } -func (*ACLRecord) ProtoMessage() {} -func (*ACLRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{12} -} -func (m *ACLRecord) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLRecord.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 *ACLRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLRecord.Merge(m, src) -} -func (m *ACLRecord) XXX_Size() int { - return m.Size() -} -func (m *ACLRecord) XXX_DiscardUnknown() { - xxx_messageInfo_ACLRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLRecord proto.InternalMessageInfo - -func (m *ACLRecord) GetPrevId() string { - if m != nil { - return m.PrevId - } - return "" -} - -func (m *ACLRecord) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *ACLRecord) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func (m *ACLRecord) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *ACLRecord) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -type ACLHeader struct { - FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` -} - -func (m *ACLHeader) Reset() { *m = ACLHeader{} } -func (m *ACLHeader) String() string { return proto.CompactTextString(m) } -func (*ACLHeader) ProtoMessage() {} -func (*ACLHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{13} -} -func (m *ACLHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLHeader.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 *ACLHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLHeader.Merge(m, src) -} -func (m *ACLHeader) XXX_Size() int { - return m.Size() -} -func (m *ACLHeader) XXX_DiscardUnknown() { - xxx_messageInfo_ACLHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLHeader proto.InternalMessageInfo - -func (m *ACLHeader) GetFirstId() string { - if m != nil { - return m.FirstId - } - return "" -} - -func (m *ACLHeader) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -type RawTreeChange struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (m *RawTreeChange) Reset() { *m = RawTreeChange{} } -func (m *RawTreeChange) String() string { return proto.CompactTextString(m) } -func (*RawTreeChange) ProtoMessage() {} -func (*RawTreeChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{14} -} -func (m *RawTreeChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RawTreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RawTreeChange.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 *RawTreeChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawTreeChange.Merge(m, src) -} -func (m *RawTreeChange) XXX_Size() int { - return m.Size() -} -func (m *RawTreeChange) XXX_DiscardUnknown() { - xxx_messageInfo_RawTreeChange.DiscardUnknown(m) -} - -var xxx_messageInfo_RawTreeChange proto.InternalMessageInfo - -func (m *RawTreeChange) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -func (m *RawTreeChange) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type RawTreeChangeWithId struct { - RawChange []byte `protobuf:"bytes,1,opt,name=rawChange,proto3" json:"rawChange,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *RawTreeChangeWithId) Reset() { *m = RawTreeChangeWithId{} } -func (m *RawTreeChangeWithId) String() string { return proto.CompactTextString(m) } -func (*RawTreeChangeWithId) ProtoMessage() {} -func (*RawTreeChangeWithId) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{15} -} -func (m *RawTreeChangeWithId) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RawTreeChangeWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RawTreeChangeWithId.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 *RawTreeChangeWithId) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawTreeChangeWithId.Merge(m, src) -} -func (m *RawTreeChangeWithId) XXX_Size() int { - return m.Size() -} -func (m *RawTreeChangeWithId) XXX_DiscardUnknown() { - xxx_messageInfo_RawTreeChangeWithId.DiscardUnknown(m) -} - -var xxx_messageInfo_RawTreeChangeWithId proto.InternalMessageInfo - -func (m *RawTreeChangeWithId) GetRawChange() []byte { - if m != nil { - return m.RawChange - } - return nil -} - -func (m *RawTreeChangeWithId) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -type TreeChange struct { - TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` - AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` - SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` - ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` - IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` -} - -func (m *TreeChange) Reset() { *m = TreeChange{} } -func (m *TreeChange) String() string { return proto.CompactTextString(m) } -func (*TreeChange) ProtoMessage() {} -func (*TreeChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{16} -} -func (m *TreeChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TreeChange.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 *TreeChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_TreeChange.Merge(m, src) -} -func (m *TreeChange) XXX_Size() int { - return m.Size() -} -func (m *TreeChange) XXX_DiscardUnknown() { - xxx_messageInfo_TreeChange.DiscardUnknown(m) -} - -var xxx_messageInfo_TreeChange proto.InternalMessageInfo - -func (m *TreeChange) GetTreeHeadIds() []string { - if m != nil { - return m.TreeHeadIds - } - return nil -} - -func (m *TreeChange) GetAclHeadId() string { - if m != nil { - return m.AclHeadId - } - return "" -} - -func (m *TreeChange) GetSnapshotBaseId() string { - if m != nil { - return m.SnapshotBaseId - } - return "" -} - -func (m *TreeChange) GetChangesData() []byte { - if m != nil { - return m.ChangesData - } - return nil -} - -func (m *TreeChange) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *TreeChange) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *TreeChange) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *TreeChange) GetIsSnapshot() bool { - if m != nil { - return m.IsSnapshot - } - return false -} - -type TreeHeader struct { - FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - AclId string `protobuf:"bytes,2,opt,name=aclId,proto3" json:"aclId,omitempty"` - TreeHeaderType TreeHeaderType `protobuf:"varint,3,opt,name=treeHeaderType,proto3,enum=acl.TreeHeaderType" json:"treeHeaderType,omitempty"` - Identity []byte `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` - Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *TreeHeader) Reset() { *m = TreeHeader{} } -func (m *TreeHeader) String() string { return proto.CompactTextString(m) } -func (*TreeHeader) ProtoMessage() {} -func (*TreeHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{17} -} -func (m *TreeHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TreeHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TreeHeader.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 *TreeHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_TreeHeader.Merge(m, src) -} -func (m *TreeHeader) XXX_Size() int { - return m.Size() -} -func (m *TreeHeader) XXX_DiscardUnknown() { - xxx_messageInfo_TreeHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_TreeHeader proto.InternalMessageInfo - -func (m *TreeHeader) GetFirstId() string { - if m != nil { - return m.FirstId - } - return "" -} - -func (m *TreeHeader) GetAclId() string { - if m != nil { - return m.AclId - } - return "" -} - -func (m *TreeHeader) GetTreeHeaderType() TreeHeaderType { - if m != nil { - return m.TreeHeaderType - } - return TreeHeaderType_Object -} - -func (m *TreeHeader) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *TreeHeader) GetData() []byte { - if m != nil { - return m.Data - } - return nil +func init() { + proto.RegisterEnum("aclrecord.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) + proto.RegisterType((*RawACLRecord)(nil), "aclrecord.RawACLRecord") + proto.RegisterType((*RawACLRecordWithId)(nil), "aclrecord.RawACLRecordWithId") + proto.RegisterType((*ACLRecord)(nil), "aclrecord.ACLRecord") + proto.RegisterType((*ACLRoot)(nil), "aclrecord.ACLRoot") + proto.RegisterType((*ACLContentValue)(nil), "aclrecord.ACLContentValue") + proto.RegisterType((*ACLData)(nil), "aclrecord.ACLData") + proto.RegisterType((*ACLState)(nil), "aclrecord.ACLState") + proto.RegisterMapType((map[string]*ACLUserInvite)(nil), "aclrecord.ACLState.InvitesEntry") + proto.RegisterType((*ACLUserState)(nil), "aclrecord.ACLUserState") + proto.RegisterType((*ACLUserAdd)(nil), "aclrecord.ACLUserAdd") + proto.RegisterType((*ACLUserInvite)(nil), "aclrecord.ACLUserInvite") + proto.RegisterType((*ACLUserJoin)(nil), "aclrecord.ACLUserJoin") + proto.RegisterType((*ACLUserRemove)(nil), "aclrecord.ACLUserRemove") + proto.RegisterType((*ACLReadKeyReplace)(nil), "aclrecord.ACLReadKeyReplace") + proto.RegisterType((*ACLUserPermissionChange)(nil), "aclrecord.ACLUserPermissionChange") } func init() { - proto.RegisterEnum("acl.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) - proto.RegisterEnum("acl.TreeHeaderType", TreeHeaderType_name, TreeHeaderType_value) - proto.RegisterType((*RawACLRecord)(nil), "acl.RawACLRecord") - proto.RegisterType((*ACLContentValue)(nil), "acl.ACLContentValue") - proto.RegisterType((*ACLData)(nil), "acl.ACLData") - proto.RegisterType((*ACLState)(nil), "acl.ACLState") - proto.RegisterMapType((map[string]*ACLUserInvite)(nil), "acl.ACLState.InvitesEntry") - proto.RegisterType((*ACLUserState)(nil), "acl.ACLUserState") - proto.RegisterType((*ACLUserAdd)(nil), "acl.ACLUserAdd") - proto.RegisterType((*ACLUserConfirm)(nil), "acl.ACLUserConfirm") - proto.RegisterType((*ACLUserInvite)(nil), "acl.ACLUserInvite") - proto.RegisterType((*ACLUserJoin)(nil), "acl.ACLUserJoin") - proto.RegisterType((*ACLUserRemove)(nil), "acl.ACLUserRemove") - proto.RegisterType((*ACLReadKeyReplace)(nil), "acl.ACLReadKeyReplace") - proto.RegisterType((*ACLUserPermissionChange)(nil), "acl.ACLUserPermissionChange") - proto.RegisterType((*ACLRecord)(nil), "acl.ACLRecord") - proto.RegisterType((*ACLHeader)(nil), "acl.ACLHeader") - proto.RegisterType((*RawTreeChange)(nil), "acl.RawTreeChange") - proto.RegisterType((*RawTreeChangeWithId)(nil), "acl.RawTreeChangeWithId") - proto.RegisterType((*TreeChange)(nil), "acl.TreeChange") - proto.RegisterType((*TreeHeader)(nil), "acl.TreeHeader") + proto.RegisterFile("pkg/acl/aclrecordproto/protos/aclrecord.proto", fileDescriptor_14abe0d1b4206d54) } -func init() { - proto.RegisterFile("pkg/acl/aclchanges/aclpb/protos/aclchanges.proto", fileDescriptor_37a022c841a51877) -} - -var fileDescriptor_37a022c841a51877 = []byte{ - // 1078 bytes of a gzipped FileDescriptorProto +var fileDescriptor_14abe0d1b4206d54 = []byte{ + // 862 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x8a, 0x46, - 0x08, 0xa2, 0x80, 0xbc, 0x60, 0x56, 0xe2, 0xef, 0x00, 0x8e, 0x17, 0x61, 0x6f, 0x22, 0x58, 0x75, - 0xc2, 0xae, 0xc4, 0xad, 0x33, 0xd3, 0x9b, 0x34, 0x6b, 0xcf, 0x8c, 0xa6, 0x3b, 0x89, 0x7c, 0xe4, - 0x0d, 0x78, 0x04, 0x38, 0xf2, 0x04, 0xbc, 0x02, 0x12, 0x97, 0x3d, 0x22, 0x71, 0x41, 0xc9, 0x09, - 0x4e, 0x3c, 0x02, 0xea, 0x9f, 0x99, 0xe9, 0xb1, 0x93, 0xf0, 0xa3, 0x15, 0xd2, 0x1e, 0x46, 0xea, - 0xfe, 0xaa, 0xaa, 0xbb, 0xea, 0xab, 0x9a, 0xea, 0x82, 0xb7, 0x93, 0xe7, 0x27, 0xf7, 0x49, 0x30, - 0x91, 0x5f, 0x70, 0x4a, 0xa2, 0x13, 0xca, 0xe5, 0x32, 0x39, 0xbe, 0x9f, 0xa4, 0xb1, 0x88, 0xb9, - 0x85, 0xf7, 0x14, 0x82, 0xaa, 0x24, 0x98, 0xf8, 0x4f, 0xa0, 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24, 0xc6, 0xf3, - 0xea, 0xfe, 0x37, 0x0e, 0xac, 0x2f, 0xa8, 0xbd, 0x04, 0x0a, 0x8b, 0x2a, 0xca, 0x63, 0x33, 0x1c, - 0x2e, 0xe0, 0x7e, 0x02, 0xf7, 0x6e, 0x78, 0x99, 0x6e, 0x75, 0x64, 0xae, 0x9c, 0xdc, 0x7f, 0xf1, - 0xaf, 0x7d, 0xef, 0x40, 0xa3, 0x78, 0xf9, 0xef, 0xc2, 0x72, 0x92, 0xd2, 0xf3, 0x71, 0x68, 0x9a, - 0xaa, 0xd9, 0x95, 0x2e, 0x77, 0xe7, 0x2e, 0x47, 0xb0, 0x14, 0x12, 0x41, 0x4c, 0x4c, 0x6a, 0x8d, - 0x7a, 0x80, 0x82, 0xb3, 0x34, 0xa5, 0x91, 0xc0, 0xc5, 0x53, 0xa1, 0x4a, 0x62, 0x09, 0x5f, 0x23, - 0x91, 0xff, 0xb0, 0x60, 0x53, 0xca, 0x05, 0x99, 0x26, 0xaa, 0xaa, 0xab, 0xb8, 0x00, 0xfc, 0x81, - 0x72, 0x71, 0x44, 0x49, 0x48, 0x53, 0x39, 0x9c, 0x3c, 0x63, 0x29, 0x17, 0xb9, 0x8f, 0xd9, 0xf6, - 0x36, 0x27, 0xfd, 0xcf, 0x60, 0x15, 0x93, 0x8b, 0xa3, 0x94, 0x52, 0x43, 0xe7, 0x7f, 0x9c, 0x71, - 0xfc, 0x21, 0xdc, 0x29, 0x1d, 0xf4, 0x94, 0x89, 0xd3, 0xb1, 0x32, 0x4a, 0xc9, 0x85, 0x19, 0x34, - 0xf4, 0x81, 0x05, 0x60, 0x06, 0x23, 0x37, 0x1f, 0x8c, 0xbe, 0x73, 0x01, 0x2c, 0x5f, 0xb6, 0xa1, - 0x29, 0x52, 0x4a, 0x65, 0x80, 0xe3, 0x50, 0x3f, 0xb2, 0x0d, 0x6c, 0x43, 0xf2, 0x78, 0x12, 0x4c, - 0xf4, 0x2e, 0xeb, 0x71, 0x39, 0x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x68, 0xef, 0x16, 0x89, 0x3c, 0x99, 0x9f, 0x5b, 0xba, 0x87, 0x77, 0xb5, 0xf1, 0x02, 0x0e, + 0xd3, 0x2d, 0x43, 0x58, 0x3c, 0xa7, 0x7e, 0xbe, 0x23, 0x1e, 0x55, 0x35, 0x25, 0x15, 0x10, 0xd9, + 0x4c, 0xf2, 0x7e, 0x40, 0xf0, 0xa0, 0x06, 0xbb, 0x03, 0x01, 0xb7, 0x5d, 0x8f, 0xcd, 0xed, 0xd7, + 0xa3, 0xb7, 0x82, 0x87, 0xb7, 0x5c, 0x24, 0x3b, 0x89, 0x6c, 0x8c, 0x94, 0xf5, 0x6f, 0x47, 0xea, + 0xf1, 0x53, 0xc0, 0x75, 0x08, 0xb6, 0x61, 0x6f, 0x1c, 0x2c, 0x78, 0xd8, 0x6d, 0x60, 0x80, 0xfd, + 0x57, 0x82, 0x2b, 0x26, 0xba, 0x48, 0x3f, 0x6b, 0xbe, 0x4c, 0x74, 0xad, 0x67, 0x1f, 0xfc, 0x7a, + 0xdd, 0x43, 0x57, 0xd7, 0x3d, 0xf4, 0xc7, 0x75, 0x0f, 0xfd, 0x78, 0xd3, 0x6b, 0x5c, 0xdd, 0xf4, + 0x1a, 0xbf, 0xdf, 0xf4, 0x1a, 0xdf, 0x1e, 0x6d, 0xff, 0x8d, 0xf7, 0x7a, 0xdf, 0x7c, 0x7c, 0xf4, + 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x89, 0xed, 0xeb, 0x04, 0x0a, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -1421,24 +1095,166 @@ func (m *RawACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x1a - } if len(m.Signature) > 0 { i -= len(m.Signature) copy(dAtA[i:], m.Signature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Signature))) i-- dAtA[i] = 0x12 } if len(m.Payload) > 0 { i -= len(m.Payload) copy(dAtA[i:], m.Payload) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawACLRecordWithId) 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 *RawACLRecordWithId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawACLRecordWithId) 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 = encodeVarintAclrecord(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ACLRecord) 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 *ACLRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x28 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x20 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.PrevId) > 0 { + i -= len(m.PrevId) + copy(dAtA[i:], m.PrevId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.PrevId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ACLRoot) 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 *ACLRoot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DerivationScheme) > 0 { + i -= len(m.DerivationScheme) + copy(dAtA[i:], m.DerivationScheme) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.DerivationScheme))) + i-- + dAtA[i] = 0x2a + } + if len(m.EncryptedReadKey) > 0 { + i -= len(m.EncryptedReadKey) + copy(dAtA[i:], m.EncryptedReadKey) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKey))) + i-- + dAtA[i] = 0x22 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x1a + } + if len(m.EncryptionKey) > 0 { + i -= len(m.EncryptionKey) + copy(dAtA[i:], m.EncryptionKey) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1491,7 +1307,7 @@ func (m *ACLContentValue_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -1512,7 +1328,7 @@ func (m *ACLContentValue_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, err return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -1533,7 +1349,7 @@ func (m *ACLContentValue_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -1554,7 +1370,7 @@ func (m *ACLContentValue_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, err return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x22 @@ -1575,34 +1391,13 @@ func (m *ACLContentValue_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a } return len(dAtA) - i, nil } -func (m *ACLContentValue_UserConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLContentValue_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.UserConfirm != nil { - { - size, err := m.UserConfirm.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} func (m *ACLData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1631,7 +1426,7 @@ func (m *ACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -1671,17 +1466,17 @@ func (m *ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } i -= len(k) copy(dAtA[i:], k) - i = encodeVarintAclchanges(dAtA, i, uint64(len(k))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(k))) i-- dAtA[i] = 0xa - i = encodeVarintAclchanges(dAtA, i, uint64(baseI-i)) + i = encodeVarintAclrecord(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0x1a } @@ -1694,27 +1489,27 @@ func (m *ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } } if len(m.ReadKeyHashes) > 0 { - dAtA9 := make([]byte, len(m.ReadKeyHashes)*10) - var j8 int + dAtA8 := make([]byte, len(m.ReadKeyHashes)*10) + var j7 int for _, num := range m.ReadKeyHashes { for num >= 1<<7 { - dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j8++ + j7++ } - dAtA9[j8] = uint8(num) - j8++ + dAtA8[j7] = uint8(num) + j7++ } - i -= j8 - copy(dAtA[i:], dAtA9[:j8]) - i = encodeVarintAclchanges(dAtA, i, uint64(j8)) + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintAclrecord(dAtA, i, uint64(j7)) i-- dAtA[i] = 0xa } @@ -1752,7 +1547,7 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x28 } if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1760,7 +1555,7 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1768,14 +1563,14 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1803,7 +1598,7 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1811,7 +1606,7 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1819,51 +1614,14 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLUserConfirm) 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 *ACLUserConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.UserAddId) > 0 { - i -= len(m.UserAddId) - copy(dAtA[i:], m.UserAddId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserAddId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1893,12 +1651,12 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.InviteId) > 0 { i -= len(m.InviteId) copy(dAtA[i:], m.InviteId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.InviteId))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) i-- dAtA[i] = 0x2a } if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1906,7 +1664,7 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1914,14 +1672,14 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptPublicKey) > 0 { i -= len(m.EncryptPublicKey) copy(dAtA[i:], m.EncryptPublicKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptPublicKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptPublicKey))) i-- dAtA[i] = 0x12 } if len(m.AcceptPublicKey) > 0 { i -= len(m.AcceptPublicKey) copy(dAtA[i:], m.AcceptPublicKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AcceptPublicKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptPublicKey))) i-- dAtA[i] = 0xa } @@ -1952,36 +1710,36 @@ func (m *ACLUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x2a } } - if len(m.UserInviteId) > 0 { - i -= len(m.UserInviteId) - copy(dAtA[i:], m.UserInviteId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserInviteId))) + if len(m.InviteId) > 0 { + i -= len(m.InviteId) + copy(dAtA[i:], m.InviteId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) i-- dAtA[i] = 0x22 } if len(m.AcceptSignature) > 0 { i -= len(m.AcceptSignature) copy(dAtA[i:], m.AcceptSignature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AcceptSignature))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptSignature))) i-- dAtA[i] = 0x1a } if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2016,7 +1774,7 @@ func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -2025,7 +1783,7 @@ func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2055,21 +1813,21 @@ func (m *ACLReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptedReadKey) > 0 { i -= len(m.EncryptedReadKey) copy(dAtA[i:], m.EncryptedReadKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKey))) i-- dAtA[i] = 0x1a } if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2097,323 +1855,22 @@ func (m *ACLUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x10 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ACLRecord) 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 *ACLRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x28 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x20 - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x1a - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x12 - } - if len(m.PrevId) > 0 { - i -= len(m.PrevId) - copy(dAtA[i:], m.PrevId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.PrevId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLHeader) 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 *ACLHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x12 - } - if len(m.FirstId) > 0 { - i -= len(m.FirstId) - copy(dAtA[i:], m.FirstId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.FirstId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RawTreeChange) 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 *RawTreeChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RawTreeChange) 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 = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RawTreeChangeWithId) 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 *RawTreeChangeWithId) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RawTreeChangeWithId) 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 = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x12 - } - if len(m.RawChange) > 0 { - i -= len(m.RawChange) - copy(dAtA[i:], m.RawChange) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.RawChange))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *TreeChange) 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 *TreeChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsSnapshot { - i-- - if m.IsSnapshot { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x3a - } - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x30 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x28 - } - if len(m.ChangesData) > 0 { - i -= len(m.ChangesData) - copy(dAtA[i:], m.ChangesData) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.ChangesData))) - i-- - dAtA[i] = 0x22 - } - if len(m.SnapshotBaseId) > 0 { - i -= len(m.SnapshotBaseId) - copy(dAtA[i:], m.SnapshotBaseId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.SnapshotBaseId))) - i-- - dAtA[i] = 0x1a - } - if len(m.AclHeadId) > 0 { - i -= len(m.AclHeadId) - copy(dAtA[i:], m.AclHeadId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclHeadId))) - i-- - dAtA[i] = 0x12 - } - if len(m.TreeHeadIds) > 0 { - for iNdEx := len(m.TreeHeadIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.TreeHeadIds[iNdEx]) - copy(dAtA[i:], m.TreeHeadIds[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.TreeHeadIds[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *TreeHeader) 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 *TreeHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TreeHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x2a - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x22 - } - if m.TreeHeaderType != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.TreeHeaderType)) - i-- - dAtA[i] = 0x18 - } - if len(m.AclId) > 0 { - i -= len(m.AclId) - copy(dAtA[i:], m.AclId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclId))) - i-- - dAtA[i] = 0x12 - } - if len(m.FirstId) > 0 { - i -= len(m.FirstId) - copy(dAtA[i:], m.FirstId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.FirstId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAclchanges(dAtA []byte, offset int, v uint64) int { - offset -= sovAclchanges(v) +func encodeVarintAclrecord(dAtA []byte, offset int, v uint64) int { + offset -= sovAclrecord(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -2431,15 +1888,84 @@ func (m *RawACLRecord) Size() (n int) { _ = l l = len(m.Payload) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.Signature) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} + +func (m *RawACLRecordWithId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.Id) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} + +func (m *ACLRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PrevId) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovAclrecord(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovAclrecord(uint64(m.Timestamp)) + } + return n +} + +func (m *ACLRoot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.EncryptionKey) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.EncryptedReadKey) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.DerivationScheme) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2464,7 +1990,7 @@ func (m *ACLContentValue_UserAdd) Size() (n int) { _ = l if m.UserAdd != nil { l = m.UserAdd.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2476,7 +2002,7 @@ func (m *ACLContentValue_UserRemove) Size() (n int) { _ = l if m.UserRemove != nil { l = m.UserRemove.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2488,7 +2014,7 @@ func (m *ACLContentValue_UserPermissionChange) Size() (n int) { _ = l if m.UserPermissionChange != nil { l = m.UserPermissionChange.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2500,7 +2026,7 @@ func (m *ACLContentValue_UserInvite) Size() (n int) { _ = l if m.UserInvite != nil { l = m.UserInvite.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2512,19 +2038,7 @@ func (m *ACLContentValue_UserJoin) Size() (n int) { _ = l if m.UserJoin != nil { l = m.UserJoin.Size() - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} -func (m *ACLContentValue_UserConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UserConfirm != nil { - l = m.UserConfirm.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2537,7 +2051,7 @@ func (m *ACLData) Size() (n int) { if len(m.AclContent) > 0 { for _, e := range m.AclContent { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2552,14 +2066,14 @@ func (m *ACLState) Size() (n int) { if len(m.ReadKeyHashes) > 0 { l = 0 for _, e := range m.ReadKeyHashes { - l += sovAclchanges(uint64(e)) + l += sovAclrecord(uint64(e)) } - n += 1 + sovAclchanges(uint64(l)) + l + n += 1 + sovAclrecord(uint64(l)) + l } if len(m.UserStates) > 0 { for _, e := range m.UserStates { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if len(m.Invites) > 0 { @@ -2569,10 +2083,10 @@ func (m *ACLState) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovAclchanges(uint64(l)) + l += 1 + sovAclrecord(uint64(l)) } - mapEntrySize := 1 + len(k) + sovAclchanges(uint64(len(k))) + l - n += mapEntrySize + 1 + sovAclchanges(uint64(mapEntrySize)) + mapEntrySize := 1 + len(k) + sovAclrecord(uint64(len(k))) + l + n += mapEntrySize + 1 + sovAclrecord(uint64(mapEntrySize)) } } return n @@ -2586,20 +2100,20 @@ func (m *ACLUserState) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } if m.IsConfirmed { n += 2 @@ -2615,37 +2129,20 @@ func (m *ACLUserAdd) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) - } - return n -} - -func (m *ACLUserConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.UserAddId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } return n } @@ -2658,24 +2155,24 @@ func (m *ACLUserInvite) Size() (n int) { _ = l l = len(m.AcceptPublicKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptPublicKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } l = len(m.InviteId) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2688,24 +2185,24 @@ func (m *ACLUserJoin) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.AcceptSignature) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } - l = len(m.UserInviteId) + l = len(m.InviteId) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2719,12 +2216,12 @@ func (m *ACLUserRemove) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.ReadKeyReplaces) > 0 { for _, e := range m.ReadKeyReplaces { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2738,15 +2235,15 @@ func (m *ACLReadKeyReplace) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptedReadKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2759,165 +2256,19 @@ func (m *ACLUserPermissionChange) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } return n } -func (m *ACLRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PrevId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - return n -} - -func (m *ACLHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FirstId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *RawTreeChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *RawTreeChangeWithId) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RawChange) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Id) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *TreeChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.TreeHeadIds) > 0 { - for _, s := range m.TreeHeadIds { - l = len(s) - n += 1 + l + sovAclchanges(uint64(l)) - } - } - l = len(m.AclHeadId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.SnapshotBaseId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.ChangesData) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.IsSnapshot { - n += 2 - } - return n -} - -func (m *TreeHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FirstId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.AclId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.TreeHeaderType != 0 { - n += 1 + sovAclchanges(uint64(m.TreeHeaderType)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func sovAclchanges(x uint64) (n int) { +func sovAclrecord(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozAclchanges(x uint64) (n int) { - return sovAclchanges(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozAclrecord(x uint64) (n int) { + return sovAclrecord(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *RawACLRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -2927,7 +2278,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2955,7 +2306,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2968,11 +2319,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -2989,7 +2340,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -3002,11 +2353,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -3016,14 +2367,98 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { m.Signature = []byte{} } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawACLRecordWithId) 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 ErrIntOverflowAclrecord + } + 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: RawACLRecordWithId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawACLRecordWithId: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []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 ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -3037,11 +2472,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -3050,1909 +2485,12 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLContentValue) 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 ErrIntOverflowAclchanges - } - 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: ACLContentValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLContentValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAdd", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserAdd{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserAdd{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserRemove", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserRemove{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserRemove{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserPermissionChange", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserPermissionChange{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserPermissionChange{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserInvite", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserInvite{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserInvite{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserJoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserJoin{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserJoin{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserConfirm", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserConfirm{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserConfirm{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLData) 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 ErrIntOverflowAclchanges - } - 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: ACLData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclContent", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclContent = append(m.AclContent, &ACLContentValue{}) - if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLState) 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 ErrIntOverflowAclchanges - } - 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: ACLState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReadKeyHashes = append(m.ReadKeyHashes, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.ReadKeyHashes) == 0 { - m.ReadKeyHashes = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReadKeyHashes = append(m.ReadKeyHashes, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyHashes", wireType) - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserStates", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserStates = append(m.UserStates, &ACLUserState{}) - if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Invites", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Invites == nil { - m.Invites = make(map[string]*ACLUserInvite) - } - var mapkey string - var mapvalue *ACLUserInvite - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthAclchanges - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthAclchanges - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthAclchanges - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &ACLUserInvite{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Invites[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserState) 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 ErrIntOverflowAclchanges - } - 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: ACLUserState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsConfirmed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsConfirmed = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserAdd) 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 ErrIntOverflowAclchanges - } - 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: ACLUserAdd: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserAdd: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserConfirm) 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 ErrIntOverflowAclchanges - } - 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: ACLUserConfirm: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserConfirm: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAddId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserAddId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserInvite) 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 ErrIntOverflowAclchanges - } - 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: ACLUserInvite: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserInvite: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcceptPublicKey = append(m.AcceptPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.AcceptPublicKey == nil { - m.AcceptPublicKey = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptPublicKey = append(m.EncryptPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptPublicKey == nil { - m.EncryptPublicKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.InviteId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserJoin) 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 ErrIntOverflowAclchanges - } - 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: ACLUserJoin: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserJoin: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptSignature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcceptSignature = append(m.AcceptSignature[:0], dAtA[iNdEx:postIndex]...) - if m.AcceptSignature == nil { - m.AcceptSignature = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserInviteId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserInviteId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserRemove) 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 ErrIntOverflowAclchanges - } - 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: ACLUserRemove: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserRemove: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyReplaces", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLReadKeyReplace{}) - if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLReadKeyReplace) 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 ErrIntOverflowAclchanges - } - 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: ACLReadKeyReplace: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptedReadKey == nil { - m.EncryptedReadKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserPermissionChange) 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 ErrIntOverflowAclchanges - } - 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: ACLUserPermissionChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -4974,7 +2512,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5002,7 +2540,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5016,11 +2554,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5034,7 +2572,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5047,11 +2585,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5068,7 +2606,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5081,11 +2619,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5102,7 +2640,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { m.CurrentReadKeyHash = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5121,7 +2659,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { m.Timestamp = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5135,12 +2673,12 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5154,7 +2692,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLHeader) Unmarshal(dAtA []byte) error { +func (m *ACLRoot) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5162,7 +2700,7 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5177,52 +2715,20 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ACLHeader: wiretype end group for non-group") + return fmt.Errorf("proto: ACLRoot: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ACLHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLRoot: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FirstId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FirstId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5235,11 +2741,11 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5249,64 +2755,14 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RawTreeChange) 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 ErrIntOverflowAclchanges - } - 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: RawTreeChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawTreeChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5319,292 +2775,28 @@ func (m *RawTreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []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 ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - 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 := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RawTreeChangeWithId) 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 ErrIntOverflowAclchanges - } - 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: RawTreeChangeWithId: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawTreeChangeWithId: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RawChange", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RawChange = append(m.RawChange[:0], dAtA[iNdEx:postIndex]...) - if m.RawChange == nil { - m.RawChange = []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 ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TreeChange) 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 ErrIntOverflowAclchanges - } - 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: TreeChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TreeChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeadIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TreeHeadIds = append(m.TreeHeadIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclHeadId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotBaseId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5618,25 +2810,25 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.SnapshotBaseId = string(dAtA[iNdEx:postIndex]) + m.SpaceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChangesData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5649,66 +2841,708 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChangesData = append(m.ChangesData[:0], dAtA[iNdEx:postIndex]...) - if m.ChangesData == nil { - m.ChangesData = []byte{} + m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptedReadKey == nil { + m.EncryptedReadKey = []byte{} } iNdEx = postIndex case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DerivationScheme", wireType) } - m.CurrentReadKeyHash = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAclrecord } - m.Timestamp = 0 + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DerivationScheme = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLContentValue) 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 ErrIntOverflowAclrecord + } + 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: ACLContentValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLContentValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserAdd", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.Timestamp |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 7: + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserAdd{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserAdd{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserRemove", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserRemove{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserRemove{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserPermissionChange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserPermissionChange{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserPermissionChange{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserInvite", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserInvite{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserInvite{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserJoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserJoin{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserJoin{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLData) 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 ErrIntOverflowAclrecord + } + 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: ACLData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclContent", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclContent = append(m.AclContent, &ACLContentValue{}) + if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLState) 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 ErrIntOverflowAclrecord + } + 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: ACLState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadKeyHashes = append(m.ReadKeyHashes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ReadKeyHashes) == 0 { + m.ReadKeyHashes = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadKeyHashes = append(m.ReadKeyHashes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyHashes", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserStates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserStates = append(m.UserStates, &ACLUserState{}) + if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Invites", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Invites == nil { + m.Invites = make(map[string]*ACLUserInvite) + } + var mapkey string + var mapvalue *ACLUserInvite + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthAclrecord + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthAclrecord + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthAclrecord + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ACLUserInvite{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Invites[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserState) 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 ErrIntOverflowAclrecord + } + 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: ACLUserState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5721,11 +3555,11 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5735,14 +3569,99 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - case 8: + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsSnapshot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsConfirmed", wireType) } var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5754,15 +3673,15 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { break } } - m.IsSnapshot = bool(v != 0) + m.IsConfirmed = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5776,7 +3695,7 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *TreeHeader) Unmarshal(dAtA []byte) error { +func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5784,7 +3703,7 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5799,103 +3718,20 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TreeHeader: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserAdd: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TreeHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserAdd: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FirstId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FirstId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - 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 ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeaderType", wireType) - } - m.TreeHeaderType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TreeHeaderType |= TreeHeaderType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5908,11 +3744,11 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5922,14 +3758,14 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - case 5: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5942,28 +3778,79 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5977,7 +3864,797 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } return nil } -func skipAclchanges(dAtA []byte) (n int, err error) { +func (m *ACLUserInvite) 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 ErrIntOverflowAclrecord + } + 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: ACLUserInvite: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserInvite: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptPublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptPublicKey = append(m.AcceptPublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptPublicKey == nil { + m.AcceptPublicKey = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptPublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptPublicKey = append(m.EncryptPublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptPublicKey == nil { + m.EncryptPublicKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + 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 ErrInvalidLengthAclrecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InviteId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserJoin) 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 ErrIntOverflowAclrecord + } + 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: ACLUserJoin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserJoin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptSignature = append(m.AcceptSignature[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptSignature == nil { + m.AcceptSignature = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + 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 ErrInvalidLengthAclrecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InviteId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserRemove) 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 ErrIntOverflowAclrecord + } + 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: ACLUserRemove: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserRemove: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyReplaces", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLReadKeyReplace{}) + if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLReadKeyReplace) 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 ErrIntOverflowAclrecord + } + 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: ACLReadKeyReplace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptedReadKey == nil { + m.EncryptedReadKey = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserPermissionChange) 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 ErrIntOverflowAclrecord + } + 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: ACLUserPermissionChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAclrecord(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -5985,7 +4662,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6002,7 +4679,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6018,7 +4695,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6031,14 +4708,14 @@ func skipAclchanges(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthAclchanges + return 0, ErrInvalidLengthAclrecord } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAclchanges + return 0, ErrUnexpectedEndOfGroupAclrecord } depth-- case 5: @@ -6047,7 +4724,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthAclchanges + return 0, ErrInvalidLengthAclrecord } if depth == 0 { return iNdEx, nil @@ -6057,7 +4734,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthAclchanges = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAclchanges = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAclchanges = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthAclrecord = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAclrecord = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAclrecord = fmt.Errorf("proto: unexpected end of group") ) diff --git a/pkg/acl/aclrecordproto/protos/aclrecord.proto b/pkg/acl/aclrecordproto/protos/aclrecord.proto new file mode 100644 index 00000000..01b5aa6f --- /dev/null +++ b/pkg/acl/aclrecordproto/protos/aclrecord.proto @@ -0,0 +1,102 @@ +syntax = "proto3"; +package aclrecord; +option go_package = "pkg/acl/aclrecordproto"; + +message RawACLRecord { + bytes payload = 1; + bytes signature = 2; +} + +message RawACLRecordWithId { + bytes payload = 1; + string id = 2; +} + +message ACLRecord { + string prevId = 1; + bytes identity = 2; + bytes data = 3; + uint64 currentReadKeyHash = 4; + int64 timestamp = 5; +} + +message ACLRoot { + bytes identity = 1; + bytes encryptionKey = 2; + string spaceId = 3; + bytes encryptedReadKey = 4; + string derivationScheme = 5; +} + +message ACLContentValue { + oneof value { + ACLUserAdd userAdd = 1; + ACLUserRemove userRemove = 2; + ACLUserPermissionChange userPermissionChange = 3; + ACLUserInvite userInvite = 4; + ACLUserJoin userJoin = 5; + } +} + +message ACLData { + repeated ACLContentValue aclContent = 1; +} + +message ACLState { + repeated uint64 readKeyHashes = 1; + repeated ACLUserState userStates = 2; + map invites = 3; +} + +message ACLUserState { + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; + bool isConfirmed = 5; +} + +message ACLUserAdd { + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; +} + +message ACLUserInvite { + bytes acceptPublicKey = 1; + bytes encryptPublicKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; + string inviteId = 5; +} + +message ACLUserJoin { + bytes identity = 1; + bytes encryptionKey = 2; + bytes acceptSignature = 3; + string inviteId = 4; + repeated bytes encryptedReadKeys = 5; +} + +message ACLUserRemove { + bytes identity = 1; + repeated ACLReadKeyReplace readKeyReplaces = 3; +} + +message ACLReadKeyReplace { + bytes identity = 1; + bytes encryptionKey = 2; + bytes encryptedReadKey = 3; +} + +message ACLUserPermissionChange { + bytes identity = 1; + ACLUserPermissions permissions = 2; +} + +enum ACLUserPermissions { + Admin = 0; + Writer = 1; + Reader = 2; +} diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 91b3bb47..27416972 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" @@ -30,14 +30,14 @@ var ErrInvalidSignature = errors.New("signature is invalid") type UserPermissionPair struct { Identity string - Permission aclpb.ACLUserPermissions + Permission aclrecordproto.ACLUserPermissions } type ACLState struct { currentReadKeyHash uint64 userReadKeys map[uint64]*symmetric.Key - userStates map[string]*aclpb.ACLUserState - userInvites map[string]*aclpb.ACLUserInvite + userStates map[string]*aclrecordproto.ACLUserState + userInvites map[string]*aclrecordproto.ACLUserInvite signingPubKeyDecoder keys.Decoder encryptionKey encryptionkey.PrivKey @@ -56,8 +56,8 @@ func newACLStateWithIdentity( identity: identity, encryptionKey: encryptionKey, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLUserState), - userInvites: make(map[string]*aclpb.ACLUserInvite), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), signingPubKeyDecoder: decoder, permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), @@ -68,8 +68,8 @@ func newACLState(decoder keys.Decoder) *ACLState { return &ACLState{ signingPubKeyDecoder: decoder, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLUserState), - userInvites: make(map[string]*aclpb.ACLUserInvite), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), } @@ -106,8 +106,8 @@ func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermiss return UserPermissionPair{}, ErrNoSuchUser } -func (st *ACLState) applyRecord(record *aclpb.ACLRecord) (err error) { - aclData := &aclpb.ACLData{} +func (st *ACLState) applyRecord(record *aclrecordproto.ACLRecord) (err error) { + aclData := &aclrecordproto.ACLData{} err = proto.Unmarshal(record.Data, aclData) if err != nil { @@ -126,11 +126,11 @@ func (st *ACLState) applyRecord(record *aclpb.ACLRecord) (err error) { func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { var ( change = recordWrapper.Content - aclData = &aclpb.ACLData{} + aclData = &aclrecordproto.ACLData{} ) if recordWrapper.Model != nil { - aclData = recordWrapper.Model.(*aclpb.ACLData) + aclData = recordWrapper.Model.(*aclrecordproto.ACLData) } else { err = proto.Unmarshal(change.Data, aclData) if err != nil { @@ -158,7 +158,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { return nil } -func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity []byte) (err error) { +func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uint64, identity []byte) (err error) { defer func() { if err != nil { return @@ -176,7 +176,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden return } - if !st.hasPermission(identity, aclpb.ACLUserPermissions_Admin) { + if !st.hasPermission(identity, aclrecordproto.ACLUserPermissions_Admin) { err = fmt.Errorf("user %s must have admin permissions", identity) return } @@ -192,7 +192,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden return nil } -func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { +func (st *ACLState) applyChangeContent(ch *aclrecordproto.ACLContentValue) error { switch { case ch.GetUserPermissionChange() != nil: return st.applyUserPermissionChange(ch.GetUserPermissionChange()) @@ -211,7 +211,7 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { } } -func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { +func (st *ACLState) applyUserPermissionChange(ch *aclrecordproto.ACLUserPermissionChange) error { chIdentity := string(ch.Identity) state, exists := st.userStates[chIdentity] if !exists { @@ -222,12 +222,12 @@ func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) return nil } -func (st *ACLState) applyUserInvite(ch *aclpb.ACLUserInvite) error { +func (st *ACLState) applyUserInvite(ch *aclrecordproto.ACLUserInvite) error { st.userInvites[ch.InviteId] = ch return nil } -func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { +func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error { invite, exists := st.userInvites[ch.UserInviteId] if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) @@ -266,7 +266,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { } // adding user to the list - userState := &aclpb.ACLUserState{ + userState := &aclrecordproto.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, EncryptedReadKeys: ch.EncryptedReadKeys, @@ -277,13 +277,13 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { return nil } -func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { +func (st *ACLState) applyUserAdd(ch *aclrecordproto.ACLUserAdd) error { chIdentity := string(ch.Identity) if _, exists := st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } - st.userStates[chIdentity] = &aclpb.ACLUserState{ + st.userStates[chIdentity] = &aclrecordproto.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, @@ -304,7 +304,7 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { return nil } -func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { +func (st *ACLState) applyUserRemove(ch *aclrecordproto.ACLUserRemove) error { chIdentity := string(ch.Identity) if chIdentity == st.identity { return ErrDocumentForbidden @@ -338,7 +338,7 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { return nil } -func (st *ACLState) applyUserConfirm(ch *aclpb.ACLUserConfirm) error { +func (st *ACLState) applyUserConfirm(ch *aclrecordproto.ACLUserConfirm) error { chIdentity := string(ch.Identity) state, exists := st.userStates[chIdentity] if !exists { @@ -365,7 +365,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermissions) bool { +func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto.ACLUserPermissions) bool { state, exists := st.userStates[string(identity)] if !exists { return false @@ -374,17 +374,17 @@ func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermi return state.Permissions == permission } -func (st *ACLState) isUserJoin(data *aclpb.ACLData) bool { +func (st *ACLState) isUserJoin(data *aclrecordproto.ACLData) bool { // if we have a UserJoin, then it should always be the first one applied return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil } -func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity []byte) bool { +func (st *ACLState) isUserAdd(data *aclrecordproto.ACLData, identity []byte) bool { // if we have a UserAdd, then it should always be the first one applied userAdd := data.GetAclContent()[0].GetUserAdd() return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0 } -func (st *ACLState) GetUserStates() map[string]*aclpb.ACLUserState { +func (st *ACLState) GetUserStates() map[string]*aclrecordproto.ACLUserState { return st.userStates } diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go index c6413cb0..f56e5259 100644 --- a/pkg/acl/list/changebuilder.go +++ b/pkg/acl/list/changebuilder.go @@ -2,7 +2,7 @@ package list import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index 3cfedd06..d20d5b69 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" @@ -60,7 +60,7 @@ func BuildACLList(decoder keys.Decoder, storage storage.ListStorage) (ACLList, e } func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStorage) (list ACLList, err error) { - header, err := storage.Header() + header, err := storage.Root() if err != nil { return } diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index fd249cfb..d36cd373 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -1,7 +1,7 @@ package list import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" diff --git a/pkg/acl/list/record.go b/pkg/acl/list/record.go index 1cf10e59..04f4abbf 100644 --- a/pkg/acl/list/record.go +++ b/pkg/acl/list/record.go @@ -1,19 +1,19 @@ package list import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/gogo/protobuf/proto" ) type ACLRecord struct { Id string - Content *aclpb.ACLRecord + Content *aclrecordproto.ACLRecord Identity string Model interface{} Sign []byte } -func NewRecord(id string, aclRecord *aclpb.ACLRecord) *ACLRecord { +func NewRecord(id string, aclRecord *aclrecordproto.ACLRecord) *ACLRecord { return &ACLRecord{ Id: id, Content: aclRecord, @@ -21,17 +21,45 @@ func NewRecord(id string, aclRecord *aclpb.ACLRecord) *ACLRecord { } } -func NewFromRawRecord(rawRec *aclpb.RawACLRecord) (*ACLRecord, error) { - aclRec := &aclpb.ACLRecord{} - err := proto.Unmarshal(rawRec.Payload, aclRec) +func NewFromRawRecord(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { + rawRec := &aclrecordproto.RawACLRecord{} + err = proto.Unmarshal(rawRecWithId.Payload, rawRec) if err != nil { - return nil, err + return + } + + protoAclRec := &aclrecordproto.ACLRecord{} + err = proto.Unmarshal(rawRec.Payload, protoAclRec) + if err != nil { + return } return &ACLRecord{ - Id: rawRec.Id, - Content: aclRec, + Id: rawRecWithId.Id, + Content: protoAclRec, Sign: rawRec.Signature, - Identity: string(aclRec.Identity), + Identity: string(protoAclRec.Identity), }, nil } + +func NewFromRawRoot(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { + rawRec := &aclrecordproto.RawACLRecord{} + err = proto.Unmarshal(rawRecWithId.Payload, rawRec) + if err != nil { + return + } + + protoAclRec := &aclrecordproto.ACLRecord{} + err = proto.Unmarshal(rawRec.Payload, protoAclRec) + if err != nil { + return + } + + return &ACLRecord{ + Id: rawRecWithId.Id, + Content: protoAclRec, + Sign: rawRec.Signature, + Identity: string(protoAclRec.Identity), + }, nil +} + diff --git a/pkg/acl/storage/inmemory.go b/pkg/acl/storage/inmemory.go index 7f6af367..1e200e68 100644 --- a/pkg/acl/storage/inmemory.go +++ b/pkg/acl/storage/inmemory.go @@ -3,44 +3,41 @@ package storage import ( "context" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "sync" ) type inMemoryACLListStorage struct { - header *aclpb.ACLHeader - records []*aclpb.RawACLRecord - - id string + records []*aclrecordproto.RawACLRecordWithId + id string sync.RWMutex } func NewInMemoryACLListStorage( id string, - header *aclpb.ACLHeader, - records []*aclpb.RawACLRecord) (ListStorage, error) { + records []*aclrecordproto.RawACLRecordWithId) (ListStorage, error) { return &inMemoryACLListStorage{ id: id, - header: header, records: records, RWMutex: sync.RWMutex{}, }, nil } -func (i *inMemoryACLListStorage) Header() (*aclpb.ACLHeader, error) { +func (i *inMemoryACLListStorage) Root() (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() - return i.header, nil + return i.records[0], nil } -func (i *inMemoryACLListStorage) Head() (*aclpb.RawACLRecord, error) { +func (i *inMemoryACLListStorage) Head() (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() return i.records[len(i.records)-1], nil } -func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) { +func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() for _, rec := range i.records { @@ -51,7 +48,7 @@ func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (* return nil, fmt.Errorf("no such record") } -func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error { +func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error { panic("implement me") } @@ -63,26 +60,27 @@ func (i *inMemoryACLListStorage) ID() (string, error) { type inMemoryTreeStorage struct { id string - header *aclpb.TreeHeader + root *treechangeproto.RawTreeChangeWithId heads []string - changes map[string]*aclpb.RawTreeChangeWithId + changes map[string]*treechangeproto.RawTreeChangeWithId sync.RWMutex } func NewInMemoryTreeStorage( treeId string, - header *aclpb.TreeHeader, + root *treechangeproto.RawTreeChangeWithId, heads []string, - changes []*aclpb.RawTreeChangeWithId) (TreeStorage, error) { - allChanges := make(map[string]*aclpb.RawTreeChangeWithId) + changes []*treechangeproto.RawTreeChangeWithId) (TreeStorage, error) { + allChanges := make(map[string]*treechangeproto.RawTreeChangeWithId) for _, ch := range changes { allChanges[ch.Id] = ch } + allChanges[treeId] = root return &inMemoryTreeStorage{ id: treeId, - header: header, + root: root, heads: heads, changes: allChanges, RWMutex: sync.RWMutex{}, @@ -95,10 +93,10 @@ func (t *inMemoryTreeStorage) ID() (string, error) { return t.id, nil } -func (t *inMemoryTreeStorage) Header() (*aclpb.TreeHeader, error) { +func (t *inMemoryTreeStorage) Root() (*treechangeproto.RawTreeChangeWithId, error) { t.RLock() defer t.RUnlock() - return t.header, nil + return t.root, nil } func (t *inMemoryTreeStorage) Heads() ([]string, error) { @@ -118,7 +116,7 @@ func (t *inMemoryTreeStorage) SetHeads(heads []string) error { return nil } -func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawTreeChangeWithId) error { +func (t *inMemoryTreeStorage) AddRawChange(change *treechangeproto.RawTreeChangeWithId) error { t.Lock() defer t.Unlock() // TODO: better to do deep copy @@ -126,7 +124,7 @@ func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawTreeChangeWithId) er return nil } -func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*aclpb.RawTreeChangeWithId, error) { +func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*treechangeproto.RawTreeChangeWithId, error) { t.RLock() defer t.RUnlock() if res, exists := t.changes[changeId]; exists { @@ -163,7 +161,7 @@ func (i *inMemoryStorageProvider) Storage(id string) (Storage, error) { func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) { i.Lock() defer i.Unlock() - res, err := NewInMemoryTreeStorage(payload.TreeId, payload.Header, payload.Heads, payload.Changes) + res, err := NewInMemoryTreeStorage(payload.TreeId, payload.RootRawChange, payload.Heads, payload.Changes) if err != nil { return nil, err } @@ -175,7 +173,7 @@ func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePay func (i *inMemoryStorageProvider) CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) { i.Lock() defer i.Unlock() - res, err := NewInMemoryACLListStorage(payload.ListId, payload.Header, payload.Records) + res, err := NewInMemoryACLListStorage(payload.ListId, payload.Records) if err != nil { return nil, err } diff --git a/pkg/acl/storage/liststorage.go b/pkg/acl/storage/liststorage.go index ccb5b5da..c4fe7d6e 100644 --- a/pkg/acl/storage/liststorage.go +++ b/pkg/acl/storage/liststorage.go @@ -2,14 +2,14 @@ package storage import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" ) type ListStorage interface { Storage - Header() (*aclpb.ACLHeader, error) - Head() (*aclpb.RawACLRecord, error) + Root() (*aclrecordproto.RawACLRecordWithId, error) + Head() (*aclrecordproto.RawACLRecordWithId, error) - GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) - AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error + GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) + AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error } diff --git a/pkg/acl/storage/provider.go b/pkg/acl/storage/provider.go index 984b21c4..3c2c7d91 100644 --- a/pkg/acl/storage/provider.go +++ b/pkg/acl/storage/provider.go @@ -2,27 +2,26 @@ package storage import ( "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) var ErrUnknownTreeId = errors.New("tree does not exist") type TreeStorageCreatePayload struct { - TreeId string - Header *aclpb.TreeHeader - Changes []*aclpb.RawTreeChangeWithId - Heads []string + TreeId string + RootRawChange *treechangeproto.RawTreeChangeWithId + Changes []*treechangeproto.RawTreeChangeWithId + Heads []string } type ACLListStorageCreatePayload struct { ListId string - Header *aclpb.ACLHeader - Records []*aclpb.RawACLRecord + Records []*aclrecordproto.RawACLRecordWithId } type Provider interface { Storage(id string) (Storage, error) - AddStorage(id string, st Storage) error CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) } diff --git a/pkg/acl/storage/treestorage.go b/pkg/acl/storage/treestorage.go index 0e7d09a1..a9c98f1d 100644 --- a/pkg/acl/storage/treestorage.go +++ b/pkg/acl/storage/treestorage.go @@ -2,17 +2,17 @@ package storage import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) type TreeStorage interface { Storage - Header() (*aclpb.TreeHeader, error) + Root() (*treechangeproto.RawTreeChangeWithId, error) Heads() ([]string, error) SetHeads(heads []string) error - AddRawChange(change *aclpb.RawTreeChangeWithId) error - GetRawChange(ctx context.Context, recordID string) (*aclpb.RawTreeChangeWithId, error) + AddRawChange(change *treechangeproto.RawTreeChangeWithId) error + GetRawChange(ctx context.Context, id string) (*treechangeproto.RawTreeChangeWithId, error) } type TreeStorageCreatorFunc = func(payload TreeStorageCreatePayload) (TreeStorage, error) diff --git a/pkg/acl/tree/change.go b/pkg/acl/tree/change.go index cefc9327..43e9f654 100644 --- a/pkg/acl/tree/change.go +++ b/pkg/acl/tree/change.go @@ -2,11 +2,7 @@ package tree import ( "errors" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - "github.com/gogo/protobuf/proto" - - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) var ( @@ -14,68 +10,52 @@ var ( ErrIncorrectCID = errors.New("change has incorrect CID") ) -type ChangeContent struct { - ChangesData proto.Marshaler - ACLData *aclpb.ACLData - Id string // TODO: this is just for testing, because id should be created automatically from content -} - // Change is an abstract type for all types of changes type Change struct { - Next []*Change - PreviousIds []string - Id string - SnapshotId string - IsSnapshot bool - DecryptedChange []byte // TODO: check if we need it - ParsedModel interface{} // TODO: check if we need it + Next []*Change + PreviousIds []string + AclHeadId string + Id string + SnapshotId string + IsSnapshot bool + Timestamp int64 + ReadKeyHash uint64 + Identity string + Data []byte + Model interface{} // iterator helpers visited bool branchesFinished bool - Content *aclpb.TreeChange - Identity string - Sign []byte + Signature []byte } -func (ch *Change) ProtoChange() proto.Marshaler { - return ch.Content -} - -func (ch *Change) DecryptContents(key *symmetric.Key) error { - // if the document is already decrypted - if ch.Content.CurrentReadKeyHash == 0 { - return nil - } - decrypted, err := key.Decrypt(ch.Content.ChangesData) - if err != nil { - return fmt.Errorf("failed to decrypt changes data: %w", err) - } - - ch.DecryptedChange = decrypted - return nil -} - -func NewChange(id string, ch *aclpb.TreeChange, signature []byte) *Change { +func NewChange(id string, ch *treechangeproto.TreeChange, signature []byte) *Change { return &Change{ Next: nil, PreviousIds: ch.TreeHeadIds, + AclHeadId: ch.AclHeadId, + Timestamp: ch.Timestamp, + ReadKeyHash: ch.CurrentReadKeyHash, Id: id, - Content: ch, + Data: ch.ChangesData, SnapshotId: ch.SnapshotBaseId, IsSnapshot: ch.IsSnapshot, Identity: string(ch.Identity), - Sign: signature, + Signature: signature, } } -func (ch *Change) DecryptedChangeContent() []byte { - return ch.DecryptedChange -} - -func (ch *Change) Signature() []byte { - return ch.Sign +func NewChangeFromRoot(id string, ch *treechangeproto.RootChange, signature []byte) *Change { + return &Change{ + Next: nil, + AclHeadId: ch.AclHeadId, + Id: id, + IsSnapshot: true, + Identity: string(ch.Identity), + Signature: signature, + } } func (ch *Change) CID() string { diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 7b478fd8..1a2e207b 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -2,8 +2,8 @@ package tree import ( "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" @@ -14,32 +14,44 @@ import ( var ErrEmptyChange = errors.New("change payload should not be empty") type BuilderContent struct { - treeHeadIds []string - aclHeadId string - snapshotBaseId string - currentReadKeyHash uint64 - identity []byte - isSnapshot bool - signingKey signingkey.PrivKey - readKey *symmetric.Key - content []byte + TreeHeadIds []string + AclHeadId string + SnapshotBaseId string + CurrentReadKeyHash uint64 + Identity []byte + IsSnapshot bool + SigningKey signingkey.PrivKey + ReadKey *symmetric.Key + Content []byte +} + +type InitialContent struct { + AclHeadId string + Identity []byte + SigningKey signingkey.PrivKey + SpaceId string + Seed []byte + ChangeType string } type ChangeBuilder interface { - ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) - BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) - BuildRaw(ch *Change) (*aclpb.RawTreeChangeWithId, error) + ConvertFromRaw(rawIdChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) + BuildContent(payload BuilderContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) + BuildInitialContent(payload InitialContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) + BuildRaw(ch *Change) (*treechangeproto.RawTreeChangeWithId, error) + SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) } type changeBuilder struct { - keys *common.Keychain + rootChange *treechangeproto.RawTreeChangeWithId + keys *common.Keychain } -func newChangeBuilder(keys *common.Keychain) ChangeBuilder { - return &changeBuilder{keys: keys} +func newChangeBuilder(keys *common.Keychain, rootChange *treechangeproto.RawTreeChangeWithId) ChangeBuilder { + return &changeBuilder{keys: keys, rootChange: rootChange} } -func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { +func (c *changeBuilder) ConvertFromRaw(rawIdChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) { if rawIdChange.GetRawChange() == nil { err = ErrEmptyChange return @@ -53,7 +65,7 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } } - raw := &aclpb.RawTreeChange{} // TODO: sync pool + raw := &treechangeproto.RawTreeChange{} // TODO: sync pool err = proto.Unmarshal(rawIdChange.GetRawChange(), raw) if err != nil { return @@ -78,28 +90,69 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } } - unmarshalled := &aclpb.TreeChange{} - err = proto.Unmarshal(raw.Payload, unmarshalled) + return c.unmarshallRawChange(raw, rawIdChange.Id) +} + +func (c *changeBuilder) SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) { + c.rootChange = rawIdChange +} + +func (c *changeBuilder) BuildInitialContent(payload InitialContent) (ch *Change, rawIdChange *treechangeproto.RawTreeChangeWithId, err error) { + change := &treechangeproto.RootChange{ + AclHeadId: payload.AclHeadId, + Timestamp: int64(time.Now().Nanosecond()), + Identity: payload.Identity, + ChangeType: payload.ChangeType, + SpaceId: payload.SpaceId, + Seed: payload.Seed, + } + + marshalledChange, err := proto.Marshal(change) if err != nil { return } - ch = NewChange(rawIdChange.Id, unmarshalled, raw.Signature) + signature, err := payload.SigningKey.Sign(marshalledChange) + if err != nil { + return + } + + raw := &treechangeproto.RawTreeChange{ + Payload: marshalledChange, + Signature: signature, + } + + marshalledRawChange, err := proto.Marshal(raw) + if err != nil { + return + } + + id, err := cid.NewCIDFromBytes(marshalledRawChange) + if err != nil { + return + } + + ch = NewChangeFromRoot(id, change, signature) + + rawIdChange = &treechangeproto.RawTreeChangeWithId{ + RawChange: marshalledRawChange, + Id: id, + } return } -func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdChange *aclpb.RawTreeChangeWithId, err error) { - change := &aclpb.TreeChange{ - TreeHeadIds: payload.treeHeadIds, - AclHeadId: payload.aclHeadId, - SnapshotBaseId: payload.snapshotBaseId, - CurrentReadKeyHash: payload.currentReadKeyHash, +func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdChange *treechangeproto.RawTreeChangeWithId, err error) { + change := &treechangeproto.TreeChange{ + TreeHeadIds: payload.TreeHeadIds, + AclHeadId: payload.AclHeadId, + SnapshotBaseId: payload.SnapshotBaseId, + CurrentReadKeyHash: payload.CurrentReadKeyHash, Timestamp: int64(time.Now().Nanosecond()), - Identity: payload.identity, - IsSnapshot: payload.isSnapshot, + Identity: payload.Identity, + IsSnapshot: payload.IsSnapshot, } - encrypted, err := payload.readKey.Encrypt(payload.content) + encrypted, err := payload.ReadKey.Encrypt(payload.Content) if err != nil { return } @@ -110,12 +163,12 @@ func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdC return } - signature, err := payload.signingKey.Sign(marshalledChange) + signature, err := payload.SigningKey.Sign(marshalledChange) if err != nil { return } - raw := &aclpb.RawTreeChange{ + raw := &treechangeproto.RawTreeChange{ Payload: marshalledChange, Signature: signature, } @@ -131,33 +184,67 @@ func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdC } ch = NewChange(id, change, signature) - ch.ParsedModel = payload.content + ch.Model = payload.Content - rawIdChange = &aclpb.RawTreeChangeWithId{ + rawIdChange = &treechangeproto.RawTreeChangeWithId{ RawChange: marshalledRawChange, Id: id, } return } -func (c *changeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { +func (c *changeBuilder) BuildRaw(ch *Change) (raw *treechangeproto.RawTreeChangeWithId, err error) { + if ch.Id == c.rootChange.Id { + return c.rootChange, nil + } + treeChange := &treechangeproto.TreeChange{ + TreeHeadIds: ch.PreviousIds, + AclHeadId: ch.AclHeadId, + SnapshotBaseId: ch.SnapshotId, + ChangesData: ch.Data, + CurrentReadKeyHash: ch.ReadKeyHash, + Timestamp: ch.Timestamp, + Identity: []byte(ch.Identity), + IsSnapshot: ch.IsSnapshot, + } var marshalled []byte - marshalled, err = ch.Content.Marshal() + marshalled, err = treeChange.Marshal() if err != nil { return } - marshalledRawChange, err := proto.Marshal(&aclpb.RawTreeChange{ + marshalledRawChange, err := proto.Marshal(&treechangeproto.RawTreeChange{ Payload: marshalled, - Signature: ch.Sign, + Signature: ch.Signature, }) if err != nil { return } - raw = &aclpb.RawTreeChangeWithId{ + raw = &treechangeproto.RawTreeChangeWithId{ RawChange: marshalledRawChange, Id: ch.Id, } return } + +func (c *changeBuilder) unmarshallRawChange(raw *treechangeproto.RawTreeChange, id string) (ch *Change, err error) { + if c.rootChange.Id == id { + unmarshalled := &treechangeproto.RootChange{} + err = proto.Unmarshal(raw.Payload, unmarshalled) + if err != nil { + return + } + ch = NewChangeFromRoot(id, unmarshalled, raw.Signature) + return + } + + unmarshalled := &treechangeproto.TreeChange{} + err = proto.Unmarshal(raw.Payload, unmarshalled) + if err != nil { + return + } + + ch = NewChange(id, unmarshalled, raw.Signature) + return +} diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index bbc337cf..220eccb3 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -2,7 +2,7 @@ package tree import ( "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" ) @@ -43,12 +43,12 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c state = aclList.ACLState() ) // checking if the user could write - perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Identity) + perm, err = state.PermissionsAtRecord(c.AclHeadId, c.Identity) if err != nil { return } - if perm.Permission != aclpb.ACLUserPermissions_Writer && perm.Permission != aclpb.ACLUserPermissions_Admin { + if perm.Permission != aclrecordproto.ACLUserPermissions_Writer && perm.Permission != aclrecordproto.ACLUserPermissions_Admin { err = list.ErrInsufficientPermissions return } @@ -56,16 +56,16 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c // checking if the change refers to later acl heads than its previous ids for _, id := range c.PreviousIds { prevChange := tree.attached[id] - if prevChange.Content.AclHeadId == c.Content.AclHeadId { + if prevChange.AclHeadId == c.AclHeadId { continue } var after bool - after, err = aclList.IsAfter(c.Content.AclHeadId, prevChange.Content.AclHeadId) + after, err = aclList.IsAfter(c.AclHeadId, prevChange.AclHeadId) if err != nil { return } if !after { - err = fmt.Errorf("current acl head id (%s) should be after each of the previous ones (%s)", c.Content.AclHeadId, prevChange.Content.AclHeadId) + err = fmt.Errorf("current acl head id (%s) should be after each of the previous ones (%s)", c.AclHeadId, prevChange.AclHeadId) return } } diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 7c1df882..115ce87e 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -3,10 +3,10 @@ package tree import ( "context" "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "sync" ) @@ -27,7 +27,7 @@ type AddResultSummary int type AddResult struct { OldHeads []string Heads []string - Added []*aclpb.RawTreeChangeWithId + Added []*treechangeproto.RawTreeChangeWithId Mode Mode } @@ -39,7 +39,7 @@ type ObjectTree interface { RWLocker ID() string - Header() *aclpb.TreeHeader + Header() *treechangeproto.RootChange Heads() []string Root() *Change HasChange(string) bool @@ -49,12 +49,12 @@ type ObjectTree interface { IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error SnapshotPath() []string - ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) + ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*treechangeproto.RawTreeChangeWithId, error) Storage() storage.TreeStorage AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error) - AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error) + AddRawChanges(ctx context.Context, changes ...*treechangeproto.RawTreeChangeWithId) (AddResult, error) Close() error } @@ -67,14 +67,14 @@ type objectTree struct { treeBuilder *treeBuilder aclList list.ACLList - id string - header *aclpb.TreeHeader - tree *Tree + id string + root *treechangeproto.RootChange + tree *Tree keys map[uint64]*symmetric.Key // buffers - difSnapshotBuf []*aclpb.RawTreeChangeWithId + difSnapshotBuf []*treechangeproto.RawTreeChangeWithId tmpChangesBuf []*Change newSnapshotsBuf []*Change notSeenIdxBuf []int @@ -94,11 +94,12 @@ type objectTreeDeps struct { } func defaultObjectTreeDeps( + rootChange *treechangeproto.RawTreeChangeWithId, treeStorage storage.TreeStorage, aclList list.ACLList) objectTreeDeps { keychain := common.NewKeychain() - changeBuilder := newChangeBuilder(keychain) + changeBuilder := newChangeBuilder(keychain, rootChange) treeBuilder := newTreeBuilder(treeStorage, changeBuilder) return objectTreeDeps{ changeBuilder: changeBuilder, @@ -131,8 +132,8 @@ func (ot *objectTree) ID() string { return ot.id } -func (ot *objectTree) Header() *aclpb.TreeHeader { - return ot.header +func (ot *objectTree) Header() *treechangeproto.RootChange { + return ot.root } func (ot *objectTree) Storage() storage.TreeStorage { @@ -172,7 +173,7 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont res = AddResult{ OldHeads: oldHeads, Heads: []string{objChange.Id}, - Added: []*aclpb.RawTreeChangeWithId{rawChange}, + Added: []*treechangeproto.RawTreeChangeWithId{rawChange}, Mode: Append, } return @@ -188,20 +189,20 @@ func (ot *objectTree) prepareBuilderContent(content SignableChangeContent) (cnt return } cnt = BuilderContent{ - treeHeadIds: ot.tree.Heads(), - aclHeadId: ot.aclList.Head().Id, - snapshotBaseId: ot.tree.RootId(), - currentReadKeyHash: state.CurrentReadKeyHash(), - identity: content.Identity, - isSnapshot: content.IsSnapshot, - signingKey: content.Key, - readKey: readKey, - content: content.Data, + TreeHeadIds: ot.tree.Heads(), + AclHeadId: ot.aclList.Head().Id, + SnapshotBaseId: ot.tree.RootId(), + CurrentReadKeyHash: state.CurrentReadKeyHash(), + Identity: content.Identity, + IsSnapshot: content.IsSnapshot, + SigningKey: content.Key, + ReadKey: readKey, + Content: content.Data, } return } -func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { +func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*treechangeproto.RawTreeChangeWithId) (addResult AddResult, err error) { addResult, err = ot.addRawChanges(ctx, rawChanges...) if err != nil { return @@ -223,7 +224,7 @@ func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra return } -func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { +func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*treechangeproto.RawTreeChangeWithId) (addResult AddResult, err error) { // resetting buffers ot.tmpChangesBuf = ot.tmpChangesBuf[:0] ot.notSeenIdxBuf = ot.notSeenIdxBuf[:0] @@ -275,7 +276,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra // returns changes that we added to the tree as attached this round // they can include not only the changes that were added now, // but also the changes that were previously in the tree - getAddedChanges := func(toConvert []*Change) (added []*aclpb.RawTreeChangeWithId, err error) { + getAddedChanges := func(toConvert []*Change) (added []*treechangeproto.RawTreeChangeWithId, err error) { alreadyConverted := make(map[*Change]struct{}) // first we see if we have already unmarshalled those changes @@ -300,7 +301,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra for _, ch := range toConvert { // if we got some changes that we need to convert to raw if _, exists := alreadyConverted[ch]; !exists { - var raw *aclpb.RawTreeChangeWithId + var raw *treechangeproto.RawTreeChangeWithId raw, err = ot.changeBuilder.BuildRaw(ch) if err != nil { return @@ -342,7 +343,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra ot.rebuildFromStorage(nil) return } - var added []*aclpb.RawTreeChangeWithId + var added []*treechangeproto.RawTreeChangeWithId added, err = getAddedChanges(nil) // we shouldn't get any error in this case if err != nil { @@ -378,7 +379,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra err = ErrHasInvalidChanges return } - var added []*aclpb.RawTreeChangeWithId + var added []*treechangeproto.RawTreeChangeWithId added, err = getAddedChanges(treeChangesAdded) if err != nil { // that means that some unattached changes were somehow corrupted in memory @@ -409,17 +410,21 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate ot.tree.Iterate(ot.tree.RootId(), func(c *Change) (isContinue bool) { var model any - if c.ParsedModel != nil { + if c.Model != nil { return iterate(c) } - readKey, exists := ot.keys[c.Content.CurrentReadKeyHash] + // if this is a root change + if c.Id == ot.id { + return iterate(c) + } + readKey, exists := ot.keys[c.ReadKeyHash] if !exists { err = list.ErrNoReadKey return false } var decrypted []byte - decrypted, err = readKey.Decrypt(c.Content.GetChangesData()) + decrypted, err = readKey.Decrypt(c.Data) if err != nil { return false } @@ -429,7 +434,7 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate return false } - c.ParsedModel = model + c.Model = model return iterate(c) }) return @@ -474,7 +479,7 @@ func (ot *objectTree) SnapshotPath() []string { return path } -func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*treechangeproto.RawTreeChangeWithId, error) { var ( needFullDocument = len(theirPath) == 0 ourPath = ot.SnapshotPath() @@ -498,11 +503,11 @@ func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) } } -func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { +func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromTree(ot.tree, theirHeads) } -func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { +func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromStorage(commonSnapshot, ot.tree.headIds, theirHeads) } diff --git a/pkg/acl/tree/objecttree_test.go b/pkg/acl/tree/objecttree_test.go index 6e43d8d3..832c15fa 100644 --- a/pkg/acl/tree/objecttree_test.go +++ b/pkg/acl/tree/objecttree_test.go @@ -2,10 +2,12 @@ package tree import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "crypto/rand" + "encoding/hex" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -14,8 +16,26 @@ import ( type mockChangeCreator struct{} -func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *aclpb.RawTreeChangeWithId { - aclChange := &aclpb.TreeChange{ +func (c *mockChangeCreator) createRoot(id, aclId string) *treechangeproto.RawTreeChangeWithId { + aclChange := &treechangeproto.RootChange{ + AclHeadId: aclId, + } + res, _ := aclChange.Marshal() + + raw := &treechangeproto.RawTreeChange{ + Payload: res, + Signature: nil, + } + rawMarshalled, _ := raw.Marshal() + + return &treechangeproto.RawTreeChangeWithId{ + RawChange: rawMarshalled, + Id: id, + } +} + +func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *treechangeproto.RawTreeChangeWithId { + aclChange := &treechangeproto.TreeChange{ TreeHeadIds: prevIds, AclHeadId: aclId, SnapshotBaseId: snapshotId, @@ -24,26 +44,21 @@ func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot b } res, _ := aclChange.Marshal() - raw := &aclpb.RawTreeChange{ + raw := &treechangeproto.RawTreeChange{ Payload: res, Signature: nil, } rawMarshalled, _ := raw.Marshal() - return &aclpb.RawTreeChangeWithId{ + return &treechangeproto.RawTreeChangeWithId{ RawChange: rawMarshalled, Id: id, } } -func (c *mockChangeCreator) createNewTreeStorage(treeId, aclListId, aclHeadId, firstChangeId string) storage.TreeStorage { - firstChange := c.createRaw(firstChangeId, aclHeadId, "", true) - header := &aclpb.TreeHeader{ - FirstId: firstChangeId, - AclId: aclListId, - TreeHeaderType: aclpb.TreeHeaderType_Object, - } - treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, header, []string{firstChangeId}, []*aclpb.RawTreeChangeWithId{firstChange}) +func (c *mockChangeCreator) createNewTreeStorage(treeId, aclHeadId string) storage.TreeStorage { + root := c.createRoot(treeId, aclHeadId) + treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, root, []string{root.Id}, []*treechangeproto.RawTreeChangeWithId{root}) return treeStorage } @@ -51,15 +66,23 @@ type mockChangeBuilder struct { originalBuilder ChangeBuilder } -func (c *mockChangeBuilder) ConvertFromRaw(rawChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { - return c.originalBuilder.ConvertFromRaw(rawChange, false) -} - -func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) { +func (c *mockChangeBuilder) BuildInitialContent(payload InitialContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) { panic("implement me") } -func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { +func (c *mockChangeBuilder) SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) { + c.originalBuilder.SetRootRawChange(rawIdChange) +} + +func (c *mockChangeBuilder) ConvertFromRaw(rawChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) { + return c.originalBuilder.ConvertFromRaw(rawChange, false) +} + +func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) { + panic("implement me") +} + +func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *treechangeproto.RawTreeChangeWithId, err error) { return c.originalBuilder.BuildRaw(ch) } @@ -93,15 +116,15 @@ func prepareACLList(t *testing.T) list.ACLList { func prepareTreeContext(t *testing.T, aclList list.ACLList) testTreeContext { changeCreator := &mockChangeCreator{} - treeStorage := changeCreator.createNewTreeStorage("treeId", aclList.ID(), aclList.Head().Id, "0") + treeStorage := changeCreator.createNewTreeStorage("0", aclList.Head().Id) + root, _ := treeStorage.Root() changeBuilder := &mockChangeBuilder{ - originalBuilder: newChangeBuilder(nil), + originalBuilder: newChangeBuilder(nil, root), } deps := objectTreeDeps{ changeBuilder: changeBuilder, treeBuilder: newTreeBuilder(treeStorage, changeBuilder), treeStorage: treeStorage, - updateListener: nil, rawChangeLoader: newRawChangeLoader(treeStorage, changeBuilder), validator: &mockChangeValidator{}, aclList: aclList, @@ -128,6 +151,18 @@ func prepareTreeContext(t *testing.T, aclList list.ACLList) testTreeContext { } } +func TestSameSignature(t *testing.T) { + privKey, _, err := signingkey.GenerateEd25519Key(rand.Reader) + require.NoError(t, err) + bytes := []byte("asefhiosahjfoiesjgioesajgihs") + for i := 0; i < 5; i++ { + signed, err := privKey.Sign(bytes) + require.NoError(t, err) + t.Log(hex.EncodeToString(signed)) + } + // kitten step voyage hand cover funny timber auction differ mushroom update pulp +} + func TestObjectTree(t *testing.T) { aclList := prepareACLList(t) @@ -137,7 +172,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } @@ -178,7 +213,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("0", aclList.Head().Id, "", true, ""), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -198,7 +233,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -220,7 +255,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -264,7 +299,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -283,7 +318,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -357,7 +392,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -433,7 +468,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -442,7 +477,7 @@ func TestObjectTree(t *testing.T) { require.NoError(t, err, "adding changes should be without error") require.Equal(t, "3", objTree.Root().Id) - rawChanges = []*aclpb.RawTreeChangeWithId{ + rawChanges = []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("4", aclList.Head().Id, "0", false, "2"), changeCreator.createRaw("5", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("6", aclList.Head().Id, "0", false, "3", "4", "5"), diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index 44dc1fb5..f6ab5f77 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -1,11 +1,10 @@ package tree import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" "github.com/gogo/protobuf/proto" @@ -13,14 +12,19 @@ import ( ) type ObjectTreeCreatePayload struct { - AccountData *account.AccountData - HeaderData []byte - ChangeData []byte - TreeType aclpb.TreeHeaderType + SignKey signingkey.PrivKey + ChangeType string + Seed []byte + SpaceId string + Identity []byte } func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (ObjectTree, error) { - deps := defaultObjectTreeDeps(treeStorage, aclList) + rootChange, err := treeStorage.Root() + if err != nil { + return nil, err + } + deps := defaultObjectTreeDeps(rootChange, treeStorage, aclList) return buildObjectTree(deps) } @@ -30,54 +34,35 @@ func CreateObjectTree( createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { aclList.RLock() var ( - deps = defaultObjectTreeDeps(nil, aclList) - state = aclList.ACLState() - aclId = aclList.ID() - aclHeadId = aclList.Head().Id - readKeyHash = state.CurrentReadKeyHash() + deps = defaultObjectTreeDeps(nil, nil, aclList) + aclHeadId = aclList.Head().Id ) - readKey, err := state.CurrentReadKey() aclList.RUnlock() if err != nil { return } - - // create first change - cnt := BuilderContent{ - treeHeadIds: nil, - aclHeadId: aclHeadId, - snapshotBaseId: "", - currentReadKeyHash: readKeyHash, - isSnapshot: true, - readKey: readKey, - identity: payload.AccountData.Identity, - signingKey: payload.AccountData.SignKey, - content: payload.ChangeData, + cnt := InitialContent{ + AclHeadId: aclHeadId, + Identity: payload.Identity, + SigningKey: payload.SignKey, + SpaceId: payload.SpaceId, + Seed: payload.Seed, + ChangeType: payload.ChangeType, } - _, raw, err := deps.changeBuilder.BuildContent(cnt) - if err != nil { - return - } - - // create header - header, id, err := createTreeHeaderAndId( - raw, - payload.TreeType, - aclId, - payload.AccountData.Identity, - payload.HeaderData) + _, raw, err := deps.changeBuilder.BuildInitialContent(cnt) if err != nil { return } + deps.changeBuilder.SetRootRawChange(raw) // create storage st, err := createStorage(storage.TreeStorageCreatePayload{ - TreeId: id, - Header: header, - Changes: []*aclpb.RawTreeChangeWithId{raw}, - Heads: []string{raw.Id}, + TreeId: raw.Id, + RootRawChange: raw, + Changes: []*treechangeproto.RawTreeChangeWithId{raw}, + Heads: []string{raw.Id}, }) if err != nil { return @@ -98,7 +83,7 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { tree: nil, keys: make(map[uint64]*symmetric.Key), tmpChangesBuf: make([]*Change, 0, 10), - difSnapshotBuf: make([]*aclpb.RawTreeChangeWithId, 0, 10), + difSnapshotBuf: make([]*treechangeproto.RawTreeChangeWithId, 0, 10), notSeenIdxBuf: make([]int, 0, 10), newSnapshotsBuf: make([]*Change, 0, 10), } @@ -128,32 +113,23 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { if err != nil { return nil, err } - objTree.header, err = objTree.treeStorage.Header() + + rawRootWithId, err := objTree.treeStorage.Root() + if err != nil { + return nil, err + } + + rawRoot := &treechangeproto.RawTreeChange{} + err = proto.Unmarshal(rawRootWithId.RawChange, rawRoot) + if err != nil { + return nil, err + } + + objTree.root = &treechangeproto.RootChange{} + err = proto.Unmarshal(rawRoot.Payload, objTree.root) if err != nil { return nil, err } return objTree, nil } - -func createTreeHeaderAndId( - raw *aclpb.RawTreeChangeWithId, - treeType aclpb.TreeHeaderType, - aclId string, - identity []byte, - headerData []byte) (header *aclpb.TreeHeader, treeId string, err error) { - header = &aclpb.TreeHeader{ - FirstId: raw.Id, - TreeHeaderType: treeType, - AclId: aclId, - Identity: identity, - Data: headerData, - } - marshalledHeader, err := proto.Marshal(header) - if err != nil { - return - } - - treeId, err = cid.NewCIDFromBytes(marshalledHeader) - return -} diff --git a/pkg/acl/tree/rawloader.go b/pkg/acl/tree/rawloader.go index c068cdba..6f6c8539 100644 --- a/pkg/acl/tree/rawloader.go +++ b/pkg/acl/tree/rawloader.go @@ -2,8 +2,8 @@ package tree import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "time" ) @@ -18,7 +18,7 @@ type rawChangeLoader struct { type rawCacheEntry struct { change *Change - rawChange *aclpb.RawTreeChangeWithId + rawChange *treechangeproto.RawTreeChangeWithId position int } @@ -29,15 +29,15 @@ func newRawChangeLoader(treeStorage storage.TreeStorage, changeBuilder ChangeBui } } -func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*treechangeproto.RawTreeChangeWithId, error) { var stack []*Change for _, h := range t.headIds { stack = append(stack, t.attached[h]) } - convert := func(chs []*Change) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { + convert := func(chs []*Change) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { for _, ch := range chs { - var raw *aclpb.RawTreeChangeWithId + var raw *treechangeproto.RawTreeChangeWithId raw, err = r.changeBuilder.BuildRaw(ch) if err != nil { return @@ -95,7 +95,7 @@ func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb. return convert(results) } -func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*treechangeproto.RawTreeChangeWithId, error) { // resetting cache r.cache = make(map[string]rawCacheEntry) defer func() { @@ -162,7 +162,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi // preparing first pass r.idStack = append(r.idStack, heads...) - var buffer []*aclpb.RawTreeChangeWithId + var buffer []*treechangeproto.RawTreeChangeWithId rootVisited := dfs(commonSnapshot, heads, 0, func(counter int, mapExists bool) bool { @@ -203,7 +203,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi }) // discarding visited - buffer = discardFromSlice(buffer, func(change *aclpb.RawTreeChangeWithId) bool { + buffer = discardFromSlice(buffer, func(change *treechangeproto.RawTreeChangeWithId) bool { return change == nil }) diff --git a/pkg/acl/tree/treegraph_nix.go b/pkg/acl/tree/treegraph_nix.go index c506c9b3..ae4f5281 100644 --- a/pkg/acl/tree/treegraph_nix.go +++ b/pkg/acl/tree/treegraph_nix.go @@ -59,7 +59,7 @@ func (t *Tree) Graph(parser DescriptionParser) (data string, err error) { label := fmt.Sprintf("Id: %s\nOrd: %s\nTime: %s\nChanges: %s\n", shortId, ord, - time.Unix(c.Content.Timestamp, 0).Format("02.01.06 15:04:05"), + time.Unix(c.Timestamp, 0).Format("02.01.06 15:04:05"), strings.Join(chSymbs, ","), ) n.SetLabel(label) diff --git a/pkg/acl/treechangeproto/protos/treechange.proto b/pkg/acl/treechangeproto/protos/treechange.proto new file mode 100644 index 00000000..8f733a5d --- /dev/null +++ b/pkg/acl/treechangeproto/protos/treechange.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package treechange; +option go_package = "pkg/acl/treechangeproto"; + +// RootChange is a root of a tree +message RootChange { + // AclHeadId is a cid of latest acl record at the time of tree creation + string aclHeadId = 1; + // SpaceId is an id of space where the document is placed + string spaceId = 2; + // ChangeType is a type of tree which this RootChange is a root of + string changeType = 3; + // Timestamp is this change creation timestamp + int64 timestamp = 4; + // Seed is a random bytes to make root change unique + bytes seed = 5; + // Identity is a public key of the tree's creator + bytes identity = 6; +} + +// TreeChange is a change of a tree +message TreeChange { + // TreeHeadIds are previous ids for this TreeChange + repeated string treeHeadIds = 1; + // AclHeadId is a cid of latest acl record at the time of this change + string aclHeadId = 2; + // SnapshotBaseId is a snapshot (root) of the tree where this change is added + string snapshotBaseId = 3; + // ChangesData is an arbitrary payload to be read by the client + bytes changesData = 4; + // CurrentReadKeyHash is the hash of the read key which is used to encrypt this change + uint64 currentReadKeyHash = 5; + // Timestamp is this change creation timestamp + int64 timestamp = 6; + // Identity is a public key with which the raw payload of this change is signed + bytes identity = 7; + // IsSnapshot indicates whether this change contains a snapshot of state + bool isSnapshot = 8; +} + +// RawTreeChange is a marshalled TreeChange (or RootChange) payload and a signature of this payload +message RawTreeChange { + // Payload is a byte payload containing TreeChange + bytes payload = 1; + // Signature is a signature made by identity indicated in the TreeChange payload + bytes signature = 2; +} + +// RawTreeChangeWithId is a marshalled RawTreeChange with CID +message RawTreeChangeWithId { + // RawChange is a byte payload of RawTreeChange + bytes rawChange = 1; + // Id is a cid made from rawChange payload + string id = 2; +} diff --git a/pkg/acl/treechangeproto/treechange.pb.go b/pkg/acl/treechangeproto/treechange.pb.go new file mode 100644 index 00000000..fd4deb8a --- /dev/null +++ b/pkg/acl/treechangeproto/treechange.pb.go @@ -0,0 +1,1537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/acl/treechangeproto/protos/treechange.proto + +package treechangeproto + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RootChange is a root of a tree +type RootChange struct { + // AclHeadId is a cid of latest acl record at the time of tree creation + AclHeadId string `protobuf:"bytes,1,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + // SpaceId is an id of space where the document is placed + SpaceId string `protobuf:"bytes,2,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + // ChangeType is a type of tree which this RootChange is a root of + ChangeType string `protobuf:"bytes,3,opt,name=changeType,proto3" json:"changeType,omitempty"` + // Timestamp is this change creation timestamp + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // Seed is a random bytes to make root change unique + Seed []byte `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"` + // Identity is a public key of the tree's creator + Identity []byte `protobuf:"bytes,6,opt,name=identity,proto3" json:"identity,omitempty"` +} + +func (m *RootChange) Reset() { *m = RootChange{} } +func (m *RootChange) String() string { return proto.CompactTextString(m) } +func (*RootChange) ProtoMessage() {} +func (*RootChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{0} +} +func (m *RootChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RootChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RootChange.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 *RootChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RootChange.Merge(m, src) +} +func (m *RootChange) XXX_Size() int { + return m.Size() +} +func (m *RootChange) XXX_DiscardUnknown() { + xxx_messageInfo_RootChange.DiscardUnknown(m) +} + +var xxx_messageInfo_RootChange proto.InternalMessageInfo + +func (m *RootChange) GetAclHeadId() string { + if m != nil { + return m.AclHeadId + } + return "" +} + +func (m *RootChange) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *RootChange) GetChangeType() string { + if m != nil { + return m.ChangeType + } + return "" +} + +func (m *RootChange) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *RootChange) GetSeed() []byte { + if m != nil { + return m.Seed + } + return nil +} + +func (m *RootChange) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +// TreeChange is a change of a tree +type TreeChange struct { + // TreeHeadIds are previous ids for this TreeChange + TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` + // AclHeadId is a cid of latest acl record at the time of this change + AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + // SnapshotBaseId is a snapshot (root) of the tree where this change is added + SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` + // ChangesData is an arbitrary payload to be read by the client + ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` + // CurrentReadKeyHash is the hash of the read key which is used to encrypt this change + CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + // Timestamp is this change creation timestamp + Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // Identity is a public key with which the raw payload of this change is signed + Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` + // IsSnapshot indicates whether this change contains a snapshot of state + IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` +} + +func (m *TreeChange) Reset() { *m = TreeChange{} } +func (m *TreeChange) String() string { return proto.CompactTextString(m) } +func (*TreeChange) ProtoMessage() {} +func (*TreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{1} +} +func (m *TreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TreeChange.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 *TreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_TreeChange.Merge(m, src) +} +func (m *TreeChange) XXX_Size() int { + return m.Size() +} +func (m *TreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_TreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_TreeChange proto.InternalMessageInfo + +func (m *TreeChange) GetTreeHeadIds() []string { + if m != nil { + return m.TreeHeadIds + } + return nil +} + +func (m *TreeChange) GetAclHeadId() string { + if m != nil { + return m.AclHeadId + } + return "" +} + +func (m *TreeChange) GetSnapshotBaseId() string { + if m != nil { + return m.SnapshotBaseId + } + return "" +} + +func (m *TreeChange) GetChangesData() []byte { + if m != nil { + return m.ChangesData + } + return nil +} + +func (m *TreeChange) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *TreeChange) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *TreeChange) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *TreeChange) GetIsSnapshot() bool { + if m != nil { + return m.IsSnapshot + } + return false +} + +// RawTreeChange is a marshalled TreeChange (or RootChange) payload and a signature of this payload +type RawTreeChange struct { + // Payload is a byte payload containing TreeChange + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + // Signature is a signature made by identity indicated in the TreeChange payload + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *RawTreeChange) Reset() { *m = RawTreeChange{} } +func (m *RawTreeChange) String() string { return proto.CompactTextString(m) } +func (*RawTreeChange) ProtoMessage() {} +func (*RawTreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{2} +} +func (m *RawTreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChange.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 *RawTreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChange.Merge(m, src) +} +func (m *RawTreeChange) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChange proto.InternalMessageInfo + +func (m *RawTreeChange) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + +func (m *RawTreeChange) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +// RawTreeChangeWithId is a marshalled RawTreeChange with CID +type RawTreeChangeWithId struct { + // RawChange is a byte payload of RawTreeChange + RawChange []byte `protobuf:"bytes,1,opt,name=rawChange,proto3" json:"rawChange,omitempty"` + // Id is a cid made from rawChange payload + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *RawTreeChangeWithId) Reset() { *m = RawTreeChangeWithId{} } +func (m *RawTreeChangeWithId) String() string { return proto.CompactTextString(m) } +func (*RawTreeChangeWithId) ProtoMessage() {} +func (*RawTreeChangeWithId) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{3} +} +func (m *RawTreeChangeWithId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChangeWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChangeWithId.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 *RawTreeChangeWithId) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChangeWithId.Merge(m, src) +} +func (m *RawTreeChangeWithId) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChangeWithId) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChangeWithId.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChangeWithId proto.InternalMessageInfo + +func (m *RawTreeChangeWithId) GetRawChange() []byte { + if m != nil { + return m.RawChange + } + return nil +} + +func (m *RawTreeChangeWithId) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func init() { + proto.RegisterType((*RootChange)(nil), "treechange.RootChange") + proto.RegisterType((*TreeChange)(nil), "treechange.TreeChange") + proto.RegisterType((*RawTreeChange)(nil), "treechange.RawTreeChange") + proto.RegisterType((*RawTreeChangeWithId)(nil), "treechange.RawTreeChangeWithId") +} + +func init() { + proto.RegisterFile("pkg/acl/treechangeproto/protos/treechange.proto", fileDescriptor_f177d8514fae978f) +} + +var fileDescriptor_f177d8514fae978f = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x0e, 0x93, 0x40, + 0x10, 0x87, 0xbb, 0xb4, 0xf6, 0xcf, 0x88, 0x3d, 0xac, 0x07, 0x37, 0xc6, 0x10, 0xc2, 0xc1, 0x70, + 0x2a, 0x31, 0xbe, 0x41, 0x6b, 0x62, 0x1b, 0x6f, 0x6b, 0x13, 0x13, 0x6f, 0x23, 0x4c, 0xca, 0xc6, + 0x16, 0x08, 0xbb, 0x4d, 0xc3, 0x5b, 0xf8, 0x08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x24, 0xfd, 0x0e, + 0x0d, 0xda, 0x18, 0xae, 0xec, 0x22, 0xbe, 0x00, 0x1e, 0x1f, 0xcb, 0x92, 0x32, 0x23, 0x09, 0x93, + 0x0f, 0x54, 0xad, 0x51, 0xa7, 0x36, 0xd6, 0x48, 0xfe, 0xa3, 0xd3, 0xd7, 0x32, 0x7e, 0xd4, 0xd2, + 0x55, 0x30, 0xe9, 0x2b, 0xa8, 0x85, 0x2b, 0xfd, 0xf1, 0xb6, 0x9f, 0x98, 0xfa, 0x2c, 0x9c, 0xca, + 0x0e, 0x09, 0xde, 0xc3, 0x33, 0x89, 0xa7, 0x8e, 0x24, 0x01, 0x93, 0x02, 0xab, 0x7d, 0x8e, 0xcd, + 0x7f, 0x75, 0xe5, 0xbd, 0xac, 0x97, 0xd0, 0x6a, 0x97, 0xa1, 0x39, 0x96, 0x64, 0xe5, 0xb8, 0xb2, + 0x05, 0xc1, 0x0a, 0x9e, 0xf7, 0x06, 0x7d, 0x52, 0x26, 0xdd, 0xd8, 0x97, 0x4a, 0x3c, 0x35, 0xe8, + 0x36, 0xb0, 0x05, 0x7c, 0x0e, 0x8e, 0xba, 0x8b, 0x76, 0x54, 0xb2, 0x7c, 0xf3, 0xf3, 0xe2, 0xb1, + 0xf3, 0xc5, 0x63, 0xbf, 0x2f, 0x1e, 0xfb, 0x76, 0xf5, 0x06, 0xe7, 0xab, 0x37, 0xf8, 0x75, 0xf5, + 0x06, 0x9f, 0x5f, 0xfc, 0xe7, 0xf0, 0x7e, 0x19, 0xdb, 0xdb, 0xdb, 0x3f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xa5, 0x78, 0xc6, 0x1e, 0xde, 0x02, 0x00, 0x00, +} + +func (m *RootChange) 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 *RootChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RootChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x32 + } + if len(m.Seed) > 0 { + i -= len(m.Seed) + copy(dAtA[i:], m.Seed) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Seed))) + i-- + dAtA[i] = 0x2a + } + if m.Timestamp != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChangeType) > 0 { + i -= len(m.ChangeType) + copy(dAtA[i:], m.ChangeType) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.ChangeType))) + i-- + dAtA[i] = 0x1a + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x12 + } + if len(m.AclHeadId) > 0 { + i -= len(m.AclHeadId) + copy(dAtA[i:], m.AclHeadId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.AclHeadId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TreeChange) 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 *TreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSnapshot { + i-- + if m.IsSnapshot { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x3a + } + if m.Timestamp != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x30 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x28 + } + if len(m.ChangesData) > 0 { + i -= len(m.ChangesData) + copy(dAtA[i:], m.ChangesData) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.ChangesData))) + i-- + dAtA[i] = 0x22 + } + if len(m.SnapshotBaseId) > 0 { + i -= len(m.SnapshotBaseId) + copy(dAtA[i:], m.SnapshotBaseId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.SnapshotBaseId))) + i-- + dAtA[i] = 0x1a + } + if len(m.AclHeadId) > 0 { + i -= len(m.AclHeadId) + copy(dAtA[i:], m.AclHeadId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.AclHeadId))) + i-- + dAtA[i] = 0x12 + } + if len(m.TreeHeadIds) > 0 { + for iNdEx := len(m.TreeHeadIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TreeHeadIds[iNdEx]) + copy(dAtA[i:], m.TreeHeadIds[iNdEx]) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.TreeHeadIds[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChange) 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 *RawTreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChange) 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 = encodeVarintTreechange(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChangeWithId) 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 *RawTreeChangeWithId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChangeWithId) 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 = encodeVarintTreechange(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.RawChange) > 0 { + i -= len(m.RawChange) + copy(dAtA[i:], m.RawChange) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.RawChange))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTreechange(dAtA []byte, offset int, v uint64) int { + offset -= sovTreechange(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RootChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AclHeadId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.ChangeType) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovTreechange(uint64(m.Timestamp)) + } + l = len(m.Seed) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func (m *TreeChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TreeHeadIds) > 0 { + for _, s := range m.TreeHeadIds { + l = len(s) + n += 1 + l + sovTreechange(uint64(l)) + } + } + l = len(m.AclHeadId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.SnapshotBaseId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.ChangesData) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovTreechange(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovTreechange(uint64(m.Timestamp)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.IsSnapshot { + n += 2 + } + return n +} + +func (m *RawTreeChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func (m *RawTreeChangeWithId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawChange) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func sovTreechange(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTreechange(x uint64) (n int) { + return sovTreechange(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RootChange) 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 ErrIntOverflowTreechange + } + 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: RootChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RootChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclHeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + 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 ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangeType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangeType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Seed = append(m.Seed[:0], dAtA[iNdEx:postIndex]...) + if m.Seed == nil { + m.Seed = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TreeChange) 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 ErrIntOverflowTreechange + } + 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: TreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TreeChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeHeadIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TreeHeadIds = append(m.TreeHeadIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclHeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotBaseId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SnapshotBaseId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangesData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangesData = append(m.ChangesData[:0], dAtA[iNdEx:postIndex]...) + if m.ChangesData == nil { + m.ChangesData = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + } + m.CurrentReadKeyHash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSnapshot", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSnapshot = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChange) 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 ErrIntOverflowTreechange + } + 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: RawTreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChange: 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 byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []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 ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + 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 := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChangeWithId) 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 ErrIntOverflowTreechange + } + 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: RawTreeChangeWithId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChangeWithId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawChange", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawChange = append(m.RawChange[:0], dAtA[iNdEx:postIndex]...) + if m.RawChange == nil { + m.RawChange = []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 ErrIntOverflowTreechange + } + 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 ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTreechange(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTreechange + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTreechange + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTreechange + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTreechange = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTreechange = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTreechange = fmt.Errorf("proto: unexpected end of group") +) diff --git a/service/document/service.go b/service/document/service.go index c8010e10..6d1192c2 100644 --- a/service/document/service.go +++ b/service/document/service.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" testchanges "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/proto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/service/storage/service.go b/service/storage/service.go index 43fb44d5..627627c0 100644 --- a/service/storage/service.go +++ b/service/storage/service.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" ) diff --git a/service/treecache/service.go b/service/treecache/service.go index 829885e3..90e91b98 100644 --- a/service/treecache/service.go +++ b/service/treecache/service.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/syncproto/proto/sync.proto b/syncproto/proto/sync.proto index 80548336..d1c60d7d 100644 --- a/syncproto/proto/sync.proto +++ b/syncproto/proto/sync.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package anytype; option go_package = "/syncproto"; -import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto"; +import "pkg/acl/aclrecordproto/aclpb/protos/aclrecordproto.proto"; message Message { Header header = 1; From d77d8dbdd14a96242354bf7faca04d65950a38a9 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 12:03:20 +0200 Subject: [PATCH 31/44] Fixes to acls --- pkg/acl/aclrecordproto/aclrecord.pb.go | 294 ++++++++---------- pkg/acl/aclrecordproto/protos/aclrecord.proto | 6 +- pkg/acl/common/keychain.go | 9 +- pkg/acl/list/aclreadkeyderive.go | 10 + pkg/acl/list/aclrecordbuilder.go | 95 ++++++ pkg/acl/list/aclstate.go | 184 ++++++----- pkg/acl/list/aclstatebuilder.go | 29 +- pkg/acl/list/changebuilder.go | 131 -------- pkg/acl/list/list.go | 82 ++--- pkg/acl/list/record.go | 69 +--- util/keys/symmetric/symmetric.go | 7 + 11 files changed, 401 insertions(+), 515 deletions(-) create mode 100644 pkg/acl/list/aclreadkeyderive.go create mode 100644 pkg/acl/list/aclrecordbuilder.go delete mode 100644 pkg/acl/list/changebuilder.go diff --git a/pkg/acl/aclrecordproto/aclrecord.pb.go b/pkg/acl/aclrecordproto/aclrecord.pb.go index 69035b70..158b70f5 100644 --- a/pkg/acl/aclrecordproto/aclrecord.pb.go +++ b/pkg/acl/aclrecordproto/aclrecord.pb.go @@ -231,11 +231,13 @@ func (m *ACLRecord) GetTimestamp() int64 { } type ACLRoot struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - SpaceId string `protobuf:"bytes,3,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - EncryptedReadKey []byte `protobuf:"bytes,4,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` - DerivationScheme string `protobuf:"bytes,5,opt,name=derivationScheme,proto3" json:"derivationScheme,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + SpaceId string `protobuf:"bytes,3,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + EncryptedReadKey []byte `protobuf:"bytes,4,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` + DerivationScheme string `protobuf:"bytes,5,opt,name=derivationScheme,proto3" json:"derivationScheme,omitempty"` + CurrentReadKeyHash uint64 `protobuf:"varint,6,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` } func (m *ACLRoot) Reset() { *m = ACLRoot{} } @@ -306,6 +308,20 @@ func (m *ACLRoot) GetDerivationScheme() string { return "" } +func (m *ACLRoot) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *ACLRoot) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + type ACLContentValue struct { // Types that are valid to be assigned to Value: // *ACLContentValue_UserAdd @@ -535,11 +551,9 @@ func (m *ACLState) GetInvites() map[string]*ACLUserInvite { } type ACLUserState struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` - EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` - IsConfirmed bool `protobuf:"varint,5,opt,name=isConfirmed,proto3" json:"isConfirmed,omitempty"` + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,3,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` } func (m *ACLUserState) Reset() { *m = ACLUserState{} } @@ -589,13 +603,6 @@ func (m *ACLUserState) GetEncryptionKey() []byte { return nil } -func (m *ACLUserState) GetEncryptedReadKeys() [][]byte { - if m != nil { - return m.EncryptedReadKeys - } - return nil -} - func (m *ACLUserState) GetPermissions() ACLUserPermissions { if m != nil { return m.Permissions @@ -603,13 +610,6 @@ func (m *ACLUserState) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } -func (m *ACLUserState) GetIsConfirmed() bool { - if m != nil { - return m.IsConfirmed - } - return false -} - type ACLUserAdd struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` @@ -1018,61 +1018,61 @@ func init() { } var fileDescriptor_14abe0d1b4206d54 = []byte{ - // 862 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0x76, 0x8f, 0x9d, 0x38, 0x53, 0xe3, 0xdd, 0x78, 0x5b, 0x90, 0x1d, 0x45, 0x8b, 0x65, 0x8d, - 0x38, 0x58, 0x2b, 0xf0, 0x82, 0x41, 0x5a, 0x94, 0x03, 0xc8, 0x6b, 0x76, 0x65, 0x93, 0x1c, 0x56, - 0x1d, 0x60, 0x11, 0xb7, 0xde, 0x99, 0x26, 0x69, 0xad, 0x3d, 0x33, 0xea, 0x6e, 0x1b, 0xf9, 0xc8, - 0x1b, 0xf0, 0x0a, 0x3c, 0x08, 0x27, 0x2e, 0x1c, 0x73, 0x41, 0xe2, 0x08, 0xc9, 0x0b, 0x70, 0xe7, - 0x82, 0xba, 0xe7, 0xdf, 0xe3, 0x58, 0x42, 0x8a, 0x90, 0x38, 0x24, 0x9e, 0xaa, 0xfa, 0xaa, 0xfc, - 0xd5, 0xd7, 0x35, 0xd5, 0x86, 0xf7, 0xe3, 0x37, 0x17, 0x4f, 0xa8, 0x3f, 0xd7, 0x7f, 0x82, 0xf9, - 0x91, 0x08, 0x62, 0x11, 0xa9, 0xe8, 0x89, 0xf9, 0x2f, 0x0b, 0xef, 0xd0, 0x38, 0xb0, 0x9d, 0x3b, - 0xbc, 0x17, 0xd0, 0x21, 0xf4, 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x90, 0x9a, 0x5f, 0x63, 0x03, - 0x26, 0xf8, 0x8a, 0xea, 0xb2, 0xe7, 0xfe, 0x25, 0x5b, 0x30, 0x43, 0xdc, 0x26, 0x35, 0xbf, 0xf7, - 0x9b, 0x05, 0x87, 0xe3, 0xc9, 0xd9, 0x24, 0x0a, 0x15, 0x0b, 0xd5, 0xd7, 0x74, 0xbe, 0x64, 0xf8, - 0x43, 0x68, 0x2f, 0x25, 0x13, 0xe3, 0x20, 0x91, 0xda, 0x19, 0xbd, 0x3d, 0x2c, 0xa6, 0x65, 0x3c, - 0x39, 0xfb, 0x2a, 0x09, 0x4e, 0x1b, 0x24, 0xc3, 0xe1, 0x13, 0x00, 0xfd, 0x48, 0xd8, 0x22, 0x5a, - 0x25, 0x93, 0xe0, 0x8c, 0xdc, 0x7a, 0x56, 0x12, 0x9f, 0x36, 0x48, 0x09, 0x8d, 0xbf, 0x81, 0xb7, - 0xb4, 0xf5, 0x92, 0x89, 0x05, 0x97, 0x92, 0x47, 0xe1, 0xe4, 0x92, 0x86, 0x17, 0xcc, 0x28, 0xe0, - 0x8c, 0xbc, 0x7a, 0x95, 0x4d, 0xe4, 0xb4, 0x41, 0xb6, 0x56, 0xc8, 0x58, 0xcd, 0xc2, 0x15, 0x57, - 0xcc, 0xc8, 0xb5, 0x95, 0x55, 0x12, 0xcf, 0x58, 0x25, 0x16, 0xfe, 0x18, 0x0e, 0xb4, 0xf5, 0x45, - 0xc4, 0x43, 0x23, 0x9e, 0x33, 0x3a, 0xaa, 0x67, 0xea, 0xe8, 0xb4, 0x41, 0x72, 0xe4, 0xb3, 0x36, - 0xec, 0xad, 0xb4, 0x86, 0xde, 0x73, 0x33, 0x16, 0x9f, 0xeb, 0x81, 0x3b, 0x01, 0xa0, 0xfe, 0x3c, - 0x55, 0xd8, 0x45, 0xfd, 0xe6, 0xc0, 0x19, 0x1d, 0x57, 0x6b, 0x95, 0xe5, 0x27, 0x25, 0xb4, 0xf7, - 0x37, 0x82, 0x83, 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60, 0xff, 0xe3, 0x83, 0xd3, 0xe7, 0x60, - 0xda, 0x99, 0x05, 0xe9, 0xee, 0xcc, 0x6d, 0xef, 0x17, 0x04, 0x4e, 0x69, 0x01, 0xdc, 0xc1, 0x99, - 0xe5, 0x92, 0x9d, 0xe7, 0xb7, 0x69, 0xb3, 0x2c, 0x59, 0xee, 0xae, 0xf0, 0x6a, 0x55, 0x79, 0x6d, - 0x97, 0x68, 0xef, 0x16, 0x89, 0x3c, 0x99, 0x9f, 0x5b, 0xba, 0x87, 0x77, 0xb5, 0xf1, 0x02, 0x0e, - 0xd3, 0x2d, 0x43, 0x58, 0x3c, 0xa7, 0x7e, 0xbe, 0x23, 0x1e, 0x55, 0x35, 0x25, 0x15, 0x10, 0xd9, - 0x4c, 0xf2, 0x7e, 0x40, 0xf0, 0xa0, 0x06, 0xbb, 0x03, 0x01, 0xb7, 0x5d, 0x8f, 0xcd, 0xed, 0xd7, - 0xa3, 0xb7, 0x82, 0x87, 0xb7, 0x5c, 0x24, 0x3b, 0x89, 0x6c, 0x8c, 0x94, 0xf5, 0x6f, 0x47, 0xea, - 0xf1, 0x53, 0xc0, 0x75, 0x08, 0xb6, 0x61, 0x6f, 0x1c, 0x2c, 0x78, 0xd8, 0x6d, 0x60, 0x80, 0xfd, - 0x57, 0x82, 0x2b, 0x26, 0xba, 0x48, 0x3f, 0x6b, 0xbe, 0x4c, 0x74, 0xad, 0x67, 0x1f, 0xfc, 0x7a, - 0xdd, 0x43, 0x57, 0xd7, 0x3d, 0xf4, 0xc7, 0x75, 0x0f, 0xfd, 0x78, 0xd3, 0x6b, 0x5c, 0xdd, 0xf4, - 0x1a, 0xbf, 0xdf, 0xf4, 0x1a, 0xdf, 0x1e, 0x6d, 0xff, 0x8d, 0xf7, 0x7a, 0xdf, 0x7c, 0x7c, 0xf4, - 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x89, 0xed, 0xeb, 0x04, 0x0a, 0x00, 0x00, + // 859 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xdf, 0x59, 0x3b, 0x71, 0xf6, 0xd9, 0x6d, 0xdc, 0x11, 0xa4, 0xab, 0xa8, 0x58, 0xd6, 0x8a, + 0x83, 0x55, 0x81, 0x0b, 0x06, 0xa9, 0x28, 0x07, 0x90, 0x6b, 0x5a, 0xd9, 0x24, 0x87, 0x6a, 0x02, + 0x14, 0x71, 0x9b, 0xee, 0x8e, 0x92, 0x51, 0xed, 0xdd, 0xd5, 0xec, 0xd8, 0xc8, 0x47, 0xce, 0x5c, + 0xe0, 0x23, 0xf0, 0x41, 0x38, 0x71, 0xe1, 0xd8, 0x0b, 0x12, 0x47, 0x94, 0x7c, 0x01, 0xee, 0x5c, + 0xd0, 0xcc, 0xfe, 0xdf, 0xb5, 0x2d, 0x2a, 0x59, 0x3d, 0x24, 0xde, 0xf7, 0xde, 0xef, 0x3d, 0xff, + 0xe6, 0xf7, 0xde, 0xbc, 0x35, 0x7c, 0x18, 0xbe, 0xba, 0x7a, 0x44, 0xdd, 0xb9, 0xfa, 0x13, 0xcc, + 0x0d, 0x84, 0x17, 0x8a, 0x40, 0x06, 0x8f, 0xf4, 0xff, 0x28, 0xf7, 0x0e, 0xb5, 0x03, 0x5b, 0x99, + 0xc3, 0x79, 0x06, 0x1d, 0x42, 0x7f, 0x18, 0x4f, 0x2e, 0x88, 0xb6, 0xb1, 0x0d, 0xad, 0x90, 0xae, + 0xe7, 0x01, 0xf5, 0x6c, 0xd4, 0x47, 0x83, 0x0e, 0x49, 0x4d, 0xfc, 0x00, 0xac, 0x88, 0x5f, 0xf9, + 0x54, 0x2e, 0x05, 0xb3, 0x4d, 0x1d, 0xcb, 0x1d, 0xce, 0xe7, 0x80, 0x8b, 0x75, 0x5e, 0x70, 0x79, + 0x3d, 0xdb, 0x55, 0xed, 0x2e, 0x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0x4b, 0xf6, 0xe6, 0xae, 0x63, 0x3c, 0x83, 0xe3, 0x64, 0x2b, + 0x10, 0x16, 0xce, 0xa9, 0x9b, 0xdd, 0xe9, 0x07, 0x65, 0x4d, 0x49, 0x09, 0x44, 0xaa, 0x49, 0xce, + 0x8f, 0x08, 0xee, 0xd5, 0x60, 0x7b, 0x10, 0x70, 0xd3, 0xcb, 0xb1, 0xb1, 0xf9, 0xe5, 0xe8, 0xac, + 0xe0, 0xfe, 0x96, 0xc5, 0xbf, 0x93, 0x48, 0x65, 0xa4, 0xcc, 0x37, 0x1d, 0xa9, 0x87, 0x8f, 0x01, + 0xd7, 0x21, 0xd8, 0x82, 0x83, 0xb1, 0xb7, 0xe0, 0x7e, 0xd7, 0xc0, 0x00, 0x87, 0x2f, 0x04, 0x97, + 0x4c, 0x74, 0x91, 0x7a, 0x56, 0x7c, 0x99, 0xe8, 0x9a, 0x4f, 0x3e, 0xfa, 0xe3, 0xa6, 0x87, 0x5e, + 0xdf, 0xf4, 0xd0, 0xdf, 0x37, 0x3d, 0xf4, 0xf3, 0x6d, 0xcf, 0x78, 0x7d, 0xdb, 0x33, 0xfe, 0xba, + 0xed, 0x19, 0xdf, 0x9f, 0x6c, 0xfe, 0x85, 0xf7, 0xf2, 0x50, 0x7f, 0x7c, 0xf2, 0x5f, 0x00, 0x00, + 0x00, 0xff, 0xff, 0x0d, 0xd2, 0xee, 0x14, 0x02, 0x0a, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -1223,6 +1223,16 @@ func (m *ACLRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.Timestamp != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x38 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x30 + } if len(m.DerivationScheme) > 0 { i -= len(m.DerivationScheme) copy(dAtA[i:], m.DerivationScheme) @@ -1536,29 +1546,10 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if m.IsConfirmed { - i-- - if m.IsConfirmed { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x28 - } if m.Permissions != 0 { i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- - dAtA[i] = 0x20 - } - if len(m.EncryptedReadKeys) > 0 { - for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.EncryptedReadKeys[iNdEx]) - copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) - i-- - dAtA[i] = 0x1a - } + dAtA[i] = 0x18 } if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) @@ -1967,6 +1958,12 @@ func (m *ACLRoot) Size() (n int) { if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovAclrecord(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovAclrecord(uint64(m.Timestamp)) + } return n } @@ -2106,18 +2103,9 @@ func (m *ACLUserState) Size() (n int) { if l > 0 { n += 1 + l + sovAclrecord(uint64(l)) } - if len(m.EncryptedReadKeys) > 0 { - for _, b := range m.EncryptedReadKeys { - l = len(b) - n += 1 + l + sovAclrecord(uint64(l)) - } - } if m.Permissions != 0 { n += 1 + sovAclrecord(uint64(m.Permissions)) } - if m.IsConfirmed { - n += 2 - } return n } @@ -2887,6 +2875,44 @@ func (m *ACLRoot) Unmarshal(dAtA []byte) error { } m.DerivationScheme = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + } + m.CurrentReadKeyHash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex skippy, err := skipAclrecord(dAtA[iNdEx:]) @@ -3604,38 +3630,6 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { } iNdEx = postIndex case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclrecord - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclrecord - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclrecord - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: if wireType != 0 { return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) } @@ -3654,26 +3648,6 @@ func (m *ACLUserState) Unmarshal(dAtA []byte) error { break } } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsConfirmed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclrecord - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsConfirmed = bool(v != 0) default: iNdEx = preIndex skippy, err := skipAclrecord(dAtA[iNdEx:]) diff --git a/pkg/acl/aclrecordproto/protos/aclrecord.proto b/pkg/acl/aclrecordproto/protos/aclrecord.proto index 01b5aa6f..4d2a969a 100644 --- a/pkg/acl/aclrecordproto/protos/aclrecord.proto +++ b/pkg/acl/aclrecordproto/protos/aclrecord.proto @@ -26,6 +26,8 @@ message ACLRoot { string spaceId = 3; bytes encryptedReadKey = 4; string derivationScheme = 5; + uint64 currentReadKeyHash = 6; + int64 timestamp = 7; } message ACLContentValue { @@ -51,9 +53,7 @@ message ACLState { message ACLUserState { bytes identity = 1; bytes encryptionKey = 2; - repeated bytes encryptedReadKeys = 3; - ACLUserPermissions permissions = 4; - bool isConfirmed = 5; + ACLUserPermissions permissions = 3; } message ACLUserAdd { diff --git a/pkg/acl/common/keychain.go b/pkg/acl/common/keychain.go index d90965c6..b9fc0fb6 100644 --- a/pkg/acl/common/keychain.go +++ b/pkg/acl/common/keychain.go @@ -1,19 +1,16 @@ package common import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) type Keychain struct { - decoder keys.Decoder - keys map[string]signingkey.PubKey + keys map[string]signingkey.PubKey } func NewKeychain() *Keychain { return &Keychain{ - decoder: signingkey.NewEDPubKeyDecoder(), - keys: make(map[string]signingkey.PubKey), + keys: make(map[string]signingkey.PubKey), } } @@ -21,7 +18,7 @@ func (k *Keychain) GetOrAdd(identity string) (signingkey.PubKey, error) { if key, exists := k.keys[identity]; exists { return key, nil } - res, err := k.decoder.DecodeFromBytes([]byte(identity)) + res, err := signingkey.NewSigningEd25519PubKeyFromBytes([]byte(identity)) if err != nil { return nil, err } diff --git a/pkg/acl/list/aclreadkeyderive.go b/pkg/acl/list/aclreadkeyderive.go new file mode 100644 index 00000000..c20b2501 --- /dev/null +++ b/pkg/acl/list/aclreadkeyderive.go @@ -0,0 +1,10 @@ +package list + +import "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" + +func ACLReadKeyDerive(signKey []byte, encKey []byte) (*symmetric.Key, error) { + concBuf := make([]byte, 0, len(signKey)+len(encKey)) + concBuf = append(concBuf, signKey...) + concBuf = append(concBuf, encKey...) + return symmetric.DeriveFromBytes(concBuf) +} diff --git a/pkg/acl/list/aclrecordbuilder.go b/pkg/acl/list/aclrecordbuilder.go new file mode 100644 index 00000000..26c9e08f --- /dev/null +++ b/pkg/acl/list/aclrecordbuilder.go @@ -0,0 +1,95 @@ +package list + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" + "github.com/gogo/protobuf/proto" +) + +type ACLRecordBuilder interface { + ConvertFromRaw(rawIdRecord *aclrecordproto.RawACLRecordWithId) (rec *ACLRecord, err error) +} + +type aclRecordBuilder struct { + id string + keychain *common.Keychain +} + +func newACLRecordBuilder(id string, keychain *common.Keychain) ACLRecordBuilder { + return &aclRecordBuilder{ + id: id, + keychain: keychain, + } +} + +func (a *aclRecordBuilder) ConvertFromRaw(rawIdRecord *aclrecordproto.RawACLRecordWithId) (rec *ACLRecord, err error) { + rawRec := &aclrecordproto.RawACLRecord{} + err = proto.Unmarshal(rawIdRecord.Payload, rawRec) + if err != nil { + return + } + + if rawIdRecord.Id == a.id { + aclRoot := &aclrecordproto.ACLRoot{} + err = proto.Unmarshal(rawRec.Payload, aclRoot) + if err != nil { + return + } + + rec = &ACLRecord{ + Id: rawIdRecord.Id, + CurrentReadKeyHash: aclRoot.CurrentReadKeyHash, + Timestamp: aclRoot.Timestamp, + Signature: rawRec.Signature, + Identity: aclRoot.Identity, + Model: aclRoot, + } + } else { + aclRecord := &aclrecordproto.ACLRecord{} + err = proto.Unmarshal(rawRec.Payload, aclRecord) + if err != nil { + return + } + + rec = &ACLRecord{ + Id: rawIdRecord.Id, + PrevId: aclRecord.PrevId, + CurrentReadKeyHash: aclRecord.CurrentReadKeyHash, + Timestamp: aclRecord.Timestamp, + Data: aclRecord.Data, + Signature: rawRec.Signature, + Identity: aclRecord.Identity, + } + } + + err = verifyRaw(a.keychain, rawRec, rawIdRecord, rec.Identity) + return +} + +func verifyRaw( + keychain *common.Keychain, + rawRec *aclrecordproto.RawACLRecord, + recWithId *aclrecordproto.RawACLRecordWithId, + identity []byte) (err error) { + identityKey, err := keychain.GetOrAdd(string(identity)) + if err != nil { + return + } + + // verifying signature + res, err := identityKey.Verify(rawRec.Payload, rawRec.Signature) + if err != nil { + return + } + if !res { + err = ErrInvalidSignature + return + } + + // verifying ID + if !cid.VerifyCID(recWithId.Payload, recWithId.Id) { + err = ErrIncorrectCID + } + return +} diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 27416972..166fff71 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -27,6 +27,7 @@ var ErrNoSuchRecord = errors.New("no such record") var ErrInsufficientPermissions = errors.New("insufficient permissions") var ErrNoReadKey = errors.New("acl state doesn't have a read key") var ErrInvalidSignature = errors.New("signature is invalid") +var ErrIncorrectRoot = errors.New("incorrect root") type UserPermissionPair struct { Identity string @@ -34,13 +35,13 @@ type UserPermissionPair struct { } type ACLState struct { + id string currentReadKeyHash uint64 userReadKeys map[uint64]*symmetric.Key userStates map[string]*aclrecordproto.ACLUserState userInvites map[string]*aclrecordproto.ACLUserInvite - - signingPubKeyDecoder keys.Decoder - encryptionKey encryptionkey.PrivKey + encryptionKey encryptionkey.PrivKey + signingKey signingkey.PrivKey identity string permissionsAtRecord map[string][]UserPermissionPair @@ -48,30 +49,30 @@ type ACLState struct { keychain *common.Keychain } -func newACLStateWithIdentity( - identity string, - encryptionKey encryptionkey.PrivKey, - decoder keys.Decoder) *ACLState { - return &ACLState{ - identity: identity, - encryptionKey: encryptionKey, - userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclrecordproto.ACLUserState), - userInvites: make(map[string]*aclrecordproto.ACLUserInvite), - signingPubKeyDecoder: decoder, - permissionsAtRecord: make(map[string][]UserPermissionPair), - keychain: common.NewKeychain(), +func newACLStateWithKeys( + signingKey signingkey.PrivKey, + encryptionKey encryptionkey.PrivKey) (*ACLState, error) { + identity, err := signingKey.Raw() + if err != nil { + return nil, err } + return &ACLState{ + identity: string(identity), + signingKey: signingKey, + encryptionKey: encryptionKey, + userReadKeys: make(map[uint64]*symmetric.Key), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), + permissionsAtRecord: make(map[string][]UserPermissionPair), + }, nil } func newACLState(decoder keys.Decoder) *ACLState { return &ACLState{ - signingPubKeyDecoder: decoder, - userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclrecordproto.ACLUserState), - userInvites: make(map[string]*aclrecordproto.ACLUserInvite), - permissionsAtRecord: make(map[string][]UserPermissionPair), - keychain: common.NewKeychain(), + userReadKeys: make(map[uint64]*symmetric.Key), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), + permissionsAtRecord: make(map[string][]UserPermissionPair), } } @@ -106,40 +107,27 @@ func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermiss return UserPermissionPair{}, ErrNoSuchUser } -func (st *ACLState) applyRecord(record *aclrecordproto.ACLRecord) (err error) { +func (st *ACLState) applyRecord(record *ACLRecord) (err error) { + if record.Id == st.id { + root, ok := record.Model.(*aclrecordproto.ACLRoot) + if !ok { + return ErrIncorrectRoot + } + return st.applyRoot(root) + } aclData := &aclrecordproto.ACLData{} - err = proto.Unmarshal(record.Data, aclData) - if err != nil { - return - } - - err = st.applyChangeData(aclData, record.CurrentReadKeyHash, record.Identity) - if err != nil { - return - } - - st.currentReadKeyHash = record.CurrentReadKeyHash - return -} - -func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { - var ( - change = recordWrapper.Content - aclData = &aclrecordproto.ACLData{} - ) - - if recordWrapper.Model != nil { - aclData = recordWrapper.Model.(*aclrecordproto.ACLData) + if record.Model != nil { + aclData = record.Model.(*aclrecordproto.ACLData) } else { - err = proto.Unmarshal(change.Data, aclData) + err = proto.Unmarshal(record.Data, aclData) if err != nil { return } - recordWrapper.Model = aclData + record.Model = aclData } - err = st.applyChangeData(aclData, recordWrapper.Content.CurrentReadKeyHash, recordWrapper.Content.Identity) + err = st.applyChangeData(aclData, record.CurrentReadKeyHash, record.Identity) if err != nil { return } @@ -154,10 +142,61 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { permissions = append(permissions, permission) } - st.permissionsAtRecord[recordWrapper.Id] = permissions + st.permissionsAtRecord[record.Id] = permissions return nil } +func (st *ACLState) applyRoot(root *aclrecordproto.ACLRoot) (err error) { + if st.signingKey != nil && st.encryptionKey != nil { + err = st.saveReadKeyFromRoot(root) + if err != nil { + return + } + } + + // adding user to the list + userState := &aclrecordproto.ACLUserState{ + Identity: root.Identity, + EncryptionKey: root.EncryptionKey, + Permissions: aclrecordproto.ACLUserPermissions_Admin, + } + st.userStates[string(root.Identity)] = userState + return +} + +func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto.ACLRoot) (err error) { + var readKey *symmetric.Key + if len(root.GetDerivationScheme()) != 0 { + var encPubKey []byte + encPubKey, err = st.encryptionKey.GetPublic().Raw() + if err != nil { + return + } + + readKey, err = ACLReadKeyDerive([]byte(st.identity), encPubKey) + if err != nil { + return + } + } else { + readKey, _, err = st.decryptReadKeyAndHash(root.EncryptedReadKey) + if err != nil { + return + } + } + + hasher := fnv.New64() + _, err = hasher.Write(readKey.Bytes()) + if err != nil { + return + } + if hasher.Sum64() != root.CurrentReadKeyHash { + return ErrIncorrectRoot + } + st.currentReadKeyHash = root.CurrentReadKeyHash + st.userReadKeys[root.CurrentReadKeyHash] = readKey + return +} + func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uint64, identity []byte) (err error) { defer func() { if err != nil { @@ -166,11 +205,8 @@ func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uin st.currentReadKeyHash = hash }() - // we can't check this for the user which is joining, because it will not be in our list - // the same is for the first change to be added - skipIdentityCheck := st.isUserJoin(changeData) || (st.currentReadKeyHash == 0 && st.isUserAdd(changeData, identity)) - if !skipIdentityCheck { - // we check signature when we add this to the Tree, so no need to do it here + if !st.isUserJoin(changeData) { + // we check signature when we add this to the List, so no need to do it here if _, exists := st.userStates[string(identity)]; !exists { err = ErrNoSuchUser return @@ -204,8 +240,6 @@ func (st *ACLState) applyChangeContent(ch *aclrecordproto.ACLContentValue) error return st.applyUserInvite(ch.GetUserInvite()) case ch.GetUserJoin() != nil: return st.applyUserJoin(ch.GetUserJoin()) - case ch.GetUserConfirm() != nil: - return st.applyUserConfirm(ch.GetUserConfirm()) default: return fmt.Errorf("unexpected change type: %v", ch) } @@ -228,9 +262,9 @@ func (st *ACLState) applyUserInvite(ch *aclrecordproto.ACLUserInvite) error { } func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error { - invite, exists := st.userInvites[ch.UserInviteId] + invite, exists := st.userInvites[ch.InviteId] if !exists { - return fmt.Errorf("no such invite with id %s", ch.UserInviteId) + return fmt.Errorf("no such invite with id %s", ch.InviteId) } chIdentity := string(ch.Identity) @@ -240,7 +274,7 @@ func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error { // validating signature signature := ch.GetAcceptSignature() - verificationKey, err := st.signingPubKeyDecoder.DecodeFromBytes(invite.AcceptPublicKey) + verificationKey, err := signingkey.NewSigningEd25519PubKeyFromBytes(invite.AcceptPublicKey) if err != nil { return fmt.Errorf("public key verifying invite accepts is given in incorrect format: %v", err) } @@ -267,11 +301,9 @@ func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error { // adding user to the list userState := &aclrecordproto.ACLUserState{ - Identity: ch.Identity, - EncryptionKey: ch.EncryptionKey, - EncryptedReadKeys: ch.EncryptedReadKeys, - Permissions: invite.Permissions, - IsConfirmed: true, + Identity: ch.Identity, + EncryptionKey: ch.EncryptionKey, + Permissions: invite.Permissions, } st.userStates[chIdentity] = userState return nil @@ -284,10 +316,9 @@ func (st *ACLState) applyUserAdd(ch *aclrecordproto.ACLUserAdd) error { } st.userStates[chIdentity] = &aclrecordproto.ACLUserState{ - Identity: ch.Identity, - EncryptionKey: ch.EncryptionKey, - Permissions: ch.Permissions, - EncryptedReadKeys: ch.EncryptedReadKeys, + Identity: ch.Identity, + EncryptionKey: ch.EncryptionKey, + Permissions: ch.Permissions, } if chIdentity == st.identity { @@ -318,12 +349,6 @@ func (st *ACLState) applyUserRemove(ch *aclrecordproto.ACLUserRemove) error { for _, replace := range ch.ReadKeyReplaces { repIdentity := string(replace.Identity) - userState, exists := st.userStates[repIdentity] - if !exists { - continue - } - - userState.EncryptedReadKeys = append(userState.EncryptedReadKeys, replace.EncryptedReadKey) // if this is our identity then we have to decrypt the key if repIdentity == st.identity { key, hash, err := st.decryptReadKeyAndHash(replace.EncryptedReadKey) @@ -338,17 +363,6 @@ func (st *ACLState) applyUserRemove(ch *aclrecordproto.ACLUserRemove) error { return nil } -func (st *ACLState) applyUserConfirm(ch *aclrecordproto.ACLUserConfirm) error { - chIdentity := string(ch.Identity) - state, exists := st.userStates[chIdentity] - if !exists { - return ErrNoSuchUser - } - - state.IsConfirmed = true - return nil -} - func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, error) { decrypted, err := st.encryptionKey.Decrypt(msg) if err != nil { diff --git a/pkg/acl/list/aclstatebuilder.go b/pkg/acl/list/aclstatebuilder.go index da79141b..2d7693fb 100644 --- a/pkg/acl/list/aclstatebuilder.go +++ b/pkg/acl/list/aclstatebuilder.go @@ -4,19 +4,20 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) type aclStateBuilder struct { - identity string - key encryptionkey.PrivKey - decoder keys.Decoder + signPrivKey signingkey.PrivKey + encPrivKey encryptionkey.PrivKey + decoder keys.Decoder } func newACLStateBuilderWithIdentity(decoder keys.Decoder, accountData *account.AccountData) *aclStateBuilder { return &aclStateBuilder{ - decoder: decoder, - identity: string(accountData.Identity), - key: accountData.EncKey, + decoder: decoder, + signPrivKey: accountData.SignKey, + encPrivKey: accountData.EncKey, } } @@ -26,19 +27,17 @@ func newACLStateBuilder(decoder keys.Decoder) *aclStateBuilder { } } -func (sb *aclStateBuilder) Build(records []*ACLRecord) (*ACLState, error) { - var ( - err error - state *ACLState - ) - - if sb.key != nil { - state = newACLStateWithIdentity(sb.identity, sb.key, sb.decoder) +func (sb *aclStateBuilder) Build(records []*ACLRecord) (state *ACLState, err error) { + if sb.encPrivKey != nil && sb.signPrivKey != nil { + state, err = newACLStateWithKeys(sb.signPrivKey, sb.encPrivKey) + if err != nil { + return + } } else { state = newACLState(sb.decoder) } for _, rec := range records { - err = state.applyChangeAndUpdate(rec) + err = state.applyRecord(rec) if err != nil { return nil, err } diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go deleted file mode 100644 index f56e5259..00000000 --- a/pkg/acl/list/changebuilder.go +++ /dev/null @@ -1,131 +0,0 @@ -package list - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" - "github.com/gogo/protobuf/proto" - "hash/fnv" - "time" -) - -type MarshalledChange = []byte - -type ACLChangeBuilder interface { - UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLUserPermissions) error - AddId(id string) // TODO: this is only for testing -} - -type aclChangeBuilder struct { - aclState *ACLState - list ACLList - acc *account.AccountData - - aclData *aclpb.ACLData - id string - readKey *symmetric.Key - readKeyHash uint64 -} - -func newACLChangeBuilder() *aclChangeBuilder { - return &aclChangeBuilder{} -} - -func (c *aclChangeBuilder) Init(state *ACLState, list ACLList, acc *account.AccountData) { - c.aclState = state - c.list = list - c.acc = acc - - c.aclData = &aclpb.ACLData{} - // setting read key for further encryption etc - if state.currentReadKeyHash == 0 { - c.readKey, _ = symmetric.NewRandom() - - hasher := fnv.New64() - hasher.Write(c.readKey.Bytes()) - c.readKeyHash = hasher.Sum64() - } else { - c.readKey = c.aclState.userReadKeys[c.aclState.currentReadKeyHash] - c.readKeyHash = c.aclState.currentReadKeyHash - } -} - -func (c *aclChangeBuilder) AddId(id string) { - c.id = id -} - -func (c *aclChangeBuilder) UserAdd(identity string, encryptionKey encryptionkey.PubKey, permissions aclpb.ACLUserPermissions) error { - var allKeys []*symmetric.Key - if c.aclState.currentReadKeyHash != 0 { - for _, key := range c.aclState.userReadKeys { - allKeys = append(allKeys, key) - } - } else { - allKeys = append(allKeys, c.readKey) - } - - var encryptedKeys [][]byte - for _, k := range allKeys { - res, err := encryptionKey.Encrypt(k.Bytes()) - if err != nil { - return err - } - - encryptedKeys = append(encryptedKeys, res) - } - rawKey, err := encryptionKey.Raw() - if err != nil { - return err - } - ch := &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserAdd{ - UserAdd: &aclpb.ACLUserAdd{ - Identity: []byte(identity), - EncryptionKey: rawKey, - EncryptedReadKeys: encryptedKeys, - Permissions: permissions, - }, - }, - } - c.aclData.AclContent = append(c.aclData.AclContent, ch) - return nil -} - -func (c *aclChangeBuilder) BuildAndApply() (*ACLRecord, []byte, error) { - aclRecord := &aclpb.ACLRecord{ - PrevId: c.list.Head().Id, - CurrentReadKeyHash: c.readKeyHash, - Timestamp: int64(time.Now().Nanosecond()), - Identity: c.acc.Identity, - } - - marshalledData, err := proto.Marshal(c.aclData) - if err != nil { - return nil, nil, err - } - aclRecord.Data = marshalledData - err = c.aclState.applyRecord(aclRecord) - if err != nil { - return nil, nil, err - } - - fullMarshalledChange, err := proto.Marshal(aclRecord) - if err != nil { - return nil, nil, err - } - signature, err := c.acc.SignKey.Sign(fullMarshalledChange) - if err != nil { - return nil, nil, err - } - id, err := cid.NewCIDFromBytes(fullMarshalledChange) - if err != nil { - return nil, nil, err - } - ch := NewRecord(id, aclRecord) - ch.Model = c.aclData - ch.Sign = signature - - return ch, fullMarshalledChange, nil -} diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index d20d5b69..aad93a8f 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -5,10 +5,9 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "sync" ) @@ -26,7 +25,7 @@ type RWLocker interface { type ACLList interface { RWLocker ID() string - Header() *aclpb.ACLHeader + Root() *aclrecordproto.ACLRoot Records() []*ACLRecord ACLState() *ACLState IsAfter(first string, second string) (bool, error) @@ -38,7 +37,7 @@ type ACLList interface { } type aclList struct { - header *aclpb.ACLHeader + root *aclrecordproto.ACLRoot records []*ACLRecord indexes map[string]int id string @@ -51,52 +50,50 @@ type aclList struct { } func BuildACLListWithIdentity(acc *account.AccountData, storage storage.ListStorage) (ACLList, error) { + id, err := storage.ID() + if err != nil { + return nil, err + } builder := newACLStateBuilderWithIdentity(acc.Decoder, acc) - return buildWithACLStateBuilder(builder, storage) + return build(id, builder, newACLRecordBuilder(id, common.NewKeychain()), storage) } func BuildACLList(decoder keys.Decoder, storage storage.ListStorage) (ACLList, error) { - return buildWithACLStateBuilder(newACLStateBuilder(decoder), storage) -} - -func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStorage) (list ACLList, err error) { - header, err := storage.Root() - if err != nil { - return - } - id, err := storage.ID() + if err != nil { + return nil, err + } + return build(id, newACLStateBuilder(decoder), newACLRecordBuilder(id, common.NewKeychain()), storage) +} + +func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder, storage storage.ListStorage) (list ACLList, err error) { + rootWithId, err := storage.Root() if err != nil { return } - - rawRecord, err := storage.Head() + aclRecRoot, err := recBuilder.ConvertFromRaw(rootWithId) if err != nil { return } - keychain := common.NewKeychain() - record, err := NewFromRawRecord(rawRecord) + rawRecordWithId, err := storage.Head() if err != nil { return } - err = verifyRecord(keychain, rawRecord, record) + + record, err := recBuilder.ConvertFromRaw(rawRecordWithId) if err != nil { return } records := []*ACLRecord{record} - for record.Content.PrevId != "" { - rawRecord, err = storage.GetRawRecord(context.Background(), record.Content.PrevId) + for record.PrevId != "" { + rawRecordWithId, err = storage.GetRawRecord(context.Background(), record.PrevId) if err != nil { return } - record, err = NewFromRawRecord(rawRecord) - if err != nil { - return - } - err = verifyRecord(keychain, rawRecord, record) + record, err = recBuilder.ConvertFromRaw(rawRecordWithId) if err != nil { return } @@ -114,16 +111,16 @@ func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStor indexes[records[len(records)/2].Id] = len(records) / 2 } - state, err := builder.Build(records) + state, err := stateBuilder.Build(records) if err != nil { return } list = &aclList{ - header: header, + root: aclRecRoot.Model.(*aclrecordproto.ACLRoot), records: records, indexes: indexes, - builder: builder, + builder: stateBuilder, aclState: state, id: id, RWMutex: sync.RWMutex{}, @@ -139,8 +136,8 @@ func (a *aclList) ID() string { return a.id } -func (a *aclList) Header() *aclpb.ACLHeader { - return a.header +func (a *aclList) Root() *aclrecordproto.ACLRoot { + return a.root } func (a *aclList) ACLState() *ACLState { @@ -191,26 +188,3 @@ func (a *aclList) IterateFrom(startId string, iterFunc IterFunc) { func (a *aclList) Close() (err error) { return nil } - -func verifyRecord(keychain *common.Keychain, rawRecord *aclpb.RawACLRecord, record *ACLRecord) (err error) { - identityKey, err := keychain.GetOrAdd(record.Identity) - if err != nil { - return - } - - // verifying signature - res, err := identityKey.Verify(rawRecord.Payload, rawRecord.Signature) - if err != nil { - return - } - if !res { - err = ErrInvalidSignature - return - } - - // verifying ID - if !cid.VerifyCID(rawRecord.Payload, rawRecord.Id) { - err = ErrIncorrectCID - } - return -} diff --git a/pkg/acl/list/record.go b/pkg/acl/list/record.go index 04f4abbf..abb37736 100644 --- a/pkg/acl/list/record.go +++ b/pkg/acl/list/record.go @@ -1,65 +1,12 @@ package list -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" - "github.com/gogo/protobuf/proto" -) - type ACLRecord struct { - Id string - Content *aclrecordproto.ACLRecord - Identity string - Model interface{} - Sign []byte + Id string + PrevId string + CurrentReadKeyHash uint64 + Timestamp int64 + Data []byte + Identity []byte + Model interface{} + Signature []byte } - -func NewRecord(id string, aclRecord *aclrecordproto.ACLRecord) *ACLRecord { - return &ACLRecord{ - Id: id, - Content: aclRecord, - Identity: string(aclRecord.Identity), - } -} - -func NewFromRawRecord(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { - rawRec := &aclrecordproto.RawACLRecord{} - err = proto.Unmarshal(rawRecWithId.Payload, rawRec) - if err != nil { - return - } - - protoAclRec := &aclrecordproto.ACLRecord{} - err = proto.Unmarshal(rawRec.Payload, protoAclRec) - if err != nil { - return - } - - return &ACLRecord{ - Id: rawRecWithId.Id, - Content: protoAclRec, - Sign: rawRec.Signature, - Identity: string(protoAclRec.Identity), - }, nil -} - -func NewFromRawRoot(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { - rawRec := &aclrecordproto.RawACLRecord{} - err = proto.Unmarshal(rawRecWithId.Payload, rawRec) - if err != nil { - return - } - - protoAclRec := &aclrecordproto.ACLRecord{} - err = proto.Unmarshal(rawRec.Payload, protoAclRec) - if err != nil { - return - } - - return &ACLRecord{ - Id: rawRecWithId.Id, - Content: protoAclRec, - Sign: rawRec.Signature, - Identity: string(protoAclRec.Identity), - }, nil -} - diff --git a/util/keys/symmetric/symmetric.go b/util/keys/symmetric/symmetric.go index 22648769..711f1fdd 100644 --- a/util/keys/symmetric/symmetric.go +++ b/util/keys/symmetric/symmetric.go @@ -5,6 +5,7 @@ import ( "crypto/cipher" "crypto/rand" "fmt" + "github.com/minio/sha256-simd" mbase "github.com/multiformats/go-multibase" ) @@ -21,6 +22,12 @@ type Key struct { raw []byte } +func DeriveFromBytes(bytes []byte) (*Key, error) { + bArray := sha256.Sum256(bytes) + bSlice := bArray[:] + return FromBytes(bSlice) +} + func (k *Key) Equals(otherKey *Key) bool { otherRaw := otherKey.raw keyRaw := k.raw From 674e784318c8490fb80b184441e72b06f757d49a Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 13:47:34 +0200 Subject: [PATCH 32/44] Make acl list etc compile --- .../aclreadkeyderive.go | 2 +- pkg/acl/list/aclstate.go | 2 +- pkg/acl/list/list_test.go | 22 +-- pkg/acl/testutils/acllistbuilder/keychain.go | 12 +- .../acllistbuilder/liststoragebuilder.go | 157 ++++++++++-------- .../liststoragebuildergraph_nix.go | 8 +- .../testutils/acllistbuilder/ymlentities.go | 19 ++- .../testutils/yamltests/userjoinexample.yml | 15 +- .../testutils/yamltests/userremoveexample.yml | 15 +- 9 files changed, 140 insertions(+), 112 deletions(-) rename pkg/acl/{list => aclrecordproto}/aclreadkeyderive.go (93%) diff --git a/pkg/acl/list/aclreadkeyderive.go b/pkg/acl/aclrecordproto/aclreadkeyderive.go similarity index 93% rename from pkg/acl/list/aclreadkeyderive.go rename to pkg/acl/aclrecordproto/aclreadkeyderive.go index c20b2501..a09ba6ce 100644 --- a/pkg/acl/list/aclreadkeyderive.go +++ b/pkg/acl/aclrecordproto/aclreadkeyderive.go @@ -1,4 +1,4 @@ -package list +package aclrecordproto import "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 166fff71..7caf345a 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -173,7 +173,7 @@ func (st *ACLState) saveReadKeyFromRoot(root *aclrecordproto.ACLRoot) (err error return } - readKey, err = ACLReadKeyDerive([]byte(st.identity), encPubKey) + readKey, err = aclrecordproto.ACLReadKeyDerive([]byte(st.identity), encPubKey) if err != nil { return } diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index d36cd373..6c3c70d1 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -1,7 +1,7 @@ package list import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" @@ -23,10 +23,10 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { idC := keychain.GetIdentity("C") // checking final state - assert.Equal(t, aclpb.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) - assert.Equal(t, aclpb.ACLUserPermissions_Writer, aclList.ACLState().GetUserStates()[idB].Permissions) - assert.Equal(t, aclpb.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) - assert.Equal(t, aclList.Head().Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) + assert.Equal(t, aclrecordproto.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) + assert.Equal(t, aclrecordproto.ACLUserPermissions_Writer, aclList.ACLState().GetUserStates()[idB].Permissions) + assert.Equal(t, aclrecordproto.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) + assert.Equal(t, aclList.Head().CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) var records []*ACLRecord aclList.Iterate(func(record *ACLRecord) (IsContinue bool) { @@ -44,7 +44,7 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { assert.NoError(t, err, "should have no error with permissions of B in the record 2") assert.Equal(t, UserPermissionPair{ Identity: idB, - Permission: aclpb.ACLUserPermissions_Writer, + Permission: aclrecordproto.ACLUserPermissions_Writer, }, perm) } @@ -62,9 +62,9 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { idC := keychain.GetIdentity("C") // checking final state - assert.Equal(t, aclpb.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) - assert.Equal(t, aclpb.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) - assert.Equal(t, aclList.Head().Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) + assert.Equal(t, aclrecordproto.ACLUserPermissions_Admin, aclList.ACLState().GetUserStates()[idA].Permissions) + assert.Equal(t, aclrecordproto.ACLUserPermissions_Reader, aclList.ACLState().GetUserStates()[idC].Permissions) + assert.Equal(t, aclList.Head().CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) _, exists := aclList.ACLState().GetUserStates()[idB] assert.Equal(t, false, exists) @@ -78,13 +78,13 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { // checking permissions at specific records assert.Equal(t, 4, len(records)) - assert.NotEqual(t, records[2].Content.CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) + assert.NotEqual(t, records[2].CurrentReadKeyHash, aclList.ACLState().CurrentReadKeyHash()) perm, err := aclList.ACLState().PermissionsAtRecord(records[2].Id, idB) assert.NoError(t, err, "should have no error with permissions of B in the record 2") assert.Equal(t, UserPermissionPair{ Identity: idB, - Permission: aclpb.ACLUserPermissions_Writer, + Permission: aclrecordproto.ACLUserPermissions_Writer, }, perm) _, err = aclList.ACLState().PermissionsAtRecord(records[3].Id, idB) diff --git a/pkg/acl/testutils/acllistbuilder/keychain.go b/pkg/acl/testutils/acllistbuilder/keychain.go index b6112ae9..0a32293e 100644 --- a/pkg/acl/testutils/acllistbuilder/keychain.go +++ b/pkg/acl/testutils/acllistbuilder/keychain.go @@ -1,6 +1,7 @@ package acllistbuilder import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "hash/fnv" @@ -21,6 +22,7 @@ type Keychain struct { ReadKeys map[string]*SymKey ReadKeysByHash map[uint64]*SymKey GeneratedIdentities map[string]string + DerivedIdentity string coder signingkey.PubKeyDecoder } @@ -37,6 +39,7 @@ func NewKeychain() *Keychain { } func (k *Keychain) ParseKeys(keys *Keys) { + k.DerivedIdentity = keys.Derived for _, encKey := range keys.Enc { k.AddEncryptionKey(encKey) } @@ -123,6 +126,13 @@ func (k *Keychain) AddReadKey(key *Key) { if err != nil { panic("should be able to generate symmetric key") } + } else if key.Value == "derived" { + signKey, _ := k.SigningKeys[k.DerivedIdentity].Raw() + encKey, _ := k.EncryptionKeys[k.DerivedIdentity].Raw() + rkey, err = aclrecordproto.ACLReadKeyDerive(signKey, encKey) + if err != nil { + panic("should be able to derive symmetric key") + } } else { rkey, err = symmetric.FromString(key.Value) if err != nil { @@ -150,7 +160,7 @@ func (k *Keychain) AddKey(key *Key) { } switch parts[1] { - case "Sign": + case "Signature": k.AddSigningKey(key) case "Enc": k.AddEncryptionKey(key) diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index c6d8703a..ca1b1649 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -3,12 +3,13 @@ package acllistbuilder import ( "context" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/yamltests" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" + "hash/fnv" "io/ioutil" "path" "time" @@ -19,17 +20,18 @@ import ( type ACLListStorageBuilder struct { aclList string - records []*aclpb.ACLRecord - rawRecords []*aclpb.RawACLRecord + records []*aclrecordproto.ACLRecord + rawRecords []*aclrecordproto.RawACLRecordWithId indexes map[string]int keychain *Keychain - header *aclpb.ACLHeader + rawRoot *aclrecordproto.RawACLRecordWithId + root *aclrecordproto.ACLRoot id string } func NewACLListStorageBuilder(keychain *Keychain) *ACLListStorageBuilder { return &ACLListStorageBuilder{ - records: make([]*aclpb.ACLRecord, 0), + records: make([]*aclrecordproto.ACLRecord, 0), indexes: make(map[string]int), keychain: keychain, } @@ -58,47 +60,66 @@ func NewACLListStorageBuilderFromFile(file string) (*ACLListStorageBuilder, erro return tb, nil } -func (t *ACLListStorageBuilder) createRaw(rec *aclpb.ACLRecord) *aclpb.RawACLRecord { - aclMarshaled, err := proto.Marshal(rec) +func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) *aclrecordproto.RawACLRecordWithId { + protoMarshalled, err := rec.Marshal() if err != nil { panic("should be able to marshal final acl message!") } - signature, err := t.keychain.SigningKeysByIdentity[string(rec.Identity)].Sign(aclMarshaled) + signature, err := t.keychain.SigningKeysByIdentity[string(identity)].Sign(protoMarshalled) if err != nil { panic("should be able to sign final acl message!") } - id, _ := cid.NewCIDFromBytes(aclMarshaled) - - return &aclpb.RawACLRecord{ - Payload: aclMarshaled, + rawRec := &aclrecordproto.RawACLRecord{ + Payload: protoMarshalled, Signature: signature, - Id: id, + } + + rawMarshalled, err := proto.Marshal(rawRec) + if err != nil { + panic(err) + } + + id, _ := cid.NewCIDFromBytes(rawMarshalled) + + return &aclrecordproto.RawACLRecordWithId{ + Payload: rawMarshalled, + Id: id, } } -func (t *ACLListStorageBuilder) getRecord(idx int) *aclpb.RawACLRecord { - return t.rawRecords[idx] +func (t *ACLListStorageBuilder) getRecord(idx int) *aclrecordproto.RawACLRecordWithId { + if idx > 0 { + return t.rawRecords[idx-1] + } + return t.rawRoot } -func (t *ACLListStorageBuilder) Head() (*aclpb.RawACLRecord, error) { - return t.getRecord(len(t.records) - 1), nil +func (t *ACLListStorageBuilder) Head() (*aclrecordproto.RawACLRecordWithId, error) { + l := len(t.records) + if l > 1 { + return t.rawRecords[l-2], nil + } + return t.rawRoot, nil } -func (t *ACLListStorageBuilder) Header() (*aclpb.ACLHeader, error) { - return t.header, nil +func (t *ACLListStorageBuilder) Root() (*aclrecordproto.RawACLRecordWithId, error) { + return t.rawRoot, nil } -func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) { +func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) { recIdx, ok := t.indexes[id] if !ok { + if id == t.rawRoot.Id { + return t.rawRoot, nil + } return nil, fmt.Errorf("no such record") } return t.getRecord(recIdx), nil } -func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error { +func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error { panic("implement me") } @@ -106,7 +127,7 @@ func (t *ACLListStorageBuilder) ID() (string, error) { return t.id, nil } -func (t *ACLListStorageBuilder) GetRawRecords() []*aclpb.RawACLRecord { +func (t *ACLListStorageBuilder) GetRawRecords() []*aclrecordproto.RawACLRecordWithId { return t.rawRecords } @@ -122,29 +143,29 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) { prevId := "" for idx, rec := range tree.Records { newRecord := t.parseRecord(rec, prevId) - rawRecord := t.createRaw(newRecord) + rawRecord := t.createRaw(newRecord, newRecord.Identity) t.records = append(t.records, newRecord) - t.rawRecords = append(t.rawRecords, t.createRaw(newRecord)) + t.rawRecords = append(t.rawRecords, rawRecord) t.indexes[rawRecord.Id] = idx prevId = rawRecord.Id } - t.createHeaderAndId() + t.parseRoot(tree.Root) } -func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.ACLRecord { +func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto.ACLRecord { k := t.keychain.GetKey(rec.ReadKey).(*SymKey) - var aclChangeContents []*aclpb.ACLContentValue + var aclChangeContents []*aclrecordproto.ACLContentValue for _, ch := range rec.AclChanges { aclChangeContent := t.parseACLChange(ch) aclChangeContents = append(aclChangeContents, aclChangeContent) } - data := &aclpb.ACLData{ + data := &aclrecordproto.ACLData{ AclContent: aclChangeContents, } bytes, _ := data.Marshal() - return &aclpb.ACLRecord{ + return &aclrecordproto.ACLRecord{ PrevId: prevId, Identity: []byte(t.keychain.GetIdentity(rec.Identity)), Data: bytes, @@ -153,7 +174,7 @@ func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclpb.A } } -func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACLContentValue) { +func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecordproto.ACLContentValue) { switch { case ch.UserAdd != nil: add := ch.UserAdd @@ -161,9 +182,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL encKey := t.keychain.GetKey(add.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserAdd{ - UserAdd: &aclpb.ACLUserAdd{ + convCh = &aclrecordproto.ACLContentValue{ + Value: &aclrecordproto.ACLContentValue_UserAdd{ + UserAdd: &aclrecordproto.ACLUserAdd{ Identity: []byte(t.keychain.GetIdentity(add.Identity)), EncryptionKey: rawKey, EncryptedReadKeys: t.encryptReadKeys(add.EncryptedReadKeys, encKey), @@ -185,13 +206,13 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL panic(err) } - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserJoin{ - UserJoin: &aclpb.ACLUserJoin{ + convCh = &aclrecordproto.ACLContentValue{ + Value: &aclrecordproto.ACLContentValue_UserJoin{ + UserJoin: &aclrecordproto.ACLUserJoin{ Identity: []byte(t.keychain.GetIdentity(join.Identity)), EncryptionKey: rawKey, AcceptSignature: signature, - UserInviteId: join.InviteId, + InviteId: join.InviteId, EncryptedReadKeys: t.encryptReadKeys(join.EncryptedReadKeys, encKey), }, }, @@ -203,9 +224,9 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL GetKey(invite.EncryptionKey).(encryptionkey.PrivKey) rawEncKey, _ := encKey.GetPublic().Raw() - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserInvite{ - UserInvite: &aclpb.ACLUserInvite{ + convCh = &aclrecordproto.ACLContentValue{ + Value: &aclrecordproto.ACLContentValue_UserInvite{ + UserInvite: &aclrecordproto.ACLUserInvite{ AcceptPublicKey: rawAcceptKey, EncryptPublicKey: rawEncKey, EncryptedReadKeys: t.encryptReadKeys(invite.EncryptedReadKeys, encKey), @@ -214,23 +235,12 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL }, }, } - case ch.UserConfirm != nil: - confirm := ch.UserConfirm - - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserConfirm{ - UserConfirm: &aclpb.ACLUserConfirm{ - Identity: []byte(t.keychain.GetIdentity(confirm.Identity)), - UserAddId: confirm.UserAddId, - }, - }, - } case ch.UserPermissionChange != nil: permissionChange := ch.UserPermissionChange - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserPermissionChange{ - UserPermissionChange: &aclpb.ACLUserPermissionChange{ + convCh = &aclrecordproto.ACLContentValue{ + Value: &aclrecordproto.ACLContentValue_UserPermissionChange{ + UserPermissionChange: &aclrecordproto.ACLUserPermissionChange{ Identity: []byte(t.keychain.GetIdentity(permissionChange.Identity)), Permissions: t.convertPermission(permissionChange.Permission), }, @@ -241,7 +251,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL newReadKey := t.keychain.GetKey(remove.NewReadKey).(*SymKey) - var replaces []*aclpb.ACLReadKeyReplace + var replaces []*aclrecordproto.ACLReadKeyReplace for _, id := range remove.IdentitiesLeft { identity := t.keychain.GetIdentity(id) encKey := t.keychain.EncryptionKeys[id] @@ -250,16 +260,16 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclpb.ACL if err != nil { panic(err) } - replaces = append(replaces, &aclpb.ACLReadKeyReplace{ + replaces = append(replaces, &aclrecordproto.ACLReadKeyReplace{ Identity: []byte(identity), EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) } - convCh = &aclpb.ACLContentValue{ - Value: &aclpb.ACLContentValue_UserRemove{ - UserRemove: &aclpb.ACLUserRemove{ + convCh = &aclrecordproto.ACLContentValue{ + Value: &aclrecordproto.ACLContentValue_UserRemove{ + UserRemove: &aclrecordproto.ACLUserRemove{ Identity: []byte(t.keychain.GetIdentity(remove.RemovedIdentity)), ReadKeyReplaces: replaces, }, @@ -286,20 +296,20 @@ func (t *ACLListStorageBuilder) encryptReadKeys(keys []string, encKey encryption return } -func (t *ACLListStorageBuilder) convertPermission(perm string) aclpb.ACLUserPermissions { +func (t *ACLListStorageBuilder) convertPermission(perm string) aclrecordproto.ACLUserPermissions { switch perm { case "admin": - return aclpb.ACLUserPermissions_Admin + return aclrecordproto.ACLUserPermissions_Admin case "writer": - return aclpb.ACLUserPermissions_Writer + return aclrecordproto.ACLUserPermissions_Writer case "reader": - return aclpb.ACLUserPermissions_Reader + return aclrecordproto.ACLUserPermissions_Reader default: panic(fmt.Sprintf("incorrect permission: %s", perm)) } } -func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclpb.ACLRecord, id string) error) (err error) { +func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto.ACLRecord, id string) error) (err error) { for i := len(t.records) - 1; i >= 0; i-- { err = f(t.records[i], t.rawRecords[i].Id) if err != nil { @@ -309,11 +319,22 @@ func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclpb.ACLRecord, id return nil } -func (t *ACLListStorageBuilder) createHeaderAndId() { - t.header = &aclpb.ACLHeader{ - FirstId: t.rawRecords[0].Id, +func (t *ACLListStorageBuilder) parseRoot(root *Root) { + rawSignKey, _ := t.keychain.GetKey(root.Identity).(signingkey.PrivKey).GetPublic().Raw() + rawEncKey, _ := t.keychain.GetKey(root.EncryptionKey).(encryptionkey.PrivKey).GetPublic().Raw() + readKey, _ := aclrecordproto.ACLReadKeyDerive(rawSignKey, rawEncKey) + hasher := fnv.New64() + hasher.Write(readKey.Bytes()) + t.root = &aclrecordproto.ACLRoot{ + Identity: rawSignKey, + EncryptionKey: rawEncKey, + SpaceId: root.SpaceId, + EncryptedReadKey: nil, + DerivationScheme: "scheme", + CurrentReadKeyHash: hasher.Sum64(), } - bytes, _ := t.header.Marshal() + t.rawRoot = t.createRaw(t.root, rawSignKey) + bytes, _ := t.rawRoot.Marshal() id, _ := cid.NewCIDFromBytes(bytes) t.id = id } diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go index d7dfc85f..34b6fc92 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuildergraph_nix.go @@ -9,7 +9,7 @@ package acllistbuilder import ( "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/gogo/protobuf/proto" "strings" @@ -33,11 +33,11 @@ func (t *ACLListStorageBuilder) Graph() (string, error) { graph.SetDir(true) var nodes = make(map[string]struct{}) - var addNodes = func(r *aclpb.ACLRecord, id string) error { + var addNodes = func(r *aclrecordproto.ACLRecord, id string) error { style := "solid" var chSymbs []string - aclData := &aclpb.ACLData{} + aclData := &aclrecordproto.ACLData{} err := proto.Unmarshal(r.GetData(), aclData) if err != nil { return err @@ -92,7 +92,7 @@ func (t *ACLListStorageBuilder) Graph() (string, error) { return nil } - var addLinks = func(r *aclpb.ACLRecord, id string) error { + var addLinks = func(r *aclrecordproto.ACLRecord, id string) error { if r.PrevId == "" { return nil } diff --git a/pkg/acl/testutils/acllistbuilder/ymlentities.go b/pkg/acl/testutils/acllistbuilder/ymlentities.go index 4d0fb069..2b77c698 100644 --- a/pkg/acl/testutils/acllistbuilder/ymlentities.go +++ b/pkg/acl/testutils/acllistbuilder/ymlentities.go @@ -6,9 +6,10 @@ type Key struct { } type Keys struct { - Enc []*Key `yaml:"Enc"` - Sign []*Key `yaml:"Sign"` - Read []*Key `yaml:"Read"` + Derived string `yaml:"Derived"` + Enc []*Key `yaml:"Enc"` + Sign []*Key `yaml:"Sign"` + Read []*Key `yaml:"Read"` } type ACLChange struct { @@ -35,11 +36,6 @@ type ACLChange struct { InviteId string `yaml:"inviteId"` } `yaml:"userInvite"` - UserConfirm *struct { - Identity string `yaml:"identity"` - UserAddId string `yaml:"UserAddId"` - } `yaml:"userConfirm"` - UserRemove *struct { RemovedIdentity string `yaml:"removedIdentity"` NewReadKey string `yaml:"newReadKey"` @@ -63,7 +59,14 @@ type Header struct { IsWorkspace bool `yaml:"isWorkspace"` } +type Root struct { + Identity string `yaml:"identity"` + EncryptionKey string `yaml:"encryptionKey"` + SpaceId string `yaml:"spaceId"` +} + type YMLList struct { + Root *Root Records []*Record `yaml:"records"` Keys Keys `yaml:"keys"` diff --git a/pkg/acl/testutils/yamltests/userjoinexample.yml b/pkg/acl/testutils/yamltests/userjoinexample.yml index 014c9349..45abf458 100644 --- a/pkg/acl/testutils/yamltests/userjoinexample.yml +++ b/pkg/acl/testutils/yamltests/userjoinexample.yml @@ -1,12 +1,8 @@ -records: +root: - identity: A - aclChanges: - - userAdd: - identity: A - permission: admin - encryptionKey: key.Enc.A - encryptedReadKeys: [key.Read.1] - readKey: key.Read.1 + encryptionKey: key.Enc.A + spaceId: space +records: - identity: A aclChanges: - userInvite: @@ -31,6 +27,7 @@ records: encryptedReadKeys: [key.Read.1] readKey: key.Read.1 keys: + Derived: A Enc: - name: A value: generated @@ -51,4 +48,4 @@ keys: value: generated Read: - name: 1 - value: generated + value: derived diff --git a/pkg/acl/testutils/yamltests/userremoveexample.yml b/pkg/acl/testutils/yamltests/userremoveexample.yml index 9d90468c..39a30f25 100644 --- a/pkg/acl/testutils/yamltests/userremoveexample.yml +++ b/pkg/acl/testutils/yamltests/userremoveexample.yml @@ -1,12 +1,8 @@ -records: +root: - identity: A - aclChanges: - - userAdd: - identity: A - permission: admin - encryptionKey: key.Enc.A - encryptedReadKeys: [key.Read.1] - readKey: key.Read.1 + encryptionKey: key.Enc.A + spaceId: space +records: - identity: A aclChanges: - userInvite: @@ -38,6 +34,7 @@ records: identitiesLeft: [A, C] readKey: key.Read.2 keys: + Derived: A Enc: - name: A value: generated @@ -58,6 +55,6 @@ keys: value: generated Read: - name: 1 - value: generated + value: derived - name: 2 value: generated From 632d73698f33949e8532b822ff8679a014f5cca4 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 14:41:50 +0200 Subject: [PATCH 33/44] More test fixes --- pkg/acl/list/aclstate.go | 6 +- pkg/acl/list/aclstatebuilder.go | 20 ++--- pkg/acl/list/list.go | 9 ++- pkg/acl/testutils/acllistbuilder/keychain.go | 74 +++++++++---------- .../acllistbuilder/liststoragebuilder.go | 41 ++++------ .../testutils/acllistbuilder/ymlentities.go | 5 +- .../testutils/yamltests/userjoinexample.yml | 5 +- .../testutils/yamltests/userremoveexample.yml | 5 +- 8 files changed, 78 insertions(+), 87 deletions(-) diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 7caf345a..a8df8c53 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -7,7 +7,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" @@ -50,6 +49,7 @@ type ACLState struct { } func newACLStateWithKeys( + id string, signingKey signingkey.PrivKey, encryptionKey encryptionkey.PrivKey) (*ACLState, error) { identity, err := signingKey.Raw() @@ -57,6 +57,7 @@ func newACLStateWithKeys( return nil, err } return &ACLState{ + id: id, identity: string(identity), signingKey: signingKey, encryptionKey: encryptionKey, @@ -67,8 +68,9 @@ func newACLStateWithKeys( }, nil } -func newACLState(decoder keys.Decoder) *ACLState { +func newACLState(id string) *ACLState { return &ACLState{ + id: id, userReadKeys: make(map[uint64]*symmetric.Key), userStates: make(map[string]*aclrecordproto.ACLUserState), userInvites: make(map[string]*aclrecordproto.ACLUserInvite), diff --git a/pkg/acl/list/aclstatebuilder.go b/pkg/acl/list/aclstatebuilder.go index 2d7693fb..75b606af 100644 --- a/pkg/acl/list/aclstatebuilder.go +++ b/pkg/acl/list/aclstatebuilder.go @@ -2,7 +2,6 @@ package list import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) @@ -10,31 +9,32 @@ import ( type aclStateBuilder struct { signPrivKey signingkey.PrivKey encPrivKey encryptionkey.PrivKey - decoder keys.Decoder + id string } -func newACLStateBuilderWithIdentity(decoder keys.Decoder, accountData *account.AccountData) *aclStateBuilder { +func newACLStateBuilderWithIdentity(accountData *account.AccountData) *aclStateBuilder { return &aclStateBuilder{ - decoder: decoder, signPrivKey: accountData.SignKey, encPrivKey: accountData.EncKey, } } -func newACLStateBuilder(decoder keys.Decoder) *aclStateBuilder { - return &aclStateBuilder{ - decoder: decoder, - } +func newACLStateBuilder() *aclStateBuilder { + return &aclStateBuilder{} +} + +func (sb *aclStateBuilder) Init(id string) { + sb.id = id } func (sb *aclStateBuilder) Build(records []*ACLRecord) (state *ACLState, err error) { if sb.encPrivKey != nil && sb.signPrivKey != nil { - state, err = newACLStateWithKeys(sb.signPrivKey, sb.encPrivKey) + state, err = newACLStateWithKeys(sb.id, sb.signPrivKey, sb.encPrivKey) if err != nil { return } } else { - state = newACLState(sb.decoder) + state = newACLState(sb.id) } for _, rec := range records { err = state.applyRecord(rec) diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index aad93a8f..f940e4b4 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -54,7 +54,7 @@ func BuildACLListWithIdentity(acc *account.AccountData, storage storage.ListStor if err != nil { return nil, err } - builder := newACLStateBuilderWithIdentity(acc.Decoder, acc) + builder := newACLStateBuilderWithIdentity(acc) return build(id, builder, newACLRecordBuilder(id, common.NewKeychain()), storage) } @@ -63,7 +63,7 @@ func BuildACLList(decoder keys.Decoder, storage storage.ListStorage) (ACLList, e if err != nil { return nil, err } - return build(id, newACLStateBuilder(decoder), newACLRecordBuilder(id, common.NewKeychain()), storage) + return build(id, newACLStateBuilder(), newACLRecordBuilder(id, common.NewKeychain()), storage) } func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder, storage storage.ListStorage) (list ACLList, err error) { @@ -87,7 +87,7 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder } records := []*ACLRecord{record} - for record.PrevId != "" { + for record.PrevId != "" && record.PrevId != id { rawRecordWithId, err = storage.GetRawRecord(context.Background(), record.PrevId) if err != nil { return @@ -99,6 +99,8 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder } records = append(records, record) } + // adding root in the end, because we already parsed it + records = append(records, aclRecRoot) indexes := make(map[string]int) for i, j := 0, len(records)-1; i < j; i, j = i+1, j-1 { @@ -111,6 +113,7 @@ func build(id string, stateBuilder *aclStateBuilder, recBuilder ACLRecordBuilder indexes[records[len(records)/2].Id] = len(records) / 2 } + stateBuilder.Init(id) state, err := stateBuilder.Build(records) if err != nil { return diff --git a/pkg/acl/testutils/acllistbuilder/keychain.go b/pkg/acl/testutils/acllistbuilder/keychain.go index 0a32293e..e26f389b 100644 --- a/pkg/acl/testutils/acllistbuilder/keychain.go +++ b/pkg/acl/testutils/acllistbuilder/keychain.go @@ -15,30 +15,30 @@ type SymKey struct { Key *symmetric.Key } -type Keychain struct { - SigningKeys map[string]signingkey.PrivKey - SigningKeysByIdentity map[string]signingkey.PrivKey - EncryptionKeys map[string]encryptionkey.PrivKey - ReadKeys map[string]*SymKey - ReadKeysByHash map[uint64]*SymKey - GeneratedIdentities map[string]string - DerivedIdentity string - coder signingkey.PubKeyDecoder +type YAMLKeychain struct { + SigningKeysByYAMLIdentity map[string]signingkey.PrivKey + SigningKeysByRealIdentity map[string]signingkey.PrivKey + EncryptionKeysByYAMLIdentity map[string]encryptionkey.PrivKey + ReadKeysByYAMLIdentity map[string]*SymKey + ReadKeysByHash map[uint64]*SymKey + GeneratedIdentities map[string]string + DerivedIdentity string + coder signingkey.PubKeyDecoder } -func NewKeychain() *Keychain { - return &Keychain{ - SigningKeys: map[string]signingkey.PrivKey{}, - SigningKeysByIdentity: map[string]signingkey.PrivKey{}, - EncryptionKeys: map[string]encryptionkey.PrivKey{}, - GeneratedIdentities: map[string]string{}, - ReadKeys: map[string]*SymKey{}, - ReadKeysByHash: map[uint64]*SymKey{}, - coder: signingkey.NewEd25519PubKeyDecoder(), +func NewKeychain() *YAMLKeychain { + return &YAMLKeychain{ + SigningKeysByYAMLIdentity: map[string]signingkey.PrivKey{}, + SigningKeysByRealIdentity: map[string]signingkey.PrivKey{}, + EncryptionKeysByYAMLIdentity: map[string]encryptionkey.PrivKey{}, + GeneratedIdentities: map[string]string{}, + ReadKeysByYAMLIdentity: map[string]*SymKey{}, + ReadKeysByHash: map[uint64]*SymKey{}, + coder: signingkey.NewEd25519PubKeyDecoder(), } } -func (k *Keychain) ParseKeys(keys *Keys) { +func (k *YAMLKeychain) ParseKeys(keys *Keys) { k.DerivedIdentity = keys.Derived for _, encKey := range keys.Enc { k.AddEncryptionKey(encKey) @@ -53,8 +53,8 @@ func (k *Keychain) ParseKeys(keys *Keys) { } } -func (k *Keychain) AddEncryptionKey(key *Key) { - if _, exists := k.EncryptionKeys[key.Name]; exists { +func (k *YAMLKeychain) AddEncryptionKey(key *Key) { + if _, exists := k.EncryptionKeysByYAMLIdentity[key.Name]; exists { return } var ( @@ -74,11 +74,11 @@ func (k *Keychain) AddEncryptionKey(key *Key) { } newPrivKey = privKey.(encryptionkey.PrivKey) } - k.EncryptionKeys[key.Name] = newPrivKey + k.EncryptionKeysByYAMLIdentity[key.Name] = newPrivKey } -func (k *Keychain) AddSigningKey(key *Key) { - if _, exists := k.SigningKeys[key.Name]; exists { +func (k *YAMLKeychain) AddSigningKey(key *Key) { + if _, exists := k.SigningKeysByYAMLIdentity[key.Name]; exists { return } var ( @@ -101,19 +101,19 @@ func (k *Keychain) AddSigningKey(key *Key) { pubKey = newPrivKey.GetPublic() } - k.SigningKeys[key.Name] = newPrivKey + k.SigningKeysByYAMLIdentity[key.Name] = newPrivKey rawPubKey, err := pubKey.Raw() if err != nil { panic(err) } encoded := string(rawPubKey) - k.SigningKeysByIdentity[encoded] = newPrivKey + k.SigningKeysByRealIdentity[encoded] = newPrivKey k.GeneratedIdentities[key.Name] = encoded } -func (k *Keychain) AddReadKey(key *Key) { - if _, exists := k.ReadKeys[key.Name]; exists { +func (k *YAMLKeychain) AddReadKey(key *Key) { + if _, exists := k.ReadKeysByYAMLIdentity[key.Name]; exists { return } @@ -127,8 +127,8 @@ func (k *Keychain) AddReadKey(key *Key) { panic("should be able to generate symmetric key") } } else if key.Value == "derived" { - signKey, _ := k.SigningKeys[k.DerivedIdentity].Raw() - encKey, _ := k.EncryptionKeys[k.DerivedIdentity].Raw() + signKey, _ := k.SigningKeysByYAMLIdentity[k.DerivedIdentity].Raw() + encKey, _ := k.EncryptionKeysByYAMLIdentity[k.DerivedIdentity].Raw() rkey, err = aclrecordproto.ACLReadKeyDerive(signKey, encKey) if err != nil { panic("should be able to derive symmetric key") @@ -143,7 +143,7 @@ func (k *Keychain) AddReadKey(key *Key) { hasher := fnv.New64() hasher.Write(rkey.Bytes()) - k.ReadKeys[key.Name] = &SymKey{ + k.ReadKeysByYAMLIdentity[key.Name] = &SymKey{ Hash: hasher.Sum64(), Key: rkey, } @@ -153,7 +153,7 @@ func (k *Keychain) AddReadKey(key *Key) { } } -func (k *Keychain) AddKey(key *Key) { +func (k *YAMLKeychain) AddKey(key *Key) { parts := strings.Split(key.Name, ".") if len(parts) != 3 { panic("cannot parse a key") @@ -171,7 +171,7 @@ func (k *Keychain) AddKey(key *Key) { } } -func (k *Keychain) GetKey(key string) interface{} { +func (k *YAMLKeychain) GetKey(key string) interface{} { parts := strings.Split(key, ".") if len(parts) != 3 { panic("cannot parse a key") @@ -180,15 +180,15 @@ func (k *Keychain) GetKey(key string) interface{} { switch parts[1] { case "Sign": - if key, exists := k.SigningKeys[name]; exists { + if key, exists := k.SigningKeysByYAMLIdentity[name]; exists { return key } case "Enc": - if key, exists := k.EncryptionKeys[name]; exists { + if key, exists := k.EncryptionKeysByYAMLIdentity[name]; exists { return key } case "Read": - if key, exists := k.ReadKeys[name]; exists { + if key, exists := k.ReadKeysByYAMLIdentity[name]; exists { return key } default: @@ -197,6 +197,6 @@ func (k *Keychain) GetKey(key string) interface{} { return nil } -func (k *Keychain) GetIdentity(name string) string { +func (k *YAMLKeychain) GetIdentity(name string) string { return k.GeneratedIdentities[name] } diff --git a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go index ca1b1649..d855ac99 100644 --- a/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go +++ b/pkg/acl/testutils/acllistbuilder/liststoragebuilder.go @@ -23,13 +23,13 @@ type ACLListStorageBuilder struct { records []*aclrecordproto.ACLRecord rawRecords []*aclrecordproto.RawACLRecordWithId indexes map[string]int - keychain *Keychain + keychain *YAMLKeychain rawRoot *aclrecordproto.RawACLRecordWithId root *aclrecordproto.ACLRoot id string } -func NewACLListStorageBuilder(keychain *Keychain) *ACLListStorageBuilder { +func NewACLListStorageBuilder(keychain *YAMLKeychain) *ACLListStorageBuilder { return &ACLListStorageBuilder{ records: make([]*aclrecordproto.ACLRecord, 0), indexes: make(map[string]int), @@ -66,7 +66,7 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) panic("should be able to marshal final acl message!") } - signature, err := t.keychain.SigningKeysByIdentity[string(identity)].Sign(protoMarshalled) + signature, err := t.keychain.SigningKeysByRealIdentity[string(identity)].Sign(protoMarshalled) if err != nil { panic("should be able to sign final acl message!") } @@ -89,17 +89,10 @@ func (t *ACLListStorageBuilder) createRaw(rec proto.Marshaler, identity []byte) } } -func (t *ACLListStorageBuilder) getRecord(idx int) *aclrecordproto.RawACLRecordWithId { - if idx > 0 { - return t.rawRecords[idx-1] - } - return t.rawRoot -} - func (t *ACLListStorageBuilder) Head() (*aclrecordproto.RawACLRecordWithId, error) { l := len(t.records) - if l > 1 { - return t.rawRecords[l-2], nil + if l > 0 { + return t.rawRecords[l-1], nil } return t.rawRoot, nil } @@ -116,7 +109,7 @@ func (t *ACLListStorageBuilder) GetRawRecord(ctx context.Context, id string) (*a } return nil, fmt.Errorf("no such record") } - return t.getRecord(recIdx), nil + return t.rawRecords[recIdx], nil } func (t *ACLListStorageBuilder) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error { @@ -131,7 +124,7 @@ func (t *ACLListStorageBuilder) GetRawRecords() []*aclrecordproto.RawACLRecordWi return t.rawRecords } -func (t *ACLListStorageBuilder) GetKeychain() *Keychain { +func (t *ACLListStorageBuilder) GetKeychain() *YAMLKeychain { return t.keychain } @@ -140,7 +133,8 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) { // are specified in the yml file, because our identities should be Ed25519 // the same thing is happening for the encryption keys t.keychain.ParseKeys(&tree.Keys) - prevId := "" + t.parseRoot(tree.Root) + prevId := t.id for idx, rec := range tree.Records { newRecord := t.parseRecord(rec, prevId) rawRecord := t.createRaw(newRecord, newRecord.Identity) @@ -149,8 +143,6 @@ func (t *ACLListStorageBuilder) Parse(tree *YMLList) { t.indexes[rawRecord.Id] = idx prevId = rawRecord.Id } - - t.parseRoot(tree.Root) } func (t *ACLListStorageBuilder) parseRecord(rec *Record, prevId string) *aclrecordproto.ACLRecord { @@ -199,7 +191,7 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord GetKey(join.EncryptionKey).(encryptionkey.PrivKey) rawKey, _ := encKey.GetPublic().Raw() - idKey, _ := t.keychain.SigningKeys[join.Identity].GetPublic().Raw() + idKey, _ := t.keychain.SigningKeysByYAMLIdentity[join.Identity].GetPublic().Raw() signKey := t.keychain.GetKey(join.AcceptSignature).(signingkey.PrivKey) signature, err := signKey.Sign(idKey) if err != nil { @@ -253,15 +245,14 @@ func (t *ACLListStorageBuilder) parseACLChange(ch *ACLChange) (convCh *aclrecord var replaces []*aclrecordproto.ACLReadKeyReplace for _, id := range remove.IdentitiesLeft { - identity := t.keychain.GetIdentity(id) - encKey := t.keychain.EncryptionKeys[id] + encKey := t.keychain.EncryptionKeysByYAMLIdentity[id] rawEncKey, _ := encKey.GetPublic().Raw() encReadKey, err := encKey.GetPublic().Encrypt(newReadKey.Key.Bytes()) if err != nil { panic(err) } replaces = append(replaces, &aclrecordproto.ACLReadKeyReplace{ - Identity: []byte(identity), + Identity: []byte(t.keychain.GetIdentity(id)), EncryptionKey: rawEncKey, EncryptedReadKey: encReadKey, }) @@ -320,8 +311,8 @@ func (t *ACLListStorageBuilder) traverseFromHead(f func(rec *aclrecordproto.ACLR } func (t *ACLListStorageBuilder) parseRoot(root *Root) { - rawSignKey, _ := t.keychain.GetKey(root.Identity).(signingkey.PrivKey).GetPublic().Raw() - rawEncKey, _ := t.keychain.GetKey(root.EncryptionKey).(encryptionkey.PrivKey).GetPublic().Raw() + rawSignKey, _ := t.keychain.SigningKeysByYAMLIdentity[root.Identity].GetPublic().Raw() + rawEncKey, _ := t.keychain.EncryptionKeysByYAMLIdentity[root.Identity].GetPublic().Raw() readKey, _ := aclrecordproto.ACLReadKeyDerive(rawSignKey, rawEncKey) hasher := fnv.New64() hasher.Write(readKey.Bytes()) @@ -334,7 +325,5 @@ func (t *ACLListStorageBuilder) parseRoot(root *Root) { CurrentReadKeyHash: hasher.Sum64(), } t.rawRoot = t.createRaw(t.root, rawSignKey) - bytes, _ := t.rawRoot.Marshal() - id, _ := cid.NewCIDFromBytes(bytes) - t.id = id + t.id = t.rawRoot.Id } diff --git a/pkg/acl/testutils/acllistbuilder/ymlentities.go b/pkg/acl/testutils/acllistbuilder/ymlentities.go index 2b77c698..df1e43c6 100644 --- a/pkg/acl/testutils/acllistbuilder/ymlentities.go +++ b/pkg/acl/testutils/acllistbuilder/ymlentities.go @@ -60,9 +60,8 @@ type Header struct { } type Root struct { - Identity string `yaml:"identity"` - EncryptionKey string `yaml:"encryptionKey"` - SpaceId string `yaml:"spaceId"` + Identity string `yaml:"identity"` + SpaceId string `yaml:"spaceId"` } type YMLList struct { diff --git a/pkg/acl/testutils/yamltests/userjoinexample.yml b/pkg/acl/testutils/yamltests/userjoinexample.yml index 45abf458..6d7bb48e 100644 --- a/pkg/acl/testutils/yamltests/userjoinexample.yml +++ b/pkg/acl/testutils/yamltests/userjoinexample.yml @@ -1,7 +1,6 @@ root: - - identity: A - encryptionKey: key.Enc.A - spaceId: space + identity: A + spaceId: space records: - identity: A aclChanges: diff --git a/pkg/acl/testutils/yamltests/userremoveexample.yml b/pkg/acl/testutils/yamltests/userremoveexample.yml index 39a30f25..6cf51b84 100644 --- a/pkg/acl/testutils/yamltests/userremoveexample.yml +++ b/pkg/acl/testutils/yamltests/userremoveexample.yml @@ -1,7 +1,6 @@ root: - - identity: A - encryptionKey: key.Enc.A - spaceId: space + identity: A + spaceId: space records: - identity: A aclChanges: From 9d73e1d5c1898ec83ce5d71db21d4a589c713cdf Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 20:32:59 +0200 Subject: [PATCH 34/44] Remove decoders and fix sync tree --- cmd/nodesgen/gen.go | 8 +- cmd/nodesgen/nodemap.yml | 4 +- common/account/service.go | 40 +++--- .../spacesyncproto/protos/spacesync.proto | 2 +- .../spacesyncproto/spacesync.pb.go | 132 +++++++++--------- common/commonspace/syncservice/syncservice.go | 14 +- common/commonspace/synctree/synctree.go | 4 +- pkg/acl/account/accountdata.go | 2 - pkg/acl/list/list.go | 3 +- pkg/acl/list/list_test.go | 5 +- pkg/acl/testutils/acllistbuilder/keychain.go | 11 +- pkg/acl/tree/objecttree.go | 6 +- pkg/acl/tree/objecttree_test.go | 17 +-- pkg/acl/tree/objecttreefactory.go | 13 +- service/node/service.go | 5 +- util/keys/asymmetric/encryptionkey/rsa.go | 8 -- util/keys/asymmetric/signingkey/ed25519.go | 42 ------ util/keys/asymmetric/signingkey/signingkey.go | 7 - util/keys/decode.go | 30 ++++ util/keys/decoder.go | 38 ----- util/keys/key.go | 7 - 21 files changed, 149 insertions(+), 249 deletions(-) create mode 100644 util/keys/decode.go delete mode 100644 util/keys/decoder.go diff --git a/cmd/nodesgen/gen.go b/cmd/nodesgen/gen.go index 069c3c59..3e1104a5 100644 --- a/cmd/nodesgen/gen.go +++ b/cmd/nodesgen/gen.go @@ -4,6 +4,7 @@ import ( "flag" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/peer" @@ -100,15 +101,12 @@ func genConfig(addresses []string, apiPort string) (config.Config, error) { return config.Config{}, err } - encKeyDecoder := encryptionkey.NewRSAPrivKeyDecoder() - signKeyDecoder := signingkey.NewEDPrivKeyDecoder() - - encEncKey, err := encKeyDecoder.EncodeToString(encKey) + encEncKey, err := keys.EncodeKeyToString(encKey) if err != nil { return config.Config{}, err } - encSignKey, err := signKeyDecoder.EncodeToString(signKey) + encSignKey, err := keys.EncodeKeyToString(signKey) if err != nil { return config.Config{}, err } diff --git a/cmd/nodesgen/nodemap.yml b/cmd/nodesgen/nodemap.yml index d7b776aa..27a0cb15 100644 --- a/cmd/nodesgen/nodemap.yml +++ b/cmd/nodesgen/nodemap.yml @@ -1,9 +1,7 @@ nodes: - grpcAddresses: - "127.0.0.1:4430" - - "127.0.0.1:4431" apiPort: "8080" - grpcAddresses: - - "127.0.0.1:4432" - - "127.0.0.1:4433" + - "127.0.0.1:4431" apiPort: "8081" diff --git a/common/account/service.go b/common/account/service.go index 7b0cc621..8cc55031 100644 --- a/common/account/service.go +++ b/common/account/service.go @@ -4,6 +4,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) @@ -34,33 +35,34 @@ func New() app.Component { func (s *service) Init(a *app.App) (err error) { cfg := a.MustComponent(config.CName).(*config.Config) - - // decoding our keys - privateEncryptionDecoder := encryptionkey.NewRSAPrivKeyDecoder() - privateSigningDecoder := signingkey.NewEDPrivKeyDecoder() - publicSigningDecoder := signingkey.NewEDPubKeyDecoder() + // TODO: add deviceKey acc := cfg.Account - decodedEncryptionKey, err := privateEncryptionDecoder.DecodeFromString(acc.EncryptionKey) - if err != nil { - return err - } - decodedSigningKey, err := privateSigningDecoder.DecodeFromString(acc.SigningKey) - if err != nil { - return err - } - signKey := decodedSigningKey.(signingkey.PrivKey) - identity, err := publicSigningDecoder.EncodeToString(signKey.GetPublic()) + decodedEncryptionKey, err := keys.DecodeKeyFromString( + acc.EncryptionKey, + encryptionkey.NewEncryptionRsaPrivKeyFromBytes, + nil) + if err != nil { + return err + } + + decodedSigningKey, err := keys.DecodeKeyFromString( + acc.SigningKey, + signingkey.NewSigningEd25519PrivKeyFromBytes, + nil) + if err != nil { + return err + } + + identity, err := decodedSigningKey.GetPublic().Raw() if err != nil { return err } - // TODO: using acl lib format basically, but we should simplify this s.accountData = &account.AccountData{ Identity: identity, - SignKey: signKey, - EncKey: decodedEncryptionKey.(encryptionkey.PrivKey), - Decoder: signingkey.NewEDPubKeyDecoder(), + SignKey: decodedSigningKey, + EncKey: decodedEncryptionKey, } s.peerId = acc.PeerId diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index a4bb3171..d4d65733 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -49,7 +49,7 @@ message HeadSyncResponse { message ObjectSyncMessage { string spaceId = 1; ObjectSyncContentValue content = 2; - treechange.RootChange treeHeader = 3; + treechange.RawTreeChangeWithId rootChange = 3; string treeId = 4; string trackingId = 5; // diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index a0e6bf89..6cbcba84 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -320,11 +320,11 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - TreeHeader *treechangeproto.RootChange `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` - TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + RootChange *treechangeproto.RawTreeChangeWithId `protobuf:"bytes,3,opt,name=rootChange,proto3" json:"rootChange,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -374,9 +374,9 @@ func (m *ObjectSyncMessage) GetContent() *ObjectSyncContentValue { return nil } -func (m *ObjectSyncMessage) GetTreeHeader() *treechangeproto.RootChange { +func (m *ObjectSyncMessage) GetRootChange() *treechangeproto.RawTreeChangeWithId { if m != nil { - return m.TreeHeader + return m.RootChange } return nil } @@ -831,57 +831,57 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 797 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x8e, 0xe3, 0x44, - 0x10, 0xb6, 0x33, 0x99, 0x49, 0x52, 0x99, 0x99, 0x0d, 0x0d, 0x3b, 0x98, 0x00, 0xd9, 0xe0, 0x03, - 0x8a, 0x40, 0x4a, 0x50, 0x90, 0x10, 0x30, 0x5c, 0xd8, 0x51, 0x46, 0x89, 0x56, 0xfc, 0xa8, 0x67, - 0x17, 0x24, 0xc4, 0xa5, 0xd7, 0xae, 0x4d, 0xcc, 0xda, 0x6e, 0xe3, 0xee, 0xb0, 0xe4, 0x09, 0xb8, - 0x80, 0x84, 0x78, 0x03, 0x9e, 0x85, 0x0b, 0xc7, 0x3d, 0xc2, 0x0d, 0xcd, 0xbc, 0x08, 0xea, 0xb2, - 0x1d, 0x3b, 0xc1, 0xbb, 0x1c, 0xf7, 0x12, 0x77, 0x7d, 0x5d, 0xf5, 0xf5, 0xd7, 0x55, 0xd5, 0x15, - 0xf8, 0xd0, 0x93, 0x51, 0x24, 0xe3, 0x49, 0xf6, 0x51, 0x89, 0xf0, 0x70, 0x42, 0xbf, 0x6a, 0x13, - 0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4e, - 0x53, 0x4c, 0xc2, 0xc0, 0x13, 0x3a, 0x90, 0xf1, 0x3d, 0xdc, 0x50, 0x3b, 0x36, 0xf9, 0x1e, 0x6a, - 0x26, 0xa8, 0x42, 0xcc, 0x5e, 0xf1, 0x31, 0xa7, 0xf5, 0x3b, 0x7d, 0x68, 0xcf, 0xd2, 0xf4, 0x42, - 0xfa, 0xa8, 0xd8, 0x29, 0xc0, 0x83, 0x18, 0x7f, 0x4c, 0xd0, 0xd3, 0xe8, 0xf7, 0xac, 0xe9, 0x6f, - 0x36, 0x1c, 0x92, 0x7e, 0xf6, 0x29, 0xb4, 0x8b, 0xe1, 0xc6, 0x5e, 0xab, 0x1b, 0x78, 0xd4, 0x22, - 0xfd, 0x7e, 0xed, 0x2c, 0xcc, 0x52, 0x74, 0x09, 0x47, 0x57, 0x3a, 0x45, 0x11, 0xb1, 0xd7, 0xeb, - 0xa6, 0x59, 0x3e, 0x15, 0xfb, 0xcf, 0xdb, 0x1c, 0xd9, 0xef, 0xd9, 0x77, 0xcf, 0xff, 0xbc, 0x1e, - 0xd8, 0x4f, 0xaf, 0x07, 0xf6, 0x3f, 0xd7, 0x03, 0xfb, 0xd7, 0x9b, 0x81, 0xf5, 0xf4, 0x66, 0x60, - 0xfd, 0x75, 0x33, 0xb0, 0xbe, 0x79, 0xeb, 0x7f, 0xff, 0x82, 0x1f, 0x1e, 0xd1, 0xe7, 0xfd, 0x7f, - 0x03, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x1f, 0x02, 0x55, 0xae, 0x07, 0x00, 0x00, + // 793 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x8e, 0x1b, 0x45, + 0x10, 0x9e, 0xf1, 0x7a, 0xd7, 0x76, 0xed, 0xae, 0x63, 0x1a, 0x12, 0x06, 0x03, 0x8e, 0x99, 0x03, + 0xb2, 0x40, 0x5a, 0x23,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 0xec, 0xba, 0xe7, 0xfc, 0x73, 0xdd, 0x73, + 0xbe, 0x7b, 0xe7, 0xa5, 0xff, 0xc5, 0x8f, 0x8e, 0xe8, 0xf3, 0xe1, 0x7f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0x33, 0xca, 0x5b, 0xe5, 0xb7, 0x07, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -1123,9 +1123,9 @@ func (m *ObjectSyncMessage) MarshalToSizedBuffer(dAtA []byte) (int, error) { i-- dAtA[i] = 0x22 } - if m.TreeHeader != nil { + if m.RootChange != nil { { - size, err := m.TreeHeader.MarshalToSizedBuffer(dAtA[:i]) + size, err := m.RootChange.MarshalToSizedBuffer(dAtA[:i]) if err != nil { return 0, err } @@ -1638,8 +1638,8 @@ func (m *ObjectSyncMessage) Size() (n int) { l = m.Content.Size() n += 1 + l + sovSpacesync(uint64(l)) } - if m.TreeHeader != nil { - l = m.TreeHeader.Size() + if m.RootChange != nil { + l = m.RootChange.Size() n += 1 + l + sovSpacesync(uint64(l)) } l = len(m.TreeId) @@ -2497,7 +2497,7 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeader", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field RootChange", wireType) } var msglen int for shift := uint(0); ; shift += 7 { @@ -2524,10 +2524,10 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - if m.TreeHeader == nil { - m.TreeHeader = &treechangeproto.RootChange{} + if m.RootChange == nil { + m.RootChange = &treechangeproto.RawTreeChangeWithId{} } - if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + if err := m.RootChange.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } iNdEx = postIndex diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index c7039a73..ecf43dfe 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -5,12 +5,16 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "time" ) type SyncService interface { - NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) + NotifyHeadUpdate( + ctx context.Context, + treeId string, + root *treechangeproto.RawTreeChangeWithId, + update *spacesyncproto.ObjectHeadUpdate) (err error) StreamPool() StreamPool Init() @@ -72,7 +76,11 @@ func (s *syncService) Close() (err error) { return s.streamPool.Close() } -func (s *syncService) NotifyHeadUpdate(ctx context.Context, treeId string, header *aclpb.TreeHeader, update *spacesyncproto.ObjectHeadUpdate) (err error) { +func (s *syncService) NotifyHeadUpdate( + ctx context.Context, + treeId string, + header *treechangeproto.RawTreeChangeWithId, + update *spacesyncproto.ObjectHeadUpdate) (err error) { s.headNotifiable.UpdateHeads(treeId, update.Heads) return s.streamPool.BroadcastAsync(spacesyncproto.WrapHeadUpdate(update, header, treeId, "")) } diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 149c7c9b..68ea48f4 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -4,10 +4,10 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) type UpdateListener interface { @@ -91,7 +91,7 @@ func (s *SyncTree) AddContent(ctx context.Context, content tree.SignableChangeCo return } -func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (res tree.AddResult, err error) { +func (s *SyncTree) AddRawChanges(ctx context.Context, changes ...*treechangeproto.RawTreeChangeWithId) (res tree.AddResult, err error) { res, err = s.AddRawChanges(ctx, changes...) if err != nil { return diff --git a/pkg/acl/account/accountdata.go b/pkg/acl/account/accountdata.go index 4368a26c..3d3fdf28 100644 --- a/pkg/acl/account/accountdata.go +++ b/pkg/acl/account/accountdata.go @@ -1,7 +1,6 @@ package account import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) @@ -10,5 +9,4 @@ type AccountData struct { // TODO: create a convenient constructor for this Identity []byte // public key SignKey signingkey.PrivKey EncKey encryptionkey.PrivKey - Decoder keys.Decoder } diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index f940e4b4..46a48681 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -8,7 +8,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "sync" ) @@ -58,7 +57,7 @@ func BuildACLListWithIdentity(acc *account.AccountData, storage storage.ListStor return build(id, builder, newACLRecordBuilder(id, common.NewKeychain()), storage) } -func BuildACLList(decoder keys.Decoder, storage storage.ListStorage) (ACLList, error) { +func BuildACLList(storage storage.ListStorage) (ACLList, error) { id, err := storage.ID() if err != nil { return nil, err diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index 6c3c70d1..13019b21 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -3,7 +3,6 @@ package list import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" @@ -15,7 +14,7 @@ func TestAclList_ACLState_UserInviteAndJoin(t *testing.T) { keychain := st.(*acllistbuilder.ACLListStorageBuilder).GetKeychain() - aclList, err := BuildACLList(signingkey.NewEDPubKeyDecoder(), st) + aclList, err := BuildACLList(st) require.NoError(t, err, "building acl list should be without error") idA := keychain.GetIdentity("A") @@ -54,7 +53,7 @@ func TestAclList_ACLState_UserJoinAndRemove(t *testing.T) { keychain := st.(*acllistbuilder.ACLListStorageBuilder).GetKeychain() - aclList, err := BuildACLList(signingkey.NewEDPubKeyDecoder(), st) + aclList, err := BuildACLList(st) require.NoError(t, err, "building acl list should be without error") idA := keychain.GetIdentity("A") diff --git a/pkg/acl/testutils/acllistbuilder/keychain.go b/pkg/acl/testutils/acllistbuilder/keychain.go index e26f389b..c893a665 100644 --- a/pkg/acl/testutils/acllistbuilder/keychain.go +++ b/pkg/acl/testutils/acllistbuilder/keychain.go @@ -2,6 +2,7 @@ package acllistbuilder import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "hash/fnv" @@ -23,7 +24,6 @@ type YAMLKeychain struct { ReadKeysByHash map[uint64]*SymKey GeneratedIdentities map[string]string DerivedIdentity string - coder signingkey.PubKeyDecoder } func NewKeychain() *YAMLKeychain { @@ -34,7 +34,6 @@ func NewKeychain() *YAMLKeychain { GeneratedIdentities: map[string]string{}, ReadKeysByYAMLIdentity: map[string]*SymKey{}, ReadKeysByHash: map[uint64]*SymKey{}, - coder: signingkey.NewEd25519PubKeyDecoder(), } } @@ -67,12 +66,10 @@ func (k *YAMLKeychain) AddEncryptionKey(key *Key) { panic(err) } } else { - decoder := encryptionkey.NewRSAPrivKeyDecoder() - privKey, err := decoder.DecodeFromString(key.Value) + newPrivKey, err = keys.DecodeKeyFromString(key.Value, encryptionkey.NewEncryptionRsaPrivKeyFromBytes, nil) if err != nil { panic(err) } - newPrivKey = privKey.(encryptionkey.PrivKey) } k.EncryptionKeysByYAMLIdentity[key.Name] = newPrivKey } @@ -92,12 +89,10 @@ func (k *YAMLKeychain) AddSigningKey(key *Key) { panic(err) } } else { - decoder := signingkey.NewEDPrivKeyDecoder() - privKey, err := decoder.DecodeFromString(key.Value) + newPrivKey, err = keys.DecodeKeyFromString(key.Value, signingkey.NewSigningEd25519PrivKeyFromBytes, nil) if err != nil { panic(err) } - newPrivKey = privKey.(signingkey.PrivKey) pubKey = newPrivKey.GetPublic() } diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 115ce87e..bb342070 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -39,7 +39,7 @@ type ObjectTree interface { RWLocker ID() string - Header() *treechangeproto.RootChange + Header() *treechangeproto.RawTreeChangeWithId Heads() []string Root() *Change HasChange(string) bool @@ -68,7 +68,7 @@ type objectTree struct { aclList list.ACLList id string - root *treechangeproto.RootChange + root *treechangeproto.RawTreeChangeWithId tree *Tree keys map[uint64]*symmetric.Key @@ -132,7 +132,7 @@ func (ot *objectTree) ID() string { return ot.id } -func (ot *objectTree) Header() *treechangeproto.RootChange { +func (ot *objectTree) Header() *treechangeproto.RawTreeChangeWithId { return ot.root } diff --git a/pkg/acl/tree/objecttree_test.go b/pkg/acl/tree/objecttree_test.go index 832c15fa..fcfab7e7 100644 --- a/pkg/acl/tree/objecttree_test.go +++ b/pkg/acl/tree/objecttree_test.go @@ -2,13 +2,10 @@ package tree import ( "context" - "crypto/rand" - "encoding/hex" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" "testing" @@ -108,7 +105,7 @@ func prepareACLList(t *testing.T) list.ACLList { st, err := acllistbuilder.NewListStorageWithTestName("userjoinexample.yml") require.NoError(t, err, "building storage should not result in error") - aclList, err := list.BuildACLList(signingkey.NewEDPubKeyDecoder(), st) + aclList, err := list.BuildACLList(st) require.NoError(t, err, "building acl list should be without error") return aclList @@ -151,18 +148,6 @@ func prepareTreeContext(t *testing.T, aclList list.ACLList) testTreeContext { } } -func TestSameSignature(t *testing.T) { - privKey, _, err := signingkey.GenerateEd25519Key(rand.Reader) - require.NoError(t, err) - bytes := []byte("asefhiosahjfoiesjgioesajgihs") - for i := 0; i < 5; i++ { - signed, err := privKey.Sign(bytes) - require.NoError(t, err) - t.Log(hex.EncodeToString(signed)) - } - // kitten step voyage hand cover funny timber auction differ mushroom update pulp -} - func TestObjectTree(t *testing.T) { aclList := prepareACLList(t) diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index f6ab5f77..3a65fde8 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -7,7 +7,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" - "github.com/gogo/protobuf/proto" "go.uber.org/zap" ) @@ -114,19 +113,13 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { return nil, err } - rawRootWithId, err := objTree.treeStorage.Root() + objTree.root, err = objTree.treeStorage.Root() if err != nil { return nil, err } - rawRoot := &treechangeproto.RawTreeChange{} - err = proto.Unmarshal(rawRootWithId.RawChange, rawRoot) - if err != nil { - return nil, err - } - - objTree.root = &treechangeproto.RootChange{} - err = proto.Unmarshal(rawRoot.Payload, objTree.root) + // verifying root + _, err = objTree.changeBuilder.ConvertFromRaw(objTree.root, true) if err != nil { return nil, err } diff --git a/service/node/service.go b/service/node/service.go index 8b86fa9f..fd1fe5b7 100644 --- a/service/node/service.go +++ b/service/node/service.go @@ -5,7 +5,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "go.uber.org/zap" @@ -83,9 +82,7 @@ func (s *service) Nodes() []*Node { func nodeFromConfigNode( n config.Node, - peerId string, - privateSigningDecoder keys.Decoder, - privateEncryptionDecoder keys.Decoder) (*Node, error) { + peerId string) (*Node, error) { decodedSigningKey, err := privateSigningDecoder.DecodeFromString(n.SigningKey) if err != nil { return nil, err diff --git a/util/keys/asymmetric/encryptionkey/rsa.go b/util/keys/asymmetric/encryptionkey/rsa.go index 4e70091a..6c733488 100644 --- a/util/keys/asymmetric/encryptionkey/rsa.go +++ b/util/keys/asymmetric/encryptionkey/rsa.go @@ -107,14 +107,6 @@ func NewEncryptionRsaPubKeyFromBytes(bytes []byte) (PubKey, error) { return &EncryptionRsaPubKey{pubKey: *pk}, nil } -func NewRSAPrivKeyDecoder() keys.Decoder { - return keys.NewKeyDecoder(NewEncryptionRsaPrivKeyFromBytes) -} - -func NewRSAPubKeyDecoder() keys.Decoder { - return keys.NewKeyDecoder(NewEncryptionRsaPubKeyFromBytes) -} - func keyEquals(k1, k2 keys.Key) bool { a, err := k1.Raw() if err != nil { diff --git a/util/keys/asymmetric/signingkey/ed25519.go b/util/keys/asymmetric/signingkey/ed25519.go index 90763e67..beb4b6ed 100644 --- a/util/keys/asymmetric/signingkey/ed25519.go +++ b/util/keys/asymmetric/signingkey/ed25519.go @@ -9,8 +9,6 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "io" - - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/strkey" ) // Ed25519PrivateKey is an ed25519 private key. @@ -147,43 +145,3 @@ func UnmarshalEd25519PrivateKey(data []byte) (PrivKey, error) { k: ed25519.PrivateKey(data), }, nil } - -// TODO: remove this one in favor of new one -type Ed25519SigningPubKeyDecoder struct{} - -func NewEd25519PubKeyDecoder() PubKeyDecoder { - return &Ed25519SigningPubKeyDecoder{} -} - -func (e *Ed25519SigningPubKeyDecoder) DecodeFromBytes(bytes []byte) (PubKey, error) { - return NewSigningEd25519PubKeyFromBytes(bytes) -} - -func (e *Ed25519SigningPubKeyDecoder) DecodeFromString(identity string) (PubKey, error) { - pubKeyRaw, err := strkey.Decode(0x5b, identity) - if err != nil { - return nil, err - } - - return e.DecodeFromBytes(pubKeyRaw) -} - -func (e *Ed25519SigningPubKeyDecoder) DecodeFromStringIntoBytes(identity string) ([]byte, error) { - return strkey.Decode(0x5b, identity) -} - -func (e *Ed25519SigningPubKeyDecoder) EncodeToString(pubkey PubKey) (string, error) { - raw, err := pubkey.Raw() - if err != nil { - return "", err - } - return strkey.Encode(0x5b, raw) -} - -func NewEDPrivKeyDecoder() keys.Decoder { - return keys.NewKeyDecoder(NewSigningEd25519PrivKeyFromBytes) -} - -func NewEDPubKeyDecoder() keys.Decoder { - return keys.NewKeyDecoder(NewSigningEd25519PubKeyFromBytes) -} diff --git a/util/keys/asymmetric/signingkey/signingkey.go b/util/keys/asymmetric/signingkey/signingkey.go index 30299eb4..07576a67 100644 --- a/util/keys/asymmetric/signingkey/signingkey.go +++ b/util/keys/asymmetric/signingkey/signingkey.go @@ -15,10 +15,3 @@ type PubKey interface { Verify(data []byte, sig []byte) (bool, error) } - -type PubKeyDecoder interface { - DecodeFromBytes(bytes []byte) (PubKey, error) - DecodeFromString(identity string) (PubKey, error) - DecodeFromStringIntoBytes(identity string) ([]byte, error) - EncodeToString(pubkey PubKey) (string, error) -} diff --git a/util/keys/decode.go b/util/keys/decode.go new file mode 100644 index 00000000..c08e7c41 --- /dev/null +++ b/util/keys/decode.go @@ -0,0 +1,30 @@ +package keys + +import ( + "encoding/base64" +) + +func EncodeKeyToString[T Key](key T) (str string, err error) { + raw, err := key.Raw() + if err != nil { + return + } + str = EncodeBytesToString(raw) + return +} + +func EncodeBytesToString(bytes []byte) string { + return base64.StdEncoding.EncodeToString(bytes) +} + +func DecodeKeyFromString[T Key](str string, construct func([]byte) (T, error), def T) (T, error) { + dec, err := DecodeBytesFromString(str) + if err != nil { + return def, err + } + return construct(dec) +} + +func DecodeBytesFromString(str string) (bytes []byte, err error) { + return base64.StdEncoding.DecodeString(str) +} diff --git a/util/keys/decoder.go b/util/keys/decoder.go deleted file mode 100644 index 0b194794..00000000 --- a/util/keys/decoder.go +++ /dev/null @@ -1,38 +0,0 @@ -package keys - -import "github.com/anytypeio/go-anytype-infrastructure-experiments/util/strkey" - -type keyDecoder[T Key] struct { - create func([]byte) (T, error) -} - -func NewKeyDecoder[T Key](create func(bytes []byte) (T, error)) Decoder { - return &keyDecoder[T]{ - create: create, - } -} - -func (e *keyDecoder[T]) DecodeFromBytes(bytes []byte) (Key, error) { - return e.create(bytes) -} - -func (e *keyDecoder[T]) DecodeFromString(identity string) (Key, error) { - pubKeyRaw, err := strkey.Decode(0x5b, identity) - if err != nil { - return nil, err - } - - return e.DecodeFromBytes(pubKeyRaw) -} - -func (e *keyDecoder[T]) DecodeFromStringIntoBytes(identity string) ([]byte, error) { - return strkey.Decode(0x5b, identity) -} - -func (e *keyDecoder[T]) EncodeToString(key Key) (string, error) { - raw, err := key.Raw() - if err != nil { - return "", err - } - return strkey.Encode(0x5b, raw) -} diff --git a/util/keys/key.go b/util/keys/key.go index 2170fac8..150d0897 100644 --- a/util/keys/key.go +++ b/util/keys/key.go @@ -8,13 +8,6 @@ type Key interface { Raw() ([]byte, error) } -type Decoder interface { - DecodeFromBytes(bytes []byte) (Key, error) - DecodeFromString(identity string) (Key, error) - DecodeFromStringIntoBytes(identity string) ([]byte, error) - EncodeToString(key Key) (string, error) -} - func KeyEquals(k1, k2 Key) bool { a, err := k1.Raw() if err != nil { From 227e7d47abf3f84d31c9d17cb48c47853dd4d9a0 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 22:15:40 +0200 Subject: [PATCH 35/44] Few more fixes, remove node service --- common/commonspace/space.go | 8 +- .../commonspace/spacesyncproto/spacesync.go | 18 +-- common/commonspace/spacetree/spacetree.go | 38 ++++++ common/commonspace/syncservice/synchandler.go | 8 +- common/nodeconf/service.go | 62 +++++++++- service/node/service.go | 111 ------------------ 6 files changed, 112 insertions(+), 133 deletions(-) delete mode 100644 service/node/service.go diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 5fbc675b..1e319a44 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -99,10 +99,10 @@ func (s *space) BuildTree(ctx context.Context, id string, listener synctree.Upda fullSyncResp := resp.GetContent().GetFullSyncResponse() payload := treestorage.TreeStorageCreatePayload{ - TreeId: resp.TreeId, - Header: resp.TreeHeader, - Changes: fullSyncResp.Changes, - Heads: fullSyncResp.Heads, + TreeId: resp.TreeId, + RootRawChange: resp.RootChange, + Changes: fullSyncResp.Changes, + Heads: fullSyncResp.Heads, } // basically building tree with inmemory storage and validating that it was without errors diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go index 6ac07962..2e22737a 100644 --- a/common/commonspace/spacesyncproto/spacesync.go +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -1,45 +1,45 @@ package spacesyncproto -import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" +import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" type SpaceStream = DRPCSpace_StreamStream -func WrapHeadUpdate(update *ObjectHeadUpdate, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { +func WrapHeadUpdate(update *ObjectHeadUpdate, rootChange *treechangeproto.RawTreeChangeWithId, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_HeadUpdate{HeadUpdate: update}, }, - TreeHeader: header, + RootChange: rootChange, TreeId: treeId, } } -func WrapFullRequest(request *ObjectFullSyncRequest, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { +func WrapFullRequest(request *ObjectFullSyncRequest, rootChange *treechangeproto.RawTreeChangeWithId, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_FullSyncRequest{FullSyncRequest: request}, }, - TreeHeader: header, + RootChange: rootChange, TreeId: treeId, } } -func WrapFullResponse(response *ObjectFullSyncResponse, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { +func WrapFullResponse(response *ObjectFullSyncResponse, rootChange *treechangeproto.RawTreeChangeWithId, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_FullSyncResponse{FullSyncResponse: response}, }, - TreeHeader: header, + RootChange: rootChange, TreeId: treeId, } } -func WrapError(err error, header *aclpb.TreeHeader, treeId, trackingId string) *ObjectSyncMessage { +func WrapError(err error, rootChange *treechangeproto.RawTreeChangeWithId, treeId, trackingId string) *ObjectSyncMessage { return &ObjectSyncMessage{ Content: &ObjectSyncContentValue{ Value: &ObjectSyncContentValue_ErrorResponse{ErrorResponse: &ObjectErrorResponse{Error: err.Error()}}, }, - TreeHeader: header, + RootChange: rootChange, TreeId: treeId, } } diff --git a/common/commonspace/spacetree/spacetree.go b/common/commonspace/spacetree/spacetree.go index 9cb4ff16..a8eab744 100644 --- a/common/commonspace/spacetree/spacetree.go +++ b/common/commonspace/spacetree/spacetree.go @@ -1 +1,39 @@ package spacetree + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" +) + +type SpaceTree interface { + cache.TreeContainer + ID() string + GetObjectIds() []string + Sync() +} + +type spaceTree struct{} + +func (s *spaceTree) Tree() tree.ObjectTree { + //TODO implement me + panic("implement me") +} + +func (s *spaceTree) ID() string { + //TODO implement me + panic("implement me") +} + +func (s *spaceTree) GetObjectIds() []string { + //TODO implement me + panic("implement me") +} + +func (s *spaceTree) Sync() { + //TODO implement me + panic("implement me") +} + +func NewSpaceTree(id string) (SpaceTree, error) { + return &spaceTree{}, nil +} diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 0d3be042..c8470de5 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -4,8 +4,8 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" ) @@ -80,7 +80,7 @@ func (s *syncHandler) HandleHeadUpdate( if fullRequest != nil { return s.syncClient.SendAsync(senderId, - spacesyncproto.WrapFullRequest(fullRequest, msg.TreeHeader, msg.TreeId, msg.TrackingId)) + spacesyncproto.WrapFullRequest(fullRequest, msg.RootChange, msg.TreeId, msg.TrackingId)) } return } @@ -92,7 +92,7 @@ func (s *syncHandler) HandleFullSyncRequest( msg *spacesyncproto.ObjectSyncMessage) (err error) { var ( fullResponse *spacesyncproto.ObjectFullSyncResponse - header = msg.TreeHeader + header = msg.RootChange ) defer func() { if err != nil { @@ -167,7 +167,7 @@ func (s *syncHandler) prepareFullSyncRequest( SnapshotPath: t.SnapshotPath(), } if len(update.Changes) != 0 { - var changesAfterSnapshot []*aclpb.RawTreeChangeWithId + var changesAfterSnapshot []*treechangeproto.RawTreeChangeWithId changesAfterSnapshot, err = t.ChangesAfterCommonSnapshot(update.SnapshotPath, update.Heads) if err != nil { return diff --git a/common/nodeconf/service.go b/common/nodeconf/service.go index 870223cb..a70fe4a1 100644 --- a/common/nodeconf/service.go +++ b/common/nodeconf/service.go @@ -5,7 +5,9 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-chash" ) @@ -31,11 +33,26 @@ type service struct { last Configuration } +type Node struct { + Address string + PeerId string + SigningKey signingkey.PubKey + EncryptionKey encryptionkey.PubKey +} + +func (n *Node) Id() string { + return n.PeerId +} + +func (n *Node) Capacity() float64 { + return 1 +} + func (s *service) Init(a *app.App) (err error) { conf := a.MustComponent(config.CName).(*config.Config) s.accountId = conf.Account.PeerId s.pool = a.MustComponent(pool.CName).(pool.Pool) - configNodes := a.MustComponent(node.CName).(node.Service).Nodes() + config := &configuration{ id: "config", accountId: s.accountId, @@ -47,9 +64,18 @@ func (s *service) Init(a *app.App) (err error) { }); err != nil { return } - members := make([]chash.Member, 0, len(configNodes)) - for _, n := range configNodes { - members = append(members, n) + members := make([]chash.Member, 0, len(conf.Nodes)-1) + for _, n := range conf.Nodes { + if n.PeerId == conf.Account.PeerId { + continue + } + var member *Node + member, err = nodeFromConfigNode(n) + if err != nil { + return + } + + members = append(members, member) } if err = config.chash.AddMembers(members...); err != nil { return @@ -70,3 +96,29 @@ func (s *service) GetById(id string) Configuration { //TODO implement me panic("implement me") } + +func nodeFromConfigNode( + n config.Node) (*Node, error) { + decodedSigningKey, err := keys.DecodeKeyFromString( + n.SigningKey, + signingkey.UnmarshalEd25519PrivateKey, + nil) + if err != nil { + return nil, err + } + + decodedEncryptionKey, err := keys.DecodeKeyFromString( + n.SigningKey, + encryptionkey.NewEncryptionRsaPrivKeyFromBytes, + nil) + if err != nil { + return nil, err + } + + return &Node{ + Address: n.Address, + PeerId: n.PeerId, + SigningKey: decodedSigningKey.GetPublic(), + EncryptionKey: decodedEncryptionKey.GetPublic(), + }, nil +} diff --git a/service/node/service.go b/service/node/service.go deleted file mode 100644 index fd1fe5b7..00000000 --- a/service/node/service.go +++ /dev/null @@ -1,111 +0,0 @@ -package node - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" - "go.uber.org/zap" -) - -const CName = "NodesService" - -var log = logger.NewNamed("nodesservice") - -type Node struct { - Address string - PeerId string - SigningKey signingkey.PubKey - EncryptionKey encryptionkey.PubKey - SigningKeyString string - EncryptionKeyString string -} - -func (n *Node) Id() string { - return n.PeerId -} - -func (n *Node) Capacity() float64 { - return 1 -} - -func New() app.Component { - return &service{} -} - -type Service interface { - Nodes() []*Node -} - -type service struct { - nodes []*Node -} - -func (s *service) Init(a *app.App) (err error) { - cfg := a.MustComponent(config.CName).(*config.Config) - signDecoder := signingkey.NewEDPrivKeyDecoder() - rsaDecoder := encryptionkey.NewRSAPrivKeyDecoder() - - var filteredNodes []*Node - for _, n := range cfg.Nodes { - if n.PeerId == cfg.Account.PeerId { - continue - } - node, err := nodeFromConfigNode(n, n.PeerId, signDecoder, rsaDecoder) - if err != nil { - return err - } - log.With(zap.String("node", node.PeerId)).Debug("adding peer to known nodes") - filteredNodes = append(filteredNodes, node) - } - s.nodes = filteredNodes - return nil -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) Run(ctx context.Context) (err error) { - return nil -} - -func (s *service) Close(ctx context.Context) (err error) { - return nil -} - -func (s *service) Nodes() []*Node { - return s.nodes -} - -func nodeFromConfigNode( - n config.Node, - peerId string) (*Node, error) { - decodedSigningKey, err := privateSigningDecoder.DecodeFromString(n.SigningKey) - if err != nil { - return nil, err - } - - decodedEncryptionKey, err := privateEncryptionDecoder.DecodeFromString(n.EncryptionKey) - if err != nil { - return nil, err - } - - encKeyString, err := privateEncryptionDecoder.EncodeToString(decodedEncryptionKey.(encryptionkey.PrivKey).GetPublic()) - if err != nil { - return nil, err - } - - signKeyString, err := privateSigningDecoder.EncodeToString(decodedSigningKey.(signingkey.PrivKey).GetPublic()) - - return &Node{ - Address: n.Address, - PeerId: peerId, - SigningKey: decodedSigningKey.(signingkey.PrivKey).GetPublic(), - EncryptionKey: decodedEncryptionKey.(encryptionkey.PrivKey).GetPublic(), - SigningKeyString: signKeyString, - EncryptionKeyString: encKeyString, - }, nil -} From 0b97aaa302ad51cc5cd93d5b0f18e1f0d9a0849f Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 22:20:08 +0200 Subject: [PATCH 36/44] Remove unneeded files --- service/api/service.go | 137 --- service/document/service.go | 219 ----- service/storage/service.go | 71 -- service/treecache/service.go | 127 --- syncproto/helpers.go | 45 - syncproto/proto/sync.proto | 49 - syncproto/sync.pb.go | 1791 ---------------------------------- util/crc16/crc16.go | 122 --- util/strkey/strkey.go | 118 --- 9 files changed, 2679 deletions(-) delete mode 100644 service/api/service.go delete mode 100644 service/document/service.go delete mode 100644 service/storage/service.go delete mode 100644 service/treecache/service.go delete mode 100644 syncproto/helpers.go delete mode 100644 syncproto/proto/sync.proto delete mode 100644 syncproto/sync.pb.go delete mode 100644 util/crc16/crc16.go delete mode 100644 util/strkey/strkey.go diff --git a/service/api/service.go b/service/api/service.go deleted file mode 100644 index 1b9f9c17..00000000 --- a/service/api/service.go +++ /dev/null @@ -1,137 +0,0 @@ -package api - -import ( - "context" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/document" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" - "go.uber.org/zap" - "io" - "net/http" - "time" -) - -const CName = "APIService" - -var log = logger.NewNamed("api") - -func New() app.Component { - return &service{} -} - -type service struct { - treeCache treecache.Service - documentService document.Service - srv *http.Server - cfg *config.Config -} - -func (s *service) Init(a *app.App) (err error) { - s.treeCache = a.MustComponent(treecache.CName).(treecache.Service) - s.documentService = a.MustComponent(document.CName).(document.Service) - s.cfg = a.MustComponent(config.CName).(*config.Config) - return nil -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) Run(ctx context.Context) (err error) { - defer func() { - if err == nil { - log.With(zap.String("port", s.cfg.APIServer.Port)).Info("api server started running") - } - }() - - s.srv = &http.Server{ - Addr: fmt.Sprintf(":%s", s.cfg.APIServer.Port), - } - mux := http.NewServeMux() - mux.HandleFunc("/treeDump", s.treeDump) - mux.HandleFunc("/createDocumentTree", s.createDocumentTree) - mux.HandleFunc("/appendDocument", s.appendDocument) - s.srv.Handler = mux - - go s.runServer() - return nil -} - -func (s *service) runServer() { - err := s.srv.ListenAndServe() - if err != nil { - log.With(zap.Error(err)).Error("could not run api server") - } -} - -func (s *service) Close(ctx context.Context) (err error) { - return s.srv.Shutdown(ctx) -} - -func (s *service) treeDump(w http.ResponseWriter, req *http.Request) { - var ( - query = req.URL.Query() - treeId = query.Get("treeId") - dump string - err error - ) - err = s.treeCache.Do(context.Background(), treeId, func(obj interface{}) error { - t := obj.(tree.ObjectTree) - dump, err = t.DebugDump() - if err != nil { - return err - } - return nil - }) - if err != nil { - sendText(w, http.StatusInternalServerError, err.Error()) - return - } - sendText(w, http.StatusOK, dump) -} - -func (s *service) createDocumentTree(w http.ResponseWriter, req *http.Request) { - var ( - query = req.URL.Query() - text = query.Get("text") - aclListId = query.Get("aclListId") - ) - timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second*30) - treeId, err := s.documentService.CreateDocumentTree(timeoutCtx, aclListId, text) - cancel() - if err != nil { - sendText(w, http.StatusInternalServerError, err.Error()) - return - } - sendText(w, http.StatusOK, treeId) -} - -func (s *service) appendDocument(w http.ResponseWriter, req *http.Request) { - var ( - query = req.URL.Query() - text = query.Get("text") - treeId = query.Get("treeId") - ) - timeoutCtx, cancel := context.WithTimeout(context.Background(), time.Second*30) - err := s.documentService.UpdateDocumentTree(timeoutCtx, treeId, text) - cancel() - if err != nil { - sendText(w, http.StatusInternalServerError, err.Error()) - return - } - sendText(w, http.StatusOK, fmt.Sprintf("updated document with id: %s with text: %s", treeId, text)) -} - -func sendText(r http.ResponseWriter, code int, body string) { - r.Header().Set("Content-Type", "text/plain") - r.WriteHeader(code) - - _, err := io.WriteString(r, fmt.Sprintf("%s\n", body)) - if err != nil { - log.Error("writing response failed", zap.Error(err)) - } -} diff --git a/service/document/service.go b/service/document/service.go deleted file mode 100644 index 6d1192c2..00000000 --- a/service/document/service.go +++ /dev/null @@ -1,219 +0,0 @@ -package document - -import ( - "context" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" - testchanges "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/proto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/message" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/syncproto" - "github.com/gogo/protobuf/proto" - "go.uber.org/zap" -) - -var CName = "DocumentService" - -var log = logger.NewNamed("documentservice") - -type service struct { - messageService message.Service - treeCache treecache.Service - account account.Service - storage storage.Service - // to create new documents we need to know all nodes - nodes []*node.Node -} - -type Service interface { - UpdateDocumentTree(ctx context.Context, id, text string) error - CreateDocumentTree(ctx context.Context, aclTreeId string, text string) (id string, err error) -} - -func New() app.Component { - return &service{} -} - -func (s *service) Init(a *app.App) (err error) { - s.account = a.MustComponent(account.CName).(account.Service) - s.messageService = a.MustComponent(message.CName).(message.Service) - s.treeCache = a.MustComponent(treecache.CName).(treecache.Service) - s.storage = a.MustComponent(storage.CName).(storage.Service) - - nodesService := a.MustComponent(node.CName).(node.Service) - s.nodes = nodesService.Nodes() - - return nil -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) Run(ctx context.Context) (err error) { - syncData := s.storage.ImportedACLSyncData() - - // we could have added a timeout or some additional logic, - // but let's just use the ACL id of the latest started node :-) - return s.messageService.SendToSpaceAsync("", syncproto.WrapACLList( - &syncproto.SyncACLList{Records: syncData.Records}, - syncData.Header, - syncData.Id, - )) -} - -func (s *service) Close(ctx context.Context) (err error) { - return nil -} - -func (s *service) UpdateDocumentTree(ctx context.Context, id, text string) (err error) { - var ( - ch *aclpb.RawChange - header *aclpb.Header - snapshotPath []string - heads []string - ) - log.With(zap.String("id", id), zap.String("text", text)). - Debug("updating document") - - err = s.treeCache.Do(ctx, id, func(obj interface{}) error { - docTree, ok := obj.(tree.ObjectTree) - if !ok { - return fmt.Errorf("can't update acl trees with text") - } - - docTree.Lock() - defer docTree.Unlock() - err = s.treeCache.Do(ctx, docTree.Header().AclListId, func(obj interface{}) error { - aclTree := obj.(list.ACLList) - aclTree.RLock() - defer aclTree.RUnlock() - - content := createAppendTextChange(text) - signable := tree.SignableChangeContent{ - Proto: content, - Key: s.account.Account().SignKey, - Identity: s.account.Account().Identity, - IsSnapshot: false, - } - ch, err = docTree.AddContent(ctx, signable) - if err != nil { - return err - } - return nil - }) - if err != nil { - return err - } - - id = docTree.ID() - heads = docTree.Heads() - header = docTree.Header() - snapshotPath = docTree.SnapshotPath() - return nil - }) - if err != nil { - return err - } - log.With( - zap.String("id", id), - zap.Strings("heads", heads), - zap.String("header", header.String())). - Debug("document updated in the database") - - return s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{ - Heads: heads, - Changes: []*aclpb.RawChange{ch}, - SnapshotPath: snapshotPath, - }, header, id)) -} - -func (s *service) CreateDocumentTree(ctx context.Context, aclListId string, text string) (id string, err error) { - acc := s.account.Account() - var ( - ch *aclpb.RawChange - header *aclpb.Header - snapshotPath []string - heads []string - ) - err = s.treeCache.Do(ctx, aclListId, func(obj interface{}) error { - t := obj.(list.ACLList) - t.RLock() - defer t.RUnlock() - - content := createInitialTextChange(text) - doc, err := tree.CreateNewTreeStorage(acc, t, content, s.storage.CreateTreeStorage) - if err != nil { - return err - } - - id, err = doc.ID() - if err != nil { - return err - } - - header, err = doc.Header() - if err != nil { - return err - } - - heads = []string{header.FirstId} - snapshotPath = []string{header.FirstId} - ch, err = doc.GetRawChange(ctx, header.FirstId) - if err != nil { - return err - } - - return nil - }) - if err != nil { - return "", err - } - - log.With(zap.String("id", id), zap.String("text", text)). - Debug("creating document") - - err = s.messageService.SendToSpaceAsync("", syncproto.WrapHeadUpdate(&syncproto.SyncHeadUpdate{ - Heads: heads, - Changes: []*aclpb.RawChange{ch}, - SnapshotPath: snapshotPath, - }, header, id)) - if err != nil { - return "", err - } - return id, err -} - -func createInitialTextChange(text string) proto.Marshaler { - return &testchanges.PlainTextChangeData{ - Content: []*testchanges.PlainTextChangeContent{ - createAppendTextChangeContent(text), - }, - Snapshot: &testchanges.PlainTextChangeSnapshot{Text: text}, - } -} - -func createAppendTextChange(text string) proto.Marshaler { - return &testchanges.PlainTextChangeData{ - Content: []*testchanges.PlainTextChangeContent{ - createAppendTextChangeContent(text), - }, - } -} - -func createAppendTextChangeContent(text string) *testchanges.PlainTextChangeContent { - return &testchanges.PlainTextChangeContent{ - Value: &testchanges.PlainTextChangeContentValueOfTextAppend{ - TextAppend: &testchanges.PlainTextChangeTextAppend{ - Text: text, - }, - }, - } -} diff --git a/service/storage/service.go b/service/storage/service.go deleted file mode 100644 index 627627c0..00000000 --- a/service/storage/service.go +++ /dev/null @@ -1,71 +0,0 @@ -package storage - -import ( - "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" -) - -var CName = "storage" - -var log = logger.NewNamed("storage").Sugar() - -type ImportedACLSyncData struct { - Id string - Header *aclpb.Header - Records []*aclpb.RawACLRecord -} - -type Service interface { - storage.Provider - ImportedACLSyncData() ImportedACLSyncData -} - -func New() app.Component { - return &service{} -} - -type service struct { - storageProvider storage.Provider - importedACLSyncData ImportedACLSyncData -} - -func (s *service) Init(a *app.App) (err error) { - s.storageProvider = storage.NewInMemoryTreeStorageProvider() - // importing hardcoded acl list, check that the keys there are correct - return nil -} - -func (s *service) Storage(treeId string) (storage.Storage, error) { - return s.storageProvider.Storage(treeId) -} - -func (s *service) AddStorage(id string, st storage.Storage) error { - return s.storageProvider.AddStorage(id, st) -} - -func (s *service) CreateTreeStorage(payload storage.TreeStorageCreatePayload) (storage.TreeStorage, error) { - return s.storageProvider.CreateTreeStorage(payload) -} - -func (s *service) CreateACLListStorage(payload storage.ACLListStorageCreatePayload) (storage.ListStorage, error) { - return s.storageProvider.CreateACLListStorage(payload) -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) ImportedACLSyncData() ImportedACLSyncData { - return s.importedACLSyncData -} - -func (s *service) Run(ctx context.Context) (err error) { - return nil -} - -func (s service) Close(ctx context.Context) (err error) { - return nil -} diff --git a/service/treecache/service.go b/service/treecache/service.go deleted file mode 100644 index 90e91b98..00000000 --- a/service/treecache/service.go +++ /dev/null @@ -1,127 +0,0 @@ -package treecache - -import ( - "context" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" - aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/storage" - "go.uber.org/zap" -) - -const CName = "treecache" - -type ObjFunc = func(obj interface{}) error - -var log = logger.NewNamed("treecache") - -type Service interface { - Do(ctx context.Context, id string, f ObjFunc) error - Add(ctx context.Context, id string, payload any) error -} - -type service struct { - storage storage.Service - account account.Service - cache ocache.OCache -} - -func New() app.ComponentRunnable { - return &service{} -} - -func (s *service) Do(ctx context.Context, treeId string, f ObjFunc) error { - log. - With(zap.String("treeId", treeId)). - Debug("requesting tree from cache to perform operation") - - t, err := s.cache.Get(ctx, treeId) - defer s.cache.Release(treeId) - if err != nil { - return err - } - return f(t) -} - -func (s *service) Add(ctx context.Context, treeId string, payload any) error { - switch pl := payload.(type) { - case aclstorage.TreeStorageCreatePayload: - log. - With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Changes))). - Debug("adding Tree with changes") - - _, err := s.storage.CreateTreeStorage(payload.(aclstorage.TreeStorageCreatePayload)) - if err != nil { - return err - } - case aclstorage.ACLListStorageCreatePayload: - log. - With(zap.String("treeId", treeId), zap.Int("len(changes)", len(pl.Records))). - Debug("adding ACLList with records") - - _, err := s.storage.CreateACLListStorage(payload.(aclstorage.ACLListStorageCreatePayload)) - if err != nil { - return err - } - - } - return nil -} - -func (s *service) Init(a *app.App) (err error) { - s.cache = ocache.New(s.loadTree) - s.account = a.MustComponent(account.CName).(account.Service) - s.storage = a.MustComponent(storage.CName).(storage.Service) - // TODO: for test we should load some predefined keys - return nil -} - -func (s *service) Name() (name string) { - return CName -} - -func (s *service) Run(ctx context.Context) (err error) { - return nil -} - -func (s *service) Close(ctx context.Context) (err error) { - return s.cache.Close() -} - -func (s *service) loadTree(ctx context.Context, id string) (ocache.Object, error) { - t, err := s.storage.Storage(id) - if err != nil { - return nil, err - } - header, err := t.Header() - if err != nil { - return nil, err - } - - switch header.DocType { // handler - case aclpb.Header_ACL: - return list.BuildACLListWithIdentity(s.account.Account(), t.(aclstorage.ListStorage)) - case aclpb.Header_DocTree: - break - default: - return nil, fmt.Errorf("incorrect type") - } - log.Info("got header", zap.String("header", header.String())) - var objTree tree.ObjectTree - err = s.Do(ctx, header.AclListId, func(obj interface{}) error { - aclList := obj.(list.ACLList) - objTree, err = tree.BuildObjectTree(t.(aclstorage.TreeStorage), nil, aclList) - if err != nil { - return err - } - return nil - }) - - return objTree, err -} diff --git a/syncproto/helpers.go b/syncproto/helpers.go deleted file mode 100644 index fbbf11dc..00000000 --- a/syncproto/helpers.go +++ /dev/null @@ -1,45 +0,0 @@ -package syncproto - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" -) - -func WrapHeadUpdate(update *SyncHeadUpdate, header *aclpb.Header, treeId string) *Sync { - return &Sync{ - Message: &SyncContentValue{ - Value: &SyncContentValueValueOfHeadUpdate{HeadUpdate: update}, - }, - TreeHeader: header, - TreeId: treeId, - } -} - -func WrapFullRequest(request *SyncFullRequest, header *aclpb.Header, treeId string) *Sync { - return &Sync{ - Message: &SyncContentValue{ - Value: &SyncContentValueValueOfFullSyncRequest{FullSyncRequest: request}, - }, - TreeHeader: header, - TreeId: treeId, - } -} - -func WrapFullResponse(response *SyncFullResponse, header *aclpb.Header, treeId string) *Sync { - return &Sync{ - Message: &SyncContentValue{ - Value: &SyncContentValueValueOfFullSyncResponse{FullSyncResponse: response}, - }, - TreeHeader: header, - TreeId: treeId, - } -} - -func WrapACLList(aclList *SyncACLList, header *aclpb.Header, id string) *Sync { - return &Sync{ - Message: &SyncContentValue{ - Value: &SyncContentValueValueOfAclList{AclList: aclList}, - }, - TreeHeader: header, - TreeId: id, - } -} diff --git a/syncproto/proto/sync.proto b/syncproto/proto/sync.proto deleted file mode 100644 index d1c60d7d..00000000 --- a/syncproto/proto/sync.proto +++ /dev/null @@ -1,49 +0,0 @@ -syntax = "proto3"; -package anytype; -option go_package = "/syncproto"; - -import "pkg/acl/aclrecordproto/aclpb/protos/aclrecordproto.proto"; - -message Message { - Header header = 1; - bytes data = 2; -} - -message Header { - bytes traceId = 1; - uint64 requestId = 2; - uint64 replyId = 3; - MessageType type = 4; - string debugInfo = 5; -} - -enum MessageType { - MessageTypeSystem = 0; - MessageTypeSpace = 1; - MessageTypeSync = 2; -} - -message System { - Handshake handshake = 1; - Ping ping = 2; - Ack ack = 3; - - message Handshake { - string protocolVersion = 1; - } - message Ping { - uint64 unixTime = 1; - } - message Ack { - Error error = 2; - } - message Error { - Code code = 1; - string description = 2; - - enum Code { - UNKNOWN = 0; - UNSUPPORTED_PROTOCOL_VERSION = 10; - } - } -} diff --git a/syncproto/sync.pb.go b/syncproto/sync.pb.go deleted file mode 100644 index 20a189a1..00000000 --- a/syncproto/sync.pb.go +++ /dev/null @@ -1,1791 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: syncproto/proto/sync.proto - -package syncproto - -import ( - fmt "fmt" - _ "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - proto "github.com/gogo/protobuf/proto" - io "io" - math "math" - math_bits "math/bits" -) - -// Reference imports to suppress errors if they are not otherwise used. -var _ = proto.Marshal -var _ = fmt.Errorf -var _ = math.Inf - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the proto package it is being compiled against. -// A compilation error at this line likely means your copy of the -// proto package needs to be updated. -const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package - -type MessageType int32 - -const ( - MessageType_MessageTypeSystem MessageType = 0 - MessageType_MessageTypeSpace MessageType = 1 - MessageType_MessageTypeSync MessageType = 2 -) - -var MessageType_name = map[int32]string{ - 0: "MessageTypeSystem", - 1: "MessageTypeSpace", - 2: "MessageTypeSync", -} - -var MessageType_value = map[string]int32{ - "MessageTypeSystem": 0, - "MessageTypeSpace": 1, - "MessageTypeSync": 2, -} - -func (x MessageType) String() string { - return proto.EnumName(MessageType_name, int32(x)) -} - -func (MessageType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{0} -} - -type System_Error_Code int32 - -const ( - System_Error_UNKNOWN System_Error_Code = 0 - System_Error_UNSUPPORTED_PROTOCOL_VERSION System_Error_Code = 10 -) - -var System_Error_Code_name = map[int32]string{ - 0: "UNKNOWN", - 10: "UNSUPPORTED_PROTOCOL_VERSION", -} - -var System_Error_Code_value = map[string]int32{ - "UNKNOWN": 0, - "UNSUPPORTED_PROTOCOL_VERSION": 10, -} - -func (x System_Error_Code) String() string { - return proto.EnumName(System_Error_Code_name, int32(x)) -} - -func (System_Error_Code) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2, 3, 0} -} - -type Message struct { - Header *Header `protobuf:"bytes,1,opt,name=header,proto3" json:"header,omitempty"` - Data []byte `protobuf:"bytes,2,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *Message) Reset() { *m = Message{} } -func (m *Message) String() string { return proto.CompactTextString(m) } -func (*Message) ProtoMessage() {} -func (*Message) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{0} -} -func (m *Message) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Message) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Message.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 *Message) XXX_Merge(src proto.Message) { - xxx_messageInfo_Message.Merge(m, src) -} -func (m *Message) XXX_Size() int { - return m.Size() -} -func (m *Message) XXX_DiscardUnknown() { - xxx_messageInfo_Message.DiscardUnknown(m) -} - -var xxx_messageInfo_Message proto.InternalMessageInfo - -func (m *Message) GetHeader() *Header { - if m != nil { - return m.Header - } - return nil -} - -func (m *Message) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -type Header struct { - TraceId []byte `protobuf:"bytes,1,opt,name=traceId,proto3" json:"traceId,omitempty"` - RequestId uint64 `protobuf:"varint,2,opt,name=requestId,proto3" json:"requestId,omitempty"` - ReplyId uint64 `protobuf:"varint,3,opt,name=replyId,proto3" json:"replyId,omitempty"` - Type MessageType `protobuf:"varint,4,opt,name=type,proto3,enum=anytype.MessageType" json:"type,omitempty"` - DebugInfo string `protobuf:"bytes,5,opt,name=debugInfo,proto3" json:"debugInfo,omitempty"` -} - -func (m *Header) Reset() { *m = Header{} } -func (m *Header) String() string { return proto.CompactTextString(m) } -func (*Header) ProtoMessage() {} -func (*Header) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{1} -} -func (m *Header) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *Header) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_Header.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 *Header) XXX_Merge(src proto.Message) { - xxx_messageInfo_Header.Merge(m, src) -} -func (m *Header) XXX_Size() int { - return m.Size() -} -func (m *Header) XXX_DiscardUnknown() { - xxx_messageInfo_Header.DiscardUnknown(m) -} - -var xxx_messageInfo_Header proto.InternalMessageInfo - -func (m *Header) GetTraceId() []byte { - if m != nil { - return m.TraceId - } - return nil -} - -func (m *Header) GetRequestId() uint64 { - if m != nil { - return m.RequestId - } - return 0 -} - -func (m *Header) GetReplyId() uint64 { - if m != nil { - return m.ReplyId - } - return 0 -} - -func (m *Header) GetType() MessageType { - if m != nil { - return m.Type - } - return MessageType_MessageTypeSystem -} - -func (m *Header) GetDebugInfo() string { - if m != nil { - return m.DebugInfo - } - return "" -} - -type System struct { - Handshake *System_Handshake `protobuf:"bytes,1,opt,name=handshake,proto3" json:"handshake,omitempty"` - Ping *System_Ping `protobuf:"bytes,2,opt,name=ping,proto3" json:"ping,omitempty"` - Ack *System_Ack `protobuf:"bytes,3,opt,name=ack,proto3" json:"ack,omitempty"` -} - -func (m *System) Reset() { *m = System{} } -func (m *System) String() string { return proto.CompactTextString(m) } -func (*System) ProtoMessage() {} -func (*System) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2} -} -func (m *System) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *System) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_System.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 *System) XXX_Merge(src proto.Message) { - xxx_messageInfo_System.Merge(m, src) -} -func (m *System) XXX_Size() int { - return m.Size() -} -func (m *System) XXX_DiscardUnknown() { - xxx_messageInfo_System.DiscardUnknown(m) -} - -var xxx_messageInfo_System proto.InternalMessageInfo - -func (m *System) GetHandshake() *System_Handshake { - if m != nil { - return m.Handshake - } - return nil -} - -func (m *System) GetPing() *System_Ping { - if m != nil { - return m.Ping - } - return nil -} - -func (m *System) GetAck() *System_Ack { - if m != nil { - return m.Ack - } - return nil -} - -type System_Handshake struct { - ProtocolVersion string `protobuf:"bytes,1,opt,name=protocolVersion,proto3" json:"protocolVersion,omitempty"` -} - -func (m *System_Handshake) Reset() { *m = System_Handshake{} } -func (m *System_Handshake) String() string { return proto.CompactTextString(m) } -func (*System_Handshake) ProtoMessage() {} -func (*System_Handshake) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2, 0} -} -func (m *System_Handshake) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *System_Handshake) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_System_Handshake.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 *System_Handshake) XXX_Merge(src proto.Message) { - xxx_messageInfo_System_Handshake.Merge(m, src) -} -func (m *System_Handshake) XXX_Size() int { - return m.Size() -} -func (m *System_Handshake) XXX_DiscardUnknown() { - xxx_messageInfo_System_Handshake.DiscardUnknown(m) -} - -var xxx_messageInfo_System_Handshake proto.InternalMessageInfo - -func (m *System_Handshake) GetProtocolVersion() string { - if m != nil { - return m.ProtocolVersion - } - return "" -} - -type System_Ping struct { - UnixTime uint64 `protobuf:"varint,1,opt,name=unixTime,proto3" json:"unixTime,omitempty"` -} - -func (m *System_Ping) Reset() { *m = System_Ping{} } -func (m *System_Ping) String() string { return proto.CompactTextString(m) } -func (*System_Ping) ProtoMessage() {} -func (*System_Ping) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2, 1} -} -func (m *System_Ping) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *System_Ping) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_System_Ping.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 *System_Ping) XXX_Merge(src proto.Message) { - xxx_messageInfo_System_Ping.Merge(m, src) -} -func (m *System_Ping) XXX_Size() int { - return m.Size() -} -func (m *System_Ping) XXX_DiscardUnknown() { - xxx_messageInfo_System_Ping.DiscardUnknown(m) -} - -var xxx_messageInfo_System_Ping proto.InternalMessageInfo - -func (m *System_Ping) GetUnixTime() uint64 { - if m != nil { - return m.UnixTime - } - return 0 -} - -type System_Ack struct { - Error *System_Error `protobuf:"bytes,2,opt,name=error,proto3" json:"error,omitempty"` -} - -func (m *System_Ack) Reset() { *m = System_Ack{} } -func (m *System_Ack) String() string { return proto.CompactTextString(m) } -func (*System_Ack) ProtoMessage() {} -func (*System_Ack) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2, 2} -} -func (m *System_Ack) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *System_Ack) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_System_Ack.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 *System_Ack) XXX_Merge(src proto.Message) { - xxx_messageInfo_System_Ack.Merge(m, src) -} -func (m *System_Ack) XXX_Size() int { - return m.Size() -} -func (m *System_Ack) XXX_DiscardUnknown() { - xxx_messageInfo_System_Ack.DiscardUnknown(m) -} - -var xxx_messageInfo_System_Ack proto.InternalMessageInfo - -func (m *System_Ack) GetError() *System_Error { - if m != nil { - return m.Error - } - return nil -} - -type System_Error struct { - Code System_Error_Code `protobuf:"varint,1,opt,name=code,proto3,enum=anytype.System_Error_Code" json:"code,omitempty"` - Description string `protobuf:"bytes,2,opt,name=description,proto3" json:"description,omitempty"` -} - -func (m *System_Error) Reset() { *m = System_Error{} } -func (m *System_Error) String() string { return proto.CompactTextString(m) } -func (*System_Error) ProtoMessage() {} -func (*System_Error) Descriptor() ([]byte, []int) { - return fileDescriptor_4b28dfdd48a89166, []int{2, 3} -} -func (m *System_Error) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *System_Error) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_System_Error.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 *System_Error) XXX_Merge(src proto.Message) { - xxx_messageInfo_System_Error.Merge(m, src) -} -func (m *System_Error) XXX_Size() int { - return m.Size() -} -func (m *System_Error) XXX_DiscardUnknown() { - xxx_messageInfo_System_Error.DiscardUnknown(m) -} - -var xxx_messageInfo_System_Error proto.InternalMessageInfo - -func (m *System_Error) GetCode() System_Error_Code { - if m != nil { - return m.Code - } - return System_Error_UNKNOWN -} - -func (m *System_Error) GetDescription() string { - if m != nil { - return m.Description - } - return "" -} - -func init() { - proto.RegisterEnum("anytype.MessageType", MessageType_name, MessageType_value) - proto.RegisterEnum("anytype.System_Error_Code", System_Error_Code_name, System_Error_Code_value) - proto.RegisterType((*Message)(nil), "anytype.Message") - proto.RegisterType((*Header)(nil), "anytype.Header") - proto.RegisterType((*System)(nil), "anytype.System") - proto.RegisterType((*System_Handshake)(nil), "anytype.System.Handshake") - proto.RegisterType((*System_Ping)(nil), "anytype.System.Ping") - proto.RegisterType((*System_Ack)(nil), "anytype.System.Ack") - proto.RegisterType((*System_Error)(nil), "anytype.System.Error") -} - -func init() { proto.RegisterFile("syncproto/proto/sync.proto", fileDescriptor_4b28dfdd48a89166) } - -var fileDescriptor_4b28dfdd48a89166 = []byte{ - // 536 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x6c, 0x93, 0xd1, 0x8a, 0xd3, 0x40, - 0x14, 0x86, 0x3b, 0xdb, 0x6c, 0x6b, 0x4f, 0x96, 0xdd, 0x38, 0xbb, 0x0b, 0x31, 0x2c, 0x21, 0x14, - 0xc5, 0xa2, 0x90, 0x4a, 0x65, 0xf1, 0x7a, 0x5d, 0x2b, 0x2d, 0x6a, 0x53, 0xa6, 0xed, 0x0a, 0xde, - 0x2c, 0xd3, 0xc9, 0x98, 0x86, 0x76, 0x93, 0x98, 0xa4, 0x60, 0xde, 0x62, 0x9f, 0xc1, 0x67, 0xf0, - 0x21, 0xbc, 0xdc, 0x4b, 0x2f, 0xa5, 0x7d, 0x11, 0x99, 0x49, 0xda, 0xc6, 0xe2, 0x45, 0x92, 0x39, - 0xff, 0xf9, 0xff, 0x33, 0xdf, 0x30, 0x04, 0x8c, 0x24, 0x0b, 0x58, 0x14, 0x87, 0x69, 0xd8, 0xce, - 0xdf, 0xa2, 0xb6, 0xe5, 0x12, 0xd7, 0x69, 0x90, 0xa5, 0x59, 0xc4, 0x8d, 0x57, 0xd1, 0xdc, 0x6b, - 0x53, 0xb6, 0x10, 0x0f, 0x9b, 0xd1, 0xc0, 0xe3, 0x89, 0x58, 0x46, 0xd3, 0x3c, 0x93, 0x94, 0xf4, - 0x3c, 0xda, 0x7c, 0x0f, 0xf5, 0x4f, 0x3c, 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0x44, 0x7f, 0x56, 0x26, 0xba, 0x5f, 0x9b, 0x95, 0x87, 0xb5, 0x59, 0xf9, 0xbd, 0x36, - 0x2b, 0x5f, 0xa0, 0xbd, 0xfd, 0xcd, 0xa6, 0x35, 0xf9, 0x79, 0xfd, 0x37, 0x00, 0x00, 0xff, 0xff, - 0x5f, 0xee, 0x92, 0xca, 0x7a, 0x03, 0x00, 0x00, -} - -func (m *Message) 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 *Message) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Message) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintSync(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x12 - } - if m.Header != nil { - { - size, err := m.Header.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *Header) 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 *Header) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *Header) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.DebugInfo) > 0 { - i -= len(m.DebugInfo) - copy(dAtA[i:], m.DebugInfo) - i = encodeVarintSync(dAtA, i, uint64(len(m.DebugInfo))) - i-- - dAtA[i] = 0x2a - } - if m.Type != 0 { - i = encodeVarintSync(dAtA, i, uint64(m.Type)) - i-- - dAtA[i] = 0x20 - } - if m.ReplyId != 0 { - i = encodeVarintSync(dAtA, i, uint64(m.ReplyId)) - i-- - dAtA[i] = 0x18 - } - if m.RequestId != 0 { - i = encodeVarintSync(dAtA, i, uint64(m.RequestId)) - i-- - dAtA[i] = 0x10 - } - if len(m.TraceId) > 0 { - i -= len(m.TraceId) - copy(dAtA[i:], m.TraceId) - i = encodeVarintSync(dAtA, i, uint64(len(m.TraceId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *System) 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 *System) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *System) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Ack != nil { - { - size, err := m.Ack.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - if m.Ping != nil { - { - size, err := m.Ping.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - if m.Handshake != nil { - { - size, err := m.Handshake.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *System_Handshake) 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 *System_Handshake) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *System_Handshake) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.ProtocolVersion) > 0 { - i -= len(m.ProtocolVersion) - copy(dAtA[i:], m.ProtocolVersion) - i = encodeVarintSync(dAtA, i, uint64(len(m.ProtocolVersion))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *System_Ping) 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 *System_Ping) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *System_Ping) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.UnixTime != 0 { - i = encodeVarintSync(dAtA, i, uint64(m.UnixTime)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func (m *System_Ack) 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 *System_Ack) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *System_Ack) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Error != nil { - { - size, err := m.Error.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSync(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} - -func (m *System_Error) 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 *System_Error) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *System_Error) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Description) > 0 { - i -= len(m.Description) - copy(dAtA[i:], m.Description) - i = encodeVarintSync(dAtA, i, uint64(len(m.Description))) - i-- - dAtA[i] = 0x12 - } - if m.Code != 0 { - i = encodeVarintSync(dAtA, i, uint64(m.Code)) - i-- - dAtA[i] = 0x8 - } - return len(dAtA) - i, nil -} - -func encodeVarintSync(dAtA []byte, offset int, v uint64) int { - offset -= sovSync(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *Message) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Header != nil { - l = m.Header.Size() - n += 1 + l + sovSync(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *Header) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.TraceId) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - if m.RequestId != 0 { - n += 1 + sovSync(uint64(m.RequestId)) - } - if m.ReplyId != 0 { - n += 1 + sovSync(uint64(m.ReplyId)) - } - if m.Type != 0 { - n += 1 + sovSync(uint64(m.Type)) - } - l = len(m.DebugInfo) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *System) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Handshake != nil { - l = m.Handshake.Size() - n += 1 + l + sovSync(uint64(l)) - } - if m.Ping != nil { - l = m.Ping.Size() - n += 1 + l + sovSync(uint64(l)) - } - if m.Ack != nil { - l = m.Ack.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *System_Handshake) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.ProtocolVersion) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *System_Ping) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UnixTime != 0 { - n += 1 + sovSync(uint64(m.UnixTime)) - } - return n -} - -func (m *System_Ack) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Error != nil { - l = m.Error.Size() - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func (m *System_Error) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Code != 0 { - n += 1 + sovSync(uint64(m.Code)) - } - l = len(m.Description) - if l > 0 { - n += 1 + l + sovSync(uint64(l)) - } - return n -} - -func sovSync(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSync(x uint64) (n int) { - return sovSync(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *Message) 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 ErrIntOverflowSync - } - 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: Message: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Message: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Header", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Header == nil { - m.Header = &Header{} - } - if err := m.Header.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *Header) 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 ErrIntOverflowSync - } - 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: Header: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Header: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TraceId", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TraceId = append(m.TraceId[:0], dAtA[iNdEx:postIndex]...) - if m.TraceId == nil { - m.TraceId = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field RequestId", wireType) - } - m.RequestId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.RequestId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field ReplyId", wireType) - } - m.ReplyId = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.ReplyId |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Type", wireType) - } - m.Type = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Type |= MessageType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field DebugInfo", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.DebugInfo = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *System) 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 ErrIntOverflowSync - } - 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: System: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: System: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Handshake", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Handshake == nil { - m.Handshake = &System_Handshake{} - } - if err := m.Handshake.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ping", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Ping == nil { - m.Ping = &System_Ping{} - } - if err := m.Ping.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Ack", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Ack == nil { - m.Ack = &System_Ack{} - } - if err := m.Ack.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *System_Handshake) 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 ErrIntOverflowSync - } - 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: Handshake: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Handshake: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ProtocolVersion", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ProtocolVersion = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *System_Ping) 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 ErrIntOverflowSync - } - 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: Ping: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Ping: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field UnixTime", wireType) - } - m.UnixTime = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.UnixTime |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *System_Ack) 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 ErrIntOverflowSync - } - 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: Ack: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Ack: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Error", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSync - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Error == nil { - m.Error = &System_Error{} - } - if err := m.Error.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *System_Error) 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 ErrIntOverflowSync - } - 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: Error: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: Error: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Code", wireType) - } - m.Code = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Code |= System_Error_Code(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Description", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSync - } - 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 ErrInvalidLengthSync - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSync - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Description = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSync(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSync - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSync(dAtA []byte) (n int, err error) { - l := len(dAtA) - iNdEx := 0 - depth := 0 - for iNdEx < l { - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSync - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= (uint64(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - wireType := int(wire & 0x7) - switch wireType { - case 0: - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSync - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - iNdEx++ - if dAtA[iNdEx-1] < 0x80 { - break - } - } - case 1: - iNdEx += 8 - case 2: - var length int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return 0, ErrIntOverflowSync - } - if iNdEx >= l { - return 0, io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - length |= (int(b) & 0x7F) << shift - if b < 0x80 { - break - } - } - if length < 0 { - return 0, ErrInvalidLengthSync - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSync - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSync - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSync = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSync = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSync = fmt.Errorf("proto: unexpected end of group") -) diff --git a/util/crc16/crc16.go b/util/crc16/crc16.go deleted file mode 100644 index 810f4bed..00000000 --- a/util/crc16/crc16.go +++ /dev/null @@ -1,122 +0,0 @@ -// Package crc16 is implementation according to CCITT standards. -// -// Note by @antirez: this is actually the XMODEM CRC 16 algorithm, using the -// following parameters: -// -// Name : "XMODEM", also known as "ZMODEM", "CRC-16/ACORN" -// Width : 16 bit -// Poly : 1021 (That is actually x^16 + x^12 + x^5 + 1) -// Initialization : 0000 -// Reflect Input byte : False -// Reflect Output CRC : False -// Xor constant to output CRC : 0000 -// Output for "123456789" : 31C3 -// -// ported from the c++ code in the stellar-core codebase -// (https://github.com/stellar/stellar-core). The code is licensed -// as: -/* - * Copyright 2001-2010 Georges Menie (www.menie.org) - * Copyright 2010-2012 Salvatore Sanfilippo (adapted to Redis coding style) - * Copyright 2015 Stellar Development Foundation (ported to go) - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * * Neither the name of the University of California, Berkeley nor the - * names of its contributors may be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY - * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package crc16 - -import ( - "bytes" - "encoding/binary" - "fmt" -) - -// ErrInvalidChecksum is returned when Validate determines either the checksum -// or the payload has been corrupted -var ErrInvalidChecksum = fmt.Errorf("invalid checksum") - -var crc16tab = [256]uint16{ - 0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7, - 0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef, - 0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6, - 0x9339, 0x8318, 0xb37b, 0xa35a, 0xd3bd, 0xc39c, 0xf3ff, 0xe3de, - 0x2462, 0x3443, 0x0420, 0x1401, 0x64e6, 0x74c7, 0x44a4, 0x5485, - 0xa56a, 0xb54b, 0x8528, 0x9509, 0xe5ee, 0xf5cf, 0xc5ac, 0xd58d, - 0x3653, 0x2672, 0x1611, 0x0630, 0x76d7, 0x66f6, 0x5695, 0x46b4, - 0xb75b, 0xa77a, 0x9719, 0x8738, 0xf7df, 0xe7fe, 0xd79d, 0xc7bc, - 0x48c4, 0x58e5, 0x6886, 0x78a7, 0x0840, 0x1861, 0x2802, 0x3823, - 0xc9cc, 0xd9ed, 0xe98e, 0xf9af, 0x8948, 0x9969, 0xa90a, 0xb92b, - 0x5af5, 0x4ad4, 0x7ab7, 0x6a96, 0x1a71, 0x0a50, 0x3a33, 0x2a12, - 0xdbfd, 0xcbdc, 0xfbbf, 0xeb9e, 0x9b79, 0x8b58, 0xbb3b, 0xab1a, - 0x6ca6, 0x7c87, 0x4ce4, 0x5cc5, 0x2c22, 0x3c03, 0x0c60, 0x1c41, - 0xedae, 0xfd8f, 0xcdec, 0xddcd, 0xad2a, 0xbd0b, 0x8d68, 0x9d49, - 0x7e97, 0x6eb6, 0x5ed5, 0x4ef4, 0x3e13, 0x2e32, 0x1e51, 0x0e70, - 0xff9f, 0xefbe, 0xdfdd, 0xcffc, 0xbf1b, 0xaf3a, 0x9f59, 0x8f78, - 0x9188, 0x81a9, 0xb1ca, 0xa1eb, 0xd10c, 0xc12d, 0xf14e, 0xe16f, - 0x1080, 0x00a1, 0x30c2, 0x20e3, 0x5004, 0x4025, 0x7046, 0x6067, - 0x83b9, 0x9398, 0xa3fb, 0xb3da, 0xc33d, 0xd31c, 0xe37f, 0xf35e, - 0x02b1, 0x1290, 0x22f3, 0x32d2, 0x4235, 0x5214, 0x6277, 0x7256, - 0xb5ea, 0xa5cb, 0x95a8, 0x8589, 0xf56e, 0xe54f, 0xd52c, 0xc50d, - 0x34e2, 0x24c3, 0x14a0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, - 0xa7db, 0xb7fa, 0x8799, 0x97b8, 0xe75f, 0xf77e, 0xc71d, 0xd73c, - 0x26d3, 0x36f2, 0x0691, 0x16b0, 0x6657, 0x7676, 0x4615, 0x5634, - 0xd94c, 0xc96d, 0xf90e, 0xe92f, 0x99c8, 0x89e9, 0xb98a, 0xa9ab, - 0x5844, 0x4865, 0x7806, 0x6827, 0x18c0, 0x08e1, 0x3882, 0x28a3, - 0xcb7d, 0xdb5c, 0xeb3f, 0xfb1e, 0x8bf9, 0x9bd8, 0xabbb, 0xbb9a, - 0x4a75, 0x5a54, 0x6a37, 0x7a16, 0x0af1, 0x1ad0, 0x2ab3, 0x3a92, - 0xfd2e, 0xed0f, 0xdd6c, 0xcd4d, 0xbdaa, 0xad8b, 0x9de8, 0x8dc9, - 0x7c26, 0x6c07, 0x5c64, 0x4c45, 0x3ca2, 0x2c83, 0x1ce0, 0x0cc1, - 0xef1f, 0xff3e, 0xcf5d, 0xdf7c, 0xaf9b, 0xbfba, 0x8fd9, 0x9ff8, - 0x6e17, 0x7e36, 0x4e55, 0x5e74, 0x2e93, 0x3eb2, 0x0ed1, 0x1ef0, -} - -// Checksum returns the 2-byte checksum for the provided data -func Checksum(data []byte) []byte { - var crc uint16 - var out bytes.Buffer - for _, b := range data { - crc = ((crc << 8) & 0xffff) ^ crc16tab[((crc>>8)^uint16(b))&0x00FF] - } - - err := binary.Write(&out, binary.LittleEndian, crc) - if err != nil { - panic(err) - } - - return out.Bytes() -} - -// Validate returns an error if the provided checksum does not match -// the calculated checksum of the provided data -func Validate(data []byte, expected []byte) error { - - actual := Checksum(data) - - // validate the provided checksum against the calculated - if !bytes.Equal(actual, expected) { - return ErrInvalidChecksum - } - - return nil -} diff --git a/util/strkey/strkey.go b/util/strkey/strkey.go deleted file mode 100644 index 0e766f12..00000000 --- a/util/strkey/strkey.go +++ /dev/null @@ -1,118 +0,0 @@ -package strkey - -import ( - "bytes" - "encoding/binary" - "fmt" - - "github.com/mr-tron/base58/base58" - - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/crc16" -) - -// ErrInvalidVersionByte is returned when the version byte from a provided -// strkey-encoded string is not one of the valid values. -var ErrInvalidVersionByte = fmt.Errorf("invalid version byte") - -// VersionByte represents one of the possible prefix values for a StrKey base -// string--the string the when encoded using base58 yields a final StrKey. -type VersionByte byte - -// Decode decodes the provided StrKey into a raw value, checking the checksum -// and ensuring the expected VersionByte (the version parameter) is the value -// actually encoded into the provided src string. -func Decode(expected VersionByte, src string) ([]byte, error) { - raw, err := decodeString(src) - if err != nil { - return nil, err - } - - // decode into components - version := VersionByte(raw[0]) - vp := raw[0 : len(raw)-2] - payload := raw[1 : len(raw)-2] - checksum := raw[len(raw)-2:] - - // ensure version byte is expected - if version != expected { - return nil, ErrInvalidVersionByte - } - - // ensure checksum is valid - if err := crc16.Validate(vp, checksum); err != nil { - return nil, err - } - - // if we made it through the gaunlet, return the decoded value - return payload, nil -} - -// MustDecode is like Decode, but panics on error -func MustDecode(expected VersionByte, src string) []byte { - d, err := Decode(expected, src) - if err != nil { - panic(err) - } - return d -} - -// Encode encodes the provided data to a StrKey, using the provided version -// byte. -func Encode(version VersionByte, src []byte) (string, error) { - var raw bytes.Buffer - - // write version byte - if err := binary.Write(&raw, binary.LittleEndian, version); err != nil { - return "", err - } - - // write payload - if _, err := raw.Write(src); err != nil { - return "", err - } - - // calculate and write checksum - checksum := crc16.Checksum(raw.Bytes()) - if _, err := raw.Write(checksum); err != nil { - return "", err - } - - result := base58.FastBase58Encoding(raw.Bytes()) - return result, nil -} - -// MustEncode is like Encode, but panics on error -func MustEncode(version VersionByte, src []byte) string { - e, err := Encode(version, src) - if err != nil { - panic(err) - } - return e -} - -// Version extracts and returns the version byte from the provided source -// string. -func Version(src string) (VersionByte, error) { - raw, err := decodeString(src) - if err != nil { - return VersionByte(0), err - } - - return VersionByte(raw[0]), nil -} - -// decodeString decodes a base58 string into the raw bytes, and ensures it could -// potentially be strkey encoded (i.e. it has both a version byte and a -// checksum, neither of which are explicitly checked by this func) -func decodeString(src string) ([]byte, error) { - raw, err := base58.FastBase58Decoding(src) - if err != nil { - return nil, fmt.Errorf("base58 decode failed: %s", err) - } - - if len(raw) < 3 { - return nil, fmt.Errorf("encoded value is %d bytes; minimum valid length is 3", len(raw)) - } - - return raw, nil -} From 67f0b82ae4b25998787f3b9b1cd0d66c0e9ffab3 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 26 Sep 2022 22:26:42 +0200 Subject: [PATCH 37/44] Fix keys --- cmd/node/node.go | 2 -- common/net/secure/service.go | 5 ++--- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmd/node/node.go b/cmd/node/node.go index 6f4cdf88..dd456aa2 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -15,7 +15,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace" - "github.com/anytypeio/go-anytype-infrastructure-experiments/service/node" "go.uber.org/zap" "net/http" _ "net/http/pprof" @@ -90,7 +89,6 @@ func main() { func Bootstrap(a *app.App) { a.Register(account.New()). - Register(node.New()). Register(nodeconf.New()). Register(secure.New()). Register(dialer.New()). diff --git a/common/net/secure/service.go b/common/net/secure/service.go index 40a30f8c..306e2d27 100644 --- a/common/net/secure/service.go +++ b/common/net/secure/service.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/libp2p/go-libp2p-core/crypto" "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/sec" @@ -37,8 +37,7 @@ type service struct { func (s *service) Init(a *app.App) (err error) { account := a.MustComponent(config.CName).(*config.Config).Account - decoder := signingkey.NewEDPrivKeyDecoder() - pkb, err := decoder.DecodeFromStringIntoBytes(account.SigningKey) + pkb, err := keys.DecodeBytesFromString(account.SigningKey) if err != nil { return } From c111257f63a6bf9e930112c50de51b13492abb50 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 27 Sep 2022 13:31:50 +0200 Subject: [PATCH 38/44] Change account logic and add space objects --- cmd/node/node.go | 2 +- common/account/service.go | 65 +---------------------- common/commonspace/service.go | 1 - common/commonspace/space.go | 19 +++---- common/commonspace/spacetree/spacetree.go | 39 -------------- common/commonspace/storage/storage.go | 5 +- common/net/secure/service.go | 24 --------- node/account/service.go | 63 ++++++++++++++++++++++ node/nodespace/nodecache/treecache.go | 10 +++- 9 files changed, 86 insertions(+), 142 deletions(-) delete mode 100644 common/commonspace/spacetree/spacetree.go create mode 100644 node/account/service.go diff --git a/cmd/node/node.go b/cmd/node/node.go index dd456aa2..3a0e0f64 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -6,7 +6,6 @@ import ( "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/dialer" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/pool" @@ -14,6 +13,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/secure" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/node/account" "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace" "go.uber.org/zap" "net/http" diff --git a/common/account/service.go b/common/account/service.go index 8cc55031..bdf6984d 100644 --- a/common/account/service.go +++ b/common/account/service.go @@ -2,73 +2,12 @@ package account import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" - "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" ) -const CName = "account" +const CName = "common.account" type Service interface { + app.Component Account() *account.AccountData } - -type service struct { - accountData *account.AccountData - peerId string -} - -func (s *service) Account() *account.AccountData { - return s.accountData -} - -type StaticAccount struct { - SigningKey string `yaml:"signingKey"` - EncryptionKey string `yaml:"encryptionKey"` -} - -func New() app.Component { - return &service{} -} - -func (s *service) Init(a *app.App) (err error) { - cfg := a.MustComponent(config.CName).(*config.Config) - // TODO: add deviceKey - acc := cfg.Account - - decodedEncryptionKey, err := keys.DecodeKeyFromString( - acc.EncryptionKey, - encryptionkey.NewEncryptionRsaPrivKeyFromBytes, - nil) - if err != nil { - return err - } - - decodedSigningKey, err := keys.DecodeKeyFromString( - acc.SigningKey, - signingkey.NewSigningEd25519PrivKeyFromBytes, - nil) - if err != nil { - return err - } - - identity, err := decodedSigningKey.GetPublic().Raw() - if err != nil { - return err - } - - s.accountData = &account.AccountData{ - Identity: identity, - SignKey: decodedSigningKey, - EncKey: decodedEncryptionKey, - } - s.peerId = acc.PeerId - - return nil -} - -func (s *service) Name() (name string) { - return CName -} diff --git a/common/commonspace/service.go b/common/commonspace/service.go index 1ddf8dd0..ae1edd99 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -51,7 +51,6 @@ func (s *service) CreateSpace(ctx context.Context, id string, deps SpaceDeps) (S syncService := syncservice.NewSyncService(id, diffService, deps.Cache, lastConfiguration) sp := &space{ id: id, - conf: s.config, syncService: syncService, diffService: diffService, cache: deps.Cache, diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 1e319a44..07dac8f6 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -8,7 +8,6 @@ import ( "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/synctree" - "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" @@ -29,9 +28,8 @@ type Space interface { } type space struct { - id string - conf config.Space - mu sync.RWMutex + id string + mu sync.RWMutex rpc *rpcHandler @@ -46,9 +44,13 @@ func (s *space) Id() string { return s.id } -func (s *space) Init(ctx context.Context) error { +func (s *space) Init(ctx context.Context) (err error) { s.rpc = &rpcHandler{s: s} - s.diffService.Init(s.getObjectIds()) + initialIds, err := s.storage.StoredIds() + if err != nil { + return + } + s.diffService.Init(initialIds) s.syncService.Init() // basically this provides access for the external cache to use space's tree building functions s.cache.SetBuildFunc(s.BuildTree) @@ -119,11 +121,6 @@ func (s *space) BuildTree(ctx context.Context, id string, listener synctree.Upda return synctree.BuildSyncTree(ctx, s.syncService, store.(treestorage.TreeStorage), listener, s.aclList) } -func (s *space) getObjectIds() []string { - // TODO: add space object logic - return nil -} - func (s *space) Close() error { s.diffService.Close() s.cache.Close() diff --git a/common/commonspace/spacetree/spacetree.go b/common/commonspace/spacetree/spacetree.go deleted file mode 100644 index a8eab744..00000000 --- a/common/commonspace/spacetree/spacetree.go +++ /dev/null @@ -1,39 +0,0 @@ -package spacetree - -import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" -) - -type SpaceTree interface { - cache.TreeContainer - ID() string - GetObjectIds() []string - Sync() -} - -type spaceTree struct{} - -func (s *spaceTree) Tree() tree.ObjectTree { - //TODO implement me - panic("implement me") -} - -func (s *spaceTree) ID() string { - //TODO implement me - panic("implement me") -} - -func (s *spaceTree) GetObjectIds() []string { - //TODO implement me - panic("implement me") -} - -func (s *spaceTree) Sync() { - //TODO implement me - panic("implement me") -} - -func NewSpaceTree(id string) (SpaceTree, error) { - return &spaceTree{}, nil -} diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index b58d06d1..fb67e1df 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -4,8 +4,9 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" ) +const CName = "commonspace.storage" + type Storage interface { storage.Provider + StoredIds() ([]string, error) } - -const CName = "commonspace.storage" diff --git a/common/net/secure/service.go b/common/net/secure/service.go index 306e2d27..a93c3242 100644 --- a/common/net/secure/service.go +++ b/common/net/secure/service.go @@ -2,13 +2,11 @@ package secure import ( "context" - "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/libp2p/go-libp2p-core/crypto" - "github.com/libp2p/go-libp2p-core/peer" "github.com/libp2p/go-libp2p-core/sec" libp2ptls "github.com/libp2p/go-libp2p/p2p/security/tls" "go.uber.org/zap" @@ -45,28 +43,6 @@ func (s *service) Init(a *app.App) (err error) { return } - pid, err := peer.Decode(account.PeerId) - if err != nil { - return - } - - var testData = []byte("test data") - sign, err := s.key.Sign(testData) - if err != nil { - return - } - pubKey, err := pid.ExtractPublicKey() - if err != nil { - return - } - ok, err := pubKey.Verify(testData, sign) - if err != nil { - return - } - if !ok { - return fmt.Errorf("peerId and privateKey mismatched") - } - log.Info("secure service init", zap.String("peerId", account.PeerId)) return nil diff --git a/node/account/service.go b/node/account/service.go new file mode 100644 index 00000000..f9f7a6a2 --- /dev/null +++ b/node/account/service.go @@ -0,0 +1,63 @@ +package account + +import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + commonaccount "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" +) + +type service struct { + accountData *account.AccountData + peerId string +} + +func (s *service) Account() *account.AccountData { + return s.accountData +} + +func New() app.Component { + return &service{} +} + +func (s *service) Init(a *app.App) (err error) { + cfg := a.MustComponent(config.CName).(*config.Config) + acc := cfg.Account + + decodedEncryptionKey, err := keys.DecodeKeyFromString( + acc.EncryptionKey, + encryptionkey.NewEncryptionRsaPrivKeyFromBytes, + nil) + if err != nil { + return err + } + + decodedSigningKey, err := keys.DecodeKeyFromString( + acc.SigningKey, + signingkey.NewSigningEd25519PrivKeyFromBytes, + nil) + if err != nil { + return err + } + + identity, err := decodedSigningKey.GetPublic().Raw() + if err != nil { + return err + } + + s.accountData = &account.AccountData{ + Identity: identity, + SignKey: decodedSigningKey, + EncKey: decodedEncryptionKey, + } + s.peerId = acc.PeerId + + return nil +} + +func (s *service) Name() (name string) { + return commonaccount.CName +} diff --git a/node/nodespace/nodecache/treecache.go b/node/nodespace/nodecache/treecache.go index af195df9..926bced6 100644 --- a/node/nodespace/nodecache/treecache.go +++ b/node/nodespace/nodecache/treecache.go @@ -2,6 +2,7 @@ package nodecache import ( "context" + "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" @@ -9,6 +10,7 @@ import ( ) var log = logger.NewNamed("treecache") +var ErrCacheObjectWithoutTree = errors.New("cache object contains no tree") type treeCache struct { gcttl int @@ -44,11 +46,17 @@ func (c *treeCache) GetTree(ctx context.Context, id string) (res cache.TreeResul return cache.TreeResult{}, err } + treeContainer, ok := cacheRes.(cache.TreeContainer) + if !ok { + err = ErrCacheObjectWithoutTree + return + } + res = cache.TreeResult{ Release: func() { c.cache.Release(id) }, - TreeContainer: cacheRes.(cache.TreeContainer), + TreeContainer: treeContainer, } return } From ac3a50a31c0273266902736d91efd7cb7abef7ef Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 27 Sep 2022 14:05:21 +0200 Subject: [PATCH 39/44] Gen new configs --- cmd/nodesgen/gen.go | 8 ++++-- etc/config.1.yml | 16 ------------ etc/config.2.yml | 16 ------------ etc/config.yml | 25 +++++++++---------- ...K2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml | 25 ------------------- ...zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml | 25 ------------------- etc/configs/config1.yml | 24 ++++++++++++++++++ etc/configs/config2.yml | 24 ++++++++++++++++++ 8 files changed, 66 insertions(+), 97 deletions(-) delete mode 100644 etc/config.1.yml delete mode 100644 etc/config.2.yml delete mode 100755 etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml delete mode 100755 etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml create mode 100755 etc/configs/config1.yml create mode 100755 etc/configs/config2.yml diff --git a/cmd/nodesgen/gen.go b/cmd/nodesgen/gen.go index 3e1104a5..2eddeab6 100644 --- a/cmd/nodesgen/gen.go +++ b/cmd/nodesgen/gen.go @@ -76,8 +76,8 @@ func main() { } createDir() } - for _, cfg := range configs { - path := fmt.Sprintf("%s/%s.yml", configsPath, cfg.Account.PeerId) + for idx, cfg := range configs { + path := fmt.Sprintf("%s/config%d.yml", configsPath, idx+1) bytes, err := yaml.Marshal(cfg) if err != nil { panic(fmt.Sprintf("could not marshal the keys: %v", err)) @@ -130,5 +130,9 @@ func genConfig(addresses []string, apiPort string) (config.Config, error) { APIServer: config.APIServer{ Port: apiPort, }, + Space: config.Space{ + GCTTL: 60, + SyncPeriod: 10, + }, }, nil } diff --git a/etc/config.1.yml b/etc/config.1.yml deleted file mode 100644 index 093d1ef7..00000000 --- a/etc/config.1.yml +++ /dev/null @@ -1,16 +0,0 @@ -anytype: - swarmKey: "/key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec" - -grpcServer: - listenAddrs: - - "127.0.0.1:4431" - -peerList: - myId: - peerId: "12D3KooWA4FLWvrMbCtp2MbzKcC5RRN7HqxxBxPcSADFfzrGiW3U" - privKey: "InCGjb55V9+jj2PebUExUuwrpOIBc4hmgk2dSqyk3k4DjmgrdoNVuFe7xCFaFdUVb0RJYj6A+OTp2yXASTmq2w==" - remote: - - peerId: "12D3KooWHJpSEMQUZCyK8TK181LhjzntWjKfXDr7MWks9cw41R2C" - addr: "127.0.0.1:4430" - - peerId: "12D3KooWK6c1CPLL4Bvjim9A9SDRmehy12hYjbqX1VASHKfH7W7H" - addr: "127.0.0.1:4432" diff --git a/etc/config.2.yml b/etc/config.2.yml deleted file mode 100644 index 701fdc5f..00000000 --- a/etc/config.2.yml +++ /dev/null @@ -1,16 +0,0 @@ -anytype: - swarmKey: "/key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec" - -grpcServer: - listenAddrs: - - "127.0.0.1:4432" - -peerList: - myId: - peerId: "12D3KooWK6c1CPLL4Bvjim9A9SDRmehy12hYjbqX1VASHKfH7W7H" - privKey: "jynYZBgtM4elT+6e7M5UERTJCZgUd3hDdmQjCqTpApyJ4h53V6TQan4Ru4OXqz+91rCLjpIVdphhaB0l+TvNsA==" - remote: - - peerId: "12D3KooWA4FLWvrMbCtp2MbzKcC5RRN7HqxxBxPcSADFfzrGiW3U" - addr: "127.0.0.1:4431" - - peerId: "12D3KooWHJpSEMQUZCyK8TK181LhjzntWjKfXDr7MWks9cw41R2C" - addr: "127.0.0.1:4430" diff --git a/etc/config.yml b/etc/config.yml index 09b13d54..8c829b5f 100644 --- a/etc/config.yml +++ b/etc/config.yml @@ -3,23 +3,22 @@ anytype: grpcServer: listenAddrs: - 127.0.0.1:4430 - - 127.0.0.1:4431 tls: false account: - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnz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QKYy2QqfvPNBFnzR2ubA1.yml deleted file mode 100755 index dcea6558..00000000 --- a/etc/configs/12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1.yml +++ /dev/null @@ -1,25 +0,0 @@ -anytype: - swarmKey: /key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec -grpcServer: - listenAddrs: - - 127.0.0.1:4430 - - 127.0.0.1:4431 - tls: false -account: - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 - signingKey: 3id6ddLcoNoe9rDgGM88ET8T6TnvHm5GFqFdN6kBzn7Q8d6VUGgjeT59CNWFiaofdeRnHBvX2A5ZacMXvfwaYEFuCbug - encryptionKey: JgG4CcCbae1qEpe7mKpBzsHjZhXUmDSNVNX2B1gxFZsJyMX4V6kBQUott9zRWyeXaW1ZmpzuxDXnwSQpAnNurhXyGa9iQaAPqzY9A9VWBPD33Yy1eW7TRuVemzToh8jJQKQKnZNbF8ucTWV9qahusKzyvN8uyhrqoW2tAPfA9S3E3ognCuqbLSW6yjE2rBKayvyS1BVwzjSd6FZK4DDyjfU3pbEVjut3wytGEAn9af6sNMmyCnf2MX5vLovWs9rU8av61wD4z7HTsXyGFx4K75N4Go249Hpe9SKAT6HxhRc3yvj63krPLiQV5yMuH2UeMUXBDekUQyNmBEdn9wrur7mLqB67Bc6tcc2PP8XApBCdWJHvHjN4FktSpaG5vbCqoZbLD1oCbk36q2x9s6XM8pydVqD1J9P3nTbfgMb5pJCTFjNtgKeuKv6wjfJeA9jF1VhcJQisfsahgv9MvZ9M8FJpZTq1zKUhYDCRnZxUkraoMS5yNNVdDzaUckKEDthqik7BMWCWT79vq7uVgMwEvGwGi76gtoMg1159bbPMLZ4bdPVfhH2S9QjPrzQfwZSrzB2YeVPjWpaXDeLDity5H8n1NK2oniAQR6gE71n81neSptsuhV6o6QpQ89AU8y57XmEsou4VEryn8vUxBHhULLxrLNUouxyWamCeFiDjk5cSN6koQsf9BYKSNTPFTrwjTKForDokMhcPdMtFktKwjv7u9UEGcY4MKvNzZZkc77gHiP8bqVtdNNoLpTFUC5SZ9i7bKdHvK12HpSy7yzzPeMXJ9UwhLxkok1g81ngTbN1yxRhvYXyHZFtguCR9kvGojDjka91MTBtk551qDw9eCn2xZT9U8jqzBCjdpvSg3mRWKMPnYAGB7m7u1ye165wyGFvzcHAx3vtXjxAqLUeKYZCjv2m6V9D2Y4qH1TQNddWqH14T1JVMis971UCH9Ddpj6a3387oUnufD1P6HZN2ieJCvptrmbGVvxJYYSvmVf1dkwbtqurDRNWD7TJ7gf6iqSP549C9bxP4GpLt3ygjHmMtcuUzstBuztvunJUnQhfnJxqU6LjRdsFzm53wGWgXNxab7ZvQcPyLwsevn1b98FGPnVpS5iY4LjmqW4ugrC6HgrbsjrXiKzR1yZKhLQkCbLzPoaHb8iB5iBnCr7d4yf5CtfpFRqgoqMFdK5LNZYmDX4HzUKN6A7wC3gGiSRFTLcgGZeSMkB5Pa61CZBU7WCQgFxykycE9HRA7PiQa496GWDCV15teToCpFRsAa6jDmR1MGXPeLRqQgve49VXnQN5FL7c1VuEv5SWjeTuCnMB47DJKBaP7eKJNKgLwETALzSCMF3nRiRgeb15kfoS4BbrJ5yupjrvwmbmvNg1AYFFS5sYNWft7K8v87wQvBakRtGP71Kp8NX77XFtu6xdB7sR6jpfC6qJPyB9akWNXgCrWy9kE4ih42gwAZdUugNZ9YtEsgRM3pwb6qJhkAPyEJtrxrja859PCAgqPSQiPQN33PaMkgQ6HJknu8CrjKRiXAycZ16KLUkHV64TNhEjPTcX1a7rqpD131AYMWX8d7CCdc9Ys7RUb6BwguuNSh8rJK3x4AkMDSUsaE8ynKvpC7RXZpJ9Nxfhd -apiServer: - port: "8080" -space: - gcTTL: 60 - syncPeriod: 10 -nodes: - - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 - address: 127.0.0.1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V1hjZPPd6ZxT1FuRozB6Qt2NLcyqY7bnTcQJb1jPUaTAGXXCR8WVmmmYo2fDQe8CdBmgyPvbzNTEJUyScBz4RdycB5PZap4SurJCWtHbuMyQbQUB6jJgURDstfXS5Akfe4oruNq9rnYcNtnsDJPtrhXHBqzDizmf1BDxR5FB2RCxzCgeAfg8WQ1Ug9PVAGTzob6ZqCrGXzWXEUniZnf1vjr7QhGKBYXEX9SWDoSMUpP4FreVDTnx15ijRZTV3p8xG5fE9e36TnugRVvTyq7XzmyPBjW2r66f1bior diff --git a/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml b/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml deleted file mode 100755 index eb88a19b..00000000 --- a/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml +++ /dev/null @@ -1,25 +0,0 @@ -anytype: - swarmKey: /key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec -grpcServer: - listenAddrs: - - 127.0.0.1:4432 - - 127.0.0.1:4433 - tls: false -account: - peerId: 12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw - signingKey: 3iiLPj6wMUQpPwTBNZcUgkbXub1jumg4AEV9LfMyFHZVc84GLyAjVbVvH6EAGhcNrxRxL82aW4BimhDZCpLsRCqx5vwj - encryptionKey: JgG4CcCbae1qEpe7mKXzp7m5hNc56SSyZd9DwUaEStKJrq7RToAC2Vgd3i6hKRwa58zCWeN6Wjc3o6qrdKPEPRvcyEPysamajVo5mdQiUgWAmr97pGEsyjuRjQoC2GY2LvLiEQxEgwFgJxKGMHMiaWMtDfxCDUaDEm4bu5RdMhqRZekAWho6c3WoEeruSr14iX1TrocFNfBkBY7CjEw8kcywXCTNgtvhb2Qiwgj5AxEF4wy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NxfomHokWacV1hjZPPd6ZxT1FuRozB6Qt2NLcyqY7bnTcQJb1jPUaTAGXXCR8WVmmmYo2fDQe8CdBmgyPvbzNTEJUyScBz4RdycB5PZap4SurJCWtHbuMyQbQUB6jJgURDstfXS5Akfe4oruNq9rnYcNtnsDJPtrhXHBqzDizmf1BDxR5FB2RCxzCgeAfg8WQ1Ug9PVAGTzob6ZqCrGXzWXEUniZnf1vjr7QhGKBYXEX9SWDoSMUpP4FreVDTnx15ijRZTV3p8xG5fE9e36TnugRVvTyq7XzmyPBjW2r66f1bior -apiServer: - port: "8081" -space: - gcTTL: 60 - syncPeriod: 10 -nodes: - - peerId: 12D3KooWMHuhZgK2skkLrvL51QQTXaXQKYy2QqfvPNBFnzR2ubA1 - address: 127.0.0.1:4430 - signingKey: 3id6ddLcoNoe9rDgGM88ET8T6TnvHm5GFqFdN6kBzn7Q8d6VUGgjeT59CNWFiaofdeRnHBvX2A5ZacMXvfwaYEFuCbug - encryptionKey: JgG4CcCbae1qEpe7mKpBzsHjZhXUmDSNVNX2B1gxFZsJyMX4V6kBQUott9zRWyeXaW1ZmpzuxDXnwSQpAnNurhXyGa9iQaAPqzY9A9VWBPD33Yy1eW7TRuVemzToh8jJQKQKnZNbF8ucTWV9qahusKzyvN8uyhrqoW2tAPfA9S3E3ognCuqbLSW6yjE2rBKayvyS1BVwzjSd6FZK4DDyjfU3pbEVjut3wytGEAn9af6sNMmyCnf2MX5vLovWs9rU8av61wD4z7HTsXyGFx4K75N4Go249Hpe9SKAT6HxhRc3yvj63krPLiQV5yMuH2UeMUXBDekUQyNmBEdn9wrur7mLqB67Bc6tcc2PP8XApBCdWJHvHjN4FktSpaG5vbCqoZbLD1oCbk36q2x9s6XM8pydVqD1J9P3nTbfgMb5pJCTFjNtgKeuKv6wjfJeA9jF1VhcJQisfsahgv9MvZ9M8FJpZTq1zKUhYDCRnZxUkraoMS5yNNVdDzaUckKEDthqik7BMWCWT79vq7uVgMwEvGwGi76gtoMg1159bbPMLZ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7tXYUpoYyuSdWwKPjSAMtaQcCSfVrhKQHQuKJargrVrez8vjWuwLfvSucV7ZHe7gjqvYgULdE1ubRCRSd7DuLjEN2Vd6obzV2c3MRet7ZSf4Sp88WM5AuTyW7BjArBc4S3gUQ8rYaiZ8Tu7NCxkEzbFwWRaemZkwfvcsX3XxqjyF37tFSGkEqE5kuBvpZW72675LkDffj7kH1zA8yE6dVujJjWsNYVFJWndUtz5Vy2KCdZAbBgq19q4AtsxWPodU2N3yZXzFAFAzTrxS6V4P7Scpdau1avgRvHLcBQPunA37xaYMy8YMifJwtmRY25mnAQwZAk3eANk7tXwZd58SDnciLNvARJvwKzTQBXcshkwyy52SX8XmXDJsPnRLaHmiYBJ63Yzr5XpZuuAtxb9qrWG2NHCNxfomHokWacV1hjZPPd6ZxT1FuRozB6Qt2NLcyqY7bnTcQJb1jPUaTAGXXCR8WVmmmYo2fDQe8CdBmgyPvbzNTEJUyScBz4RdycB5PZap4SurJCWtHbuMyQbQUB6jJgURDstfXS5Akfe4oruNq9rnYcNtnsDJPtrhXHBqzDizmf1BDxR5FB2RCxzCgeAfg8WQ1Ug9PVAGTzob6ZqCrGXzWXEUniZnf1vjr7QhGKBYXEX9SWDoSMUpP4FreVDTnx15ijRZTV3p8xG5fE9e36TnugRVvTyq7XzmyPBjW2r66f1bior diff --git a/etc/configs/config1.yml b/etc/configs/config1.yml new file mode 100755 index 00000000..4885eab8 --- /dev/null +++ b/etc/configs/config1.yml @@ -0,0 +1,24 @@ +anytype: + swarmKey: /key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec +grpcServer: + listenAddrs: + - 127.0.0.1:4430 + tls: false +account: + peerId: 12D3KooWSUx2LXPvoZGp72Dt7b7r1kPSmQ6zAUwKkHFyX64uiXRu + signingKey: 4QTrtkFLQe9wQcWT/cgFEwfMHB5pt4axInNmCIMCZaz3nVdyygRoO8/YH0V15X6Mnw1NQWsS1YIWiLS22hwepA== + encryptionKey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g9yEYQ//30yTcpUjsGlqGNzua2OvALGL2ntFY304X9Iego+7Tzxs3T0x2FQ1N33NhoxwRcMqBdksMqmCb8Bm8UvnFIuvmsfPGkkzwa/8xNH81GZiz0p9zfi4lSKdZRfTQ4lBqvogExdnalSd0CgYEAyy2Mw4eeJQ0Y6QX3nad2/06oxWiS3++CITI6dAqiepAB6V7lnP90NKfLgzJcCJwzKlMhoVv7Lu4bDCXbvQ03ba+Dl+To8Jf5/9di8j8OfllqDWPnbqyueTHu5CUk+A2Gz3RhjmMXHpVgbFkUJTkJ1RDWPImNq0KzTYQ+ZwU8lO8CgYEAo1/0zuisnXowedew3HyLw17tUeiUoMTTwdiJLduh6Qle8UKvupK4svRzcBBFFbnEGiaXSFAqmj2AMxMHzBOljpsRSiJ7L2uWzLleLQpOcpBsf7sZ6guWoIGQ6zCtMEJMkkJAT0UTfJYjJmazVEg1lLdni1enwRmggX7ZnoRsewkCgYB2SpLF1FOSpsl2Ae9kbnettRI1vOimUD+nLCM0JGzshqNWR9XPTjtN3NN0EwHaUXbIkZXm6DKZ5C8DJ5eDvgojZihrau7kBNecyL3m5CeAEHbaTOwVV5xNG3FGiwm3EckHR271A2QWfkmhS0ubUFYVIrRYko1UxIS4AOKEAFyBKQKBgQCfIsGy4wOqRsKLzbun6fIVSz8X+sS3HclD7UZ6WKanOYyWZ420qnhLnfdDcNQjF/ApbzHdfwwTKVJSaZiK23kmReUVB9Cq2YAHMJYlp0ErgPzZstrRiRidtzJHm93owWc7GZinzd1M8EOYUSJ3+t8EZXZlbsD/oCTbX/BGqolo2w== +space: + gcTTL: 60 + syncPeriod: 10 diff --git a/etc/configs/config2.yml b/etc/configs/config2.yml new file mode 100755 index 00000000..5e1eaadb --- /dev/null +++ b/etc/configs/config2.yml @@ -0,0 +1,24 @@ +anytype: + swarmKey: /key/swarm/psk/1.0.0/base16/209992e611c27d5dce8fbd2e7389f6b51da9bee980992ef60739460b536139ec +grpcServer: + listenAddrs: + - 127.0.0.1:4431 + t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on Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Tue, 27 Sep 2022 19:43:39 +0300 Subject: [PATCH 40/44] rpc errors --- common/net/rpc/rpcerr/registry.go | 51 +++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 common/net/rpc/rpcerr/registry.go diff --git a/common/net/rpc/rpcerr/registry.go b/common/net/rpc/rpcerr/registry.go new file mode 100644 index 00000000..872c0fd9 --- /dev/null +++ b/common/net/rpc/rpcerr/registry.go @@ -0,0 +1,51 @@ +package rpcerr + +import ( + "errors" + "fmt" + "storj.io/drpc/drpcerr" +) + +var ( + Unexpected = RegisterErr(errors.New("unexpected"), 1) + Closed = RegisterErr(errors.New("closed"), 2) +) + +var ( + errsMap = make(map[uint64]error) +) + +func RegisterErr(err error, code uint64) error { + if e, ok := errsMap[code]; ok { + panic(fmt.Errorf("attempt to register error with exiswting code: %d; registered error: %v", code, e)) + } + errWithCode := drpcerr.WithCode(err, code) + errsMap[code] = errWithCode + return errWithCode +} + +func Err(code uint64) error { + err, ok := errsMap[code] + if !ok { + return drpcerr.WithCode(fmt.Errorf("unexpected error, code: %d", code), code) + } + return err +} + +func Unwrap(e error) error { + code := drpcerr.Code(e) + if code == 0 { + return e + } + err, ok := errsMap[code] + if !ok { + return drpcerr.WithCode(fmt.Errorf("unexpected error: %v; code: %d", err, code), code) + } + return err +} + +type ErrGroup int64 + +func (g ErrGroup) Register(err error, code uint64) error { + return RegisterErr(err, uint64(g)+code) +} From 51af8c223df16050c0e09990676684bedfbe70fe Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Tue, 27 Sep 2022 21:06:49 +0200 Subject: [PATCH 41/44] Add space/tree creation and derivation and push space protocol changes --- Makefile | 2 +- cmd/node/node.go | 1 + common/commonspace/diffservice/diffservice.go | 4 +- common/commonspace/service.go | 231 +++++++- common/commonspace/space.go | 29 +- .../spacesyncproto/protos/spacesync.proto | 22 +- .../spacesyncproto/spacesync.pb.go | 524 ++++++++++++++++-- .../spacesyncproto/spacesync_drpc.pb.go | 42 +- common/commonspace/storage/storage.go | 17 +- common/commonspace/syncservice/syncservice.go | 3 +- common/commonspace/synctree/synctree.go | 24 + node/nodespace/rpchandler.go | 4 + node/nodespace/service.go | 7 +- pkg/acl/tree/changebuilder.go | 3 +- pkg/acl/tree/objecttreefactory.go | 27 +- 15 files changed, 858 insertions(+), 82 deletions(-) diff --git a/Makefile b/Makefile index e9143f01..53ddd25b 100644 --- a/Makefile +++ b/Makefile @@ -27,7 +27,7 @@ proto: $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_RECORDS_PATH_PB)/protos/*.proto $(GOGO_START) protoc --gogofaster_out=:. $(P_TREE_CHANGES_PATH_PB)/protos/*.proto $(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto - $(eval PKGMAP := $$(P_TREE_CHANGES)) + $(eval PKGMAP := $$(P_TREE_CHANGES),$$(P_ACL_RECORDS)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto diff --git a/cmd/node/node.go b/cmd/node/node.go index 3a0e0f64..47d0c3e5 100644 --- a/cmd/node/node.go +++ b/cmd/node/node.go @@ -89,6 +89,7 @@ func main() { func Bootstrap(a *app.App) { a.Register(account.New()). + // TODO: add space storage provider from node side Register(nodeconf.New()). Register(secure.New()). Register(dialer.New()). diff --git a/common/commonspace/diffservice/diffservice.go b/common/commonspace/diffservice/diffservice.go index b530d05f..71cf36ce 100644 --- a/common/commonspace/diffservice/diffservice.go +++ b/common/commonspace/diffservice/diffservice.go @@ -27,7 +27,7 @@ type DiffService interface { type diffService struct { spaceId string periodicSync *periodicSync - storage storage.Storage + storage storage.SpaceStorage nconf nodeconf.Configuration diff ldiff.Diff cache cache.TreeCache @@ -39,7 +39,7 @@ type diffService struct { func NewDiffService( spaceId string, syncPeriod int, - storage storage.Storage, + storage storage.SpaceStorage, nconf nodeconf.Configuration, cache cache.TreeCache, log *zap.Logger) DiffService { diff --git a/common/commonspace/service.go b/common/commonspace/service.go index ae1edd99..f5b10591 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -6,10 +6,17 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "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/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" + "hash/fnv" + "math/rand" + "time" ) const CName = "common.commonspace" @@ -21,22 +28,21 @@ func New() Service { } type Service interface { - CreateSpace(ctx context.Context, id string, deps SpaceDeps) (sp Space, err error) + CreateSpace(ctx context.Context, cache cache.TreeCache, payload SpaceCreatePayload) (Space, error) + DeriveSpace(ctx context.Context, cache cache.TreeCache, payload SpaceDerivePayload) (Space, error) + GetSpace(ctx context.Context, id string, cache cache.TreeCache) (sp Space, err error) app.Component } type service struct { config config.Space configurationService nodeconf.Service -} - -type SpaceDeps struct { - Cache cache.TreeCache - Storage storage.Storage + storageProvider storage.SpaceStorageProvider } func (s *service) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(*config.Config).Space + s.storageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider) s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) return nil } @@ -45,19 +51,222 @@ func (s *service) Name() (name string) { return CName } -func (s *service) CreateSpace(ctx context.Context, id string, deps SpaceDeps) (Space, error) { +func (s *service) CreateSpace( + ctx context.Context, + cache cache.TreeCache, + payload SpaceCreatePayload) (sp Space, err error) { + + // unmarshalling signing and encryption keys + identity, err := payload.SigningKey.GetPublic().Raw() + if err != nil { + return + } + encPubKey, err := payload.EncryptionKey.GetPublic().Raw() + if err != nil { + return + } + + // preparing header and space id + bytes := make([]byte, 32) + _, err = rand.Read(bytes) + if err != nil { + return + } + header := &spacesyncproto.SpaceHeader{ + Identity: identity, + Timestamp: time.Now().UnixNano(), + SpaceType: payload.SpaceType, + ReplicationKey: payload.ReplicationKey, + Seed: bytes, + } + marshalled, err := header.Marshal() + if err != nil { + return + } + id, err := cid.NewCIDFromBytes(marshalled) + if err != nil { + return + } + spaceId := NewSpaceId(id, payload.ReplicationKey) + + // encrypting read key + hasher := fnv.New64() + _, err = hasher.Write(payload.ReadKey) + if err != nil { + return + } + readKeyHash := hasher.Sum64() + encReadKey, err := payload.EncryptionKey.GetPublic().Encrypt(payload.ReadKey) + if err != nil { + return + } + + // preparing acl + aclRoot := &aclrecordproto.ACLRoot{ + Identity: identity, + EncryptionKey: encPubKey, + SpaceId: spaceId, + EncryptedReadKey: encReadKey, + DerivationScheme: "", + CurrentReadKeyHash: readKeyHash, + Timestamp: time.Now().UnixNano(), + } + rawWithId, err := marshalACLRoot(aclRoot, payload.SigningKey) + if err != nil { + return + } + + // creating storage + storageCreate := storage.SpaceStorageCreatePayload{ + RecWithId: rawWithId, + SpaceHeader: header, + Id: id, + } + _, err = s.storageProvider.CreateSpaceStorage(storageCreate) + if err != nil { + return + } + + return s.GetSpace(ctx, spaceId, cache) +} + +func (s *service) DeriveSpace( + ctx context.Context, + cache cache.TreeCache, + payload SpaceDerivePayload) (sp Space, err error) { + + // unmarshalling signing and encryption keys + identity, err := payload.SigningKey.GetPublic().Raw() + if err != nil { + return + } + signPrivKey, err := payload.SigningKey.Raw() + if err != nil { + return + } + encPubKey, err := payload.EncryptionKey.GetPublic().Raw() + if err != nil { + return + } + encPrivKey, err := payload.EncryptionKey.Raw() + if err != nil { + return + } + + // preparing replication key + hasher := fnv.New64() + _, err = hasher.Write(identity) + if err != nil { + return + } + repKey := hasher.Sum64() + + // preparing header and space id + header := &spacesyncproto.SpaceHeader{ + Identity: identity, + SpaceType: SpaceTypeDerived, + ReplicationKey: repKey, + } + marshalled, err := header.Marshal() + if err != nil { + return + } + id, err := cid.NewCIDFromBytes(marshalled) + if err != nil { + return + } + spaceId := NewSpaceId(id, repKey) + + // deriving and encrypting read key + readKey, err := aclrecordproto.ACLReadKeyDerive(signPrivKey, encPrivKey) + if err != nil { + return + } + hasher = fnv.New64() + _, err = hasher.Write(readKey.Bytes()) + if err != nil { + return + } + readKeyHash := hasher.Sum64() + encReadKey, err := payload.EncryptionKey.GetPublic().Encrypt(readKey.Bytes()) + if err != nil { + return + } + + // preparing acl + aclRoot := &aclrecordproto.ACLRoot{ + Identity: identity, + EncryptionKey: encPubKey, + SpaceId: spaceId, + EncryptedReadKey: encReadKey, + DerivationScheme: "", + CurrentReadKeyHash: readKeyHash, + Timestamp: time.Now().UnixNano(), + } + rawWithId, err := marshalACLRoot(aclRoot, payload.SigningKey) + if err != nil { + return + } + + // creating storage + storageCreate := storage.SpaceStorageCreatePayload{ + RecWithId: rawWithId, + SpaceHeader: header, + Id: id, + } + _, err = s.storageProvider.CreateSpaceStorage(storageCreate) + if err != nil { + return + } + + return s.GetSpace(ctx, spaceId, cache) +} + +func (s *service) GetSpace(ctx context.Context, id string, cache cache.TreeCache) (Space, error) { + st, err := s.storageProvider.SpaceStorage(id) + if err != nil { + return nil, err + } lastConfiguration := s.configurationService.GetLast() - diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, deps.Storage, lastConfiguration, deps.Cache, log) - syncService := syncservice.NewSyncService(id, diffService, deps.Cache, lastConfiguration) + diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, lastConfiguration, cache, log) + syncService := syncservice.NewSyncService(id, diffService, cache, lastConfiguration) sp := &space{ id: id, syncService: syncService, diffService: diffService, - cache: deps.Cache, - storage: deps.Storage, + cache: cache, + storage: st, } if err := sp.Init(ctx); err != nil { return nil, err } return sp, nil } + +func marshalACLRoot(aclRoot *aclrecordproto.ACLRoot, key signingkey.PrivKey) (rawWithId *aclrecordproto.RawACLRecordWithId, err error) { + marshalledRoot, err := aclRoot.Marshal() + if err != nil { + return + } + signature, err := key.Sign(marshalledRoot) + if err != nil { + return + } + raw := &aclrecordproto.RawACLRecord{ + Payload: marshalledRoot, + Signature: signature, + } + marshalledRaw, err := raw.Marshal() + if err != nil { + return + } + aclHeadId, err := cid.NewCIDFromBytes(marshalledRaw) + if err != nil { + return + } + rawWithId = &aclrecordproto.RawACLRecordWithId{ + Payload: marshalledRaw, + Id: aclHeadId, + } + return +} diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 07dac8f6..31c2fdfa 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -2,6 +2,7 @@ package commonspace import ( "context" + "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/diffservice" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" @@ -11,9 +12,30 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "sync" ) +type SpaceCreatePayload struct { + SigningKey signingkey.PrivKey + EncryptionKey encryptionkey.PrivKey + SpaceType string + ReadKey []byte + ReplicationKey uint64 +} + +const SpaceTypeDerived = "derived.space" + +type SpaceDerivePayload struct { + SigningKey signingkey.PrivKey + EncryptionKey encryptionkey.PrivKey +} + +func NewSpaceId(id string, repKey uint64) string { + return fmt.Sprintf("%s.%d", id, repKey) +} + type Space interface { Id() string @@ -21,6 +43,7 @@ type Space interface { SyncService() syncservice.SyncService DiffService() diffservice.DiffService + DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) BuildTree(ctx context.Context, id string, listener synctree.UpdateListener) (tree.ObjectTree, error) @@ -35,7 +58,7 @@ type space struct { syncService syncservice.SyncService diffService diffservice.DiffService - storage storage.Storage + storage storage.SpaceStorage cache cache.TreeCache aclList list.ACLList } @@ -69,6 +92,10 @@ func (s *space) DiffService() diffservice.DiffService { return s.diffService } +func (s *space) DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) { + return synctree.DeriveSyncTree(ctx, payload, s.syncService, listener, s.aclList, s.storage.CreateTreeStorage) +} + func (s *space) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) { return synctree.CreateSyncTree(ctx, payload, s.syncService, listener, s.aclList, s.storage.CreateTreeStorage) } diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index d4d65733..8131db4f 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -3,6 +3,7 @@ package anySpace; option go_package = "common/commonspace/spacesyncproto"; import "pkg/acl/treechangeproto/protos/treechange.proto"; +import "pkg/acl/aclrecordproto/protos/aclrecord.proto"; enum ErrCodes { Unexpected = 0; @@ -11,6 +12,9 @@ enum ErrCodes { service Space { // HeadSync compares all objects and their hashes in a space rpc HeadSync(HeadSyncRequest) returns (HeadSyncResponse); + // PushSpace sends new space to the node + rpc PushSpace(PushSpaceRequest) returns (PushSpaceResponse); + // Stream opens object sync stream with node or client rpc Stream(stream ObjectSyncMessage) returns (stream ObjectSyncMessage); } @@ -52,9 +56,9 @@ message ObjectSyncMessage { treechange.RawTreeChangeWithId rootChange = 3; string treeId = 4; string trackingId = 5; -// -// string identity = 5; -// string peerSignature = 6; + +// string identity = 5; +// string peerSignature = 6; } // ObjectSyncContentValue provides different types for object sync @@ -88,10 +92,22 @@ message ObjectFullSyncResponse { repeated string snapshotPath = 3; } +// ObjectErrorResponse is an error sent as a response for a full sync request message ObjectErrorResponse { string error = 1; } +// PushSpaceRequest is a request to add space on a node containing only one acl record +message PushSpaceRequest { + string spaceId = 1; + SpaceHeader spaceHeader = 2; + aclrecord.RawACLRecordWithId aclRoot = 3; +} + +// PushSpaceResponse is an empty response +message PushSpaceResponse {} + +// SpaceHeader is a header for a space message SpaceHeader { bytes identity = 1; int64 timestamp = 2; diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 6cbcba84..8cffa076 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -5,6 +5,7 @@ package spacesyncproto import ( fmt "fmt" + aclrecordproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" proto "github.com/gogo/protobuf/proto" io "io" @@ -690,6 +691,7 @@ func (m *ObjectFullSyncResponse) GetSnapshotPath() []string { return nil } +// ObjectErrorResponse is an error sent as a response for a full sync request type ObjectErrorResponse struct { Error string `protobuf:"bytes,1,opt,name=error,proto3" json:"error,omitempty"` } @@ -734,6 +736,105 @@ func (m *ObjectErrorResponse) GetError() string { return "" } +// PushSpaceRequest is a request to add space on a node containing only one acl record +type PushSpaceRequest struct { + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,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"` +} + +func (m *PushSpaceRequest) Reset() { *m = PushSpaceRequest{} } +func (m *PushSpaceRequest) String() string { return proto.CompactTextString(m) } +func (*PushSpaceRequest) ProtoMessage() {} +func (*PushSpaceRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{11} +} +func (m *PushSpaceRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PushSpaceRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PushSpaceRequest.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 *PushSpaceRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_PushSpaceRequest.Merge(m, src) +} +func (m *PushSpaceRequest) XXX_Size() int { + return m.Size() +} +func (m *PushSpaceRequest) XXX_DiscardUnknown() { + xxx_messageInfo_PushSpaceRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_PushSpaceRequest proto.InternalMessageInfo + +func (m *PushSpaceRequest) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *PushSpaceRequest) GetSpaceHeader() *SpaceHeader { + if m != nil { + return m.SpaceHeader + } + return nil +} + +func (m *PushSpaceRequest) GetAclRoot() *aclrecordproto.RawACLRecordWithId { + if m != nil { + return m.AclRoot + } + return nil +} + +// PushSpaceResponse is an empty response +type PushSpaceResponse struct { +} + +func (m *PushSpaceResponse) Reset() { *m = PushSpaceResponse{} } +func (m *PushSpaceResponse) String() string { return proto.CompactTextString(m) } +func (*PushSpaceResponse) ProtoMessage() {} +func (*PushSpaceResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{12} +} +func (m *PushSpaceResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PushSpaceResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PushSpaceResponse.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 *PushSpaceResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_PushSpaceResponse.Merge(m, src) +} +func (m *PushSpaceResponse) XXX_Size() int { + return m.Size() +} +func (m *PushSpaceResponse) XXX_DiscardUnknown() { + xxx_messageInfo_PushSpaceResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_PushSpaceResponse proto.InternalMessageInfo + +// SpaceHeader is a header for a space type SpaceHeader struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` @@ -746,7 +847,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_5855f4ef9cf24cdb, []int{11} + return fileDescriptor_5855f4ef9cf24cdb, []int{13} } func (m *SpaceHeader) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -823,6 +924,8 @@ func init() { proto.RegisterType((*ObjectFullSyncRequest)(nil), "anySpace.ObjectFullSyncRequest") proto.RegisterType((*ObjectFullSyncResponse)(nil), "anySpace.ObjectFullSyncResponse") proto.RegisterType((*ObjectErrorResponse)(nil), "anySpace.ObjectErrorResponse") + proto.RegisterType((*PushSpaceRequest)(nil), "anySpace.PushSpaceRequest") + proto.RegisterType((*PushSpaceResponse)(nil), "anySpace.PushSpaceResponse") proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader") } @@ -831,57 +934,63 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 793 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x8e, 0x1b, 0x45, - 0x10, 0x9e, 0xf1, 0x7a, 0xd7, 0x76, 0xed, 0xae, 0x63, 0x1a, 0x12, 0x06, 0x03, 0x8e, 0x99, 0x03, - 0xb2, 0x40, 0x5a, 0x23, 0x73, 0x01, 0x16, 0x09, 0x91, 0x95, 0x57, 0xb6, 0x22, 0x7e, 0xd4, 0x9b, - 0x80, 0x84, 0xb8, 0x74, 0x66, 0x2a, 0xf6, 0x90, 0x99, 0xe9, 0xa1, 0xbb, 0x4d, 0xf0, 0x13, 0x70, - 0x01, 0x09, 0xf1, 0x06, 0x3c, 0x0b, 0x17, 0x8e, 0x39, 0x72, 0x44, 0xde, 0x17, 0x41, 0x5d, 0xe3, - 0xf1, 0xd8, 0x66, 0x92, 0x1c, 0xf7, 0xe2, 0xe9, 0xaa, 0xfe, 0xbe, 0xea, 0xaf, 0xab, 0xaa, 0xcb, - 0xf0, 0x51, 0x20, 0x93, 0x44, 0xa6, 0xc3, 0xfc, 0xa3, 0x33, 0x11, 0xe0, 0x90, 0x7e, 0xf5, 0x32, - 0x0d, 0x32, 0x25, 0x8d, 0x1c, 0xd2, 0xaf, 0x2e, 0xbd, 0x67, 0xe4, 0x60, 0x4d, 0x91, 0x2e, 0xaf, - 0xac, 0xaf, 0x3b, 0xcc, 0x9e, 0xcc, 0x86, 0x22, 0x88, 0x87, 0x46, 0x21, 0x06, 0x73, 0x91, 0xce, - 0x70, 0x87, 0x59, 0xba, 0x73, 0xaa, 0x3f, 0x85, 0xd3, 0x09, 0x8a, 0xf0, 0x6a, 0x99, 0x06, 0xdc, - 0xba, 0x19, 0x83, 0xfa, 0x63, 0x25, 0x13, 0xcf, 0xed, 0xbb, 0x83, 0x3a, 0xa7, 0x35, 0x6b, 0x43, - 0xcd, 0x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 0x62, 0x9e, 0xa2, 0x4b, 0x38, 0xba, 0x32, 0x0a, 0x45, 0xc2, 0xde, 0xac, 0x1a, 0x6b, 0xeb, 0xf1, - 0xd8, 0x7d, 0xd1, 0xe6, 0xc0, 0xfd, 0xc0, 0xbd, 0x77, 0xfe, 0xf7, 0xaa, 0xe7, 0x3e, 0x5b, 0xf5, - 0xdc, 0x7f, 0x57, 0x3d, 0xf7, 0xf7, 0xeb, 0x9e, 0xf3, 0xec, 0xba, 0xe7, 0xfc, 0x73, 0xdd, 0x73, - 0xbe, 0x7b, 0xe7, 0xa5, 0xff, 0xc5, 0x8f, 0x8e, 0xe8, 0xf3, 0xe1, 0x7f, 0x01, 0x00, 0x00, 0xff, - 0xff, 0x33, 0xca, 0x5b, 0xe5, 0xb7, 0x07, 0x00, 0x00, + // 887 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xf7, 0x3a, 0x4e, 0x6c, 0x3f, 0x27, 0xa9, 0x3b, 0x25, 0x65, 0x71, 0xa9, 0x6b, 0xf6, 0x80, + 0x22, 0x10, 0x31, 0x32, 0x87, 0x02, 0x41, 0x42, 0x6d, 0x48, 0x64, 0xab, 0xfc, 0xa9, 0x26, 0x2d, + 0x48, 0x88, 0xcb, 0x74, 0xf7, 0x35, 0x5e, 0xba, 0xde, 0x59, 0x66, 0xc7, 0x04, 0x7f, 0x02, 0x2e, + 0x20, 0xf1, 0x09, 0x90, 0xf8, 0x2c, 0x5c, 0x38, 0xf6, 0xd8, 0x23, 0x4a, 0xbe, 0x08, 0x9a, 0x37, + 0xbb, 0xde, 0xb5, 0xd9, 0x36, 0xc7, 0x5e, 0xbc, 0xf3, 0xde, 0xfb, 0xbd, 0x37, 0xbf, 0xf7, 0x67, + 0x66, 0x0c, 0x1f, 0xfb, 0x72, 0x36, 0x93, 0xf1, 0xd0,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x65, 0xdc, 0x77, 0x3e, 0x74, 0xee, 0x1f, 0xfe, 0x73, 0xd1, 0x77, 0x9e, 0x5f, 0xf4, 0x9d, 0x7f, + 0x2f, 0xfa, 0xce, 0x1f, 0x97, 0xfd, 0xda, 0xf3, 0xcb, 0x7e, 0xed, 0xc5, 0x65, 0xbf, 0xf6, 0xfd, + 0x3b, 0x57, 0xfe, 0x6d, 0x79, 0xb2, 0x45, 0x9f, 0x8f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x7d, + 0x4c, 0x93, 0xdc, 0xe2, 0x08, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -1468,6 +1577,83 @@ func (m *ObjectErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *PushSpaceRequest) 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 *PushSpaceRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PushSpaceRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.AclRoot != nil { + { + size, err := m.AclRoot.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x1a + } + if m.SpaceHeader != nil { + { + size, err := m.SpaceHeader.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintSpacesync(dAtA, i, uint64(size)) + } + i-- + 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 +} + +func (m *PushSpaceResponse) 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 *PushSpaceResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PushSpaceResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + func (m *SpaceHeader) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1807,6 +1993,36 @@ func (m *ObjectErrorResponse) Size() (n int) { return n } +func (m *PushSpaceRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.SpaceHeader != nil { + l = m.SpaceHeader.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.AclRoot != nil { + l = m.AclRoot.Size() + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + +func (m *PushSpaceResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + func (m *SpaceHeader) Size() (n int) { if m == nil { return 0 @@ -3332,6 +3548,210 @@ func (m *ObjectErrorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *PushSpaceRequest) 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: PushSpaceRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PushSpaceRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + 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: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceHeader", 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.SpaceHeader == nil { + m.SpaceHeader = &SpaceHeader{} + } + if err := m.SpaceHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclRoot", 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.AclRoot == nil { + m.AclRoot = &aclrecordproto.RawACLRecordWithId{} + } + if err := m.AclRoot.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 *PushSpaceResponse) 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: PushSpaceResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PushSpaceResponse: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + 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 *SpaceHeader) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/spacesyncproto/spacesync_drpc.pb.go b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go index 9f984b1e..d17223ae 100644 --- a/common/commonspace/spacesyncproto/spacesync_drpc.pb.go +++ b/common/commonspace/spacesyncproto/spacesync_drpc.pb.go @@ -41,6 +41,7 @@ type DRPCSpaceClient interface { DRPCConn() drpc.Conn HeadSync(ctx context.Context, in *HeadSyncRequest) (*HeadSyncResponse, error) + PushSpace(ctx context.Context, in *PushSpaceRequest) (*PushSpaceResponse, error) Stream(ctx context.Context) (DRPCSpace_StreamClient, error) } @@ -63,6 +64,15 @@ func (c *drpcSpaceClient) HeadSync(ctx context.Context, in *HeadSyncRequest) (*H return out, nil } +func (c *drpcSpaceClient) PushSpace(ctx context.Context, in *PushSpaceRequest) (*PushSpaceResponse, error) { + out := new(PushSpaceResponse) + err := c.cc.Invoke(ctx, "/anySpace.Space/PushSpace", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, in, out) + if err != nil { + return nil, err + } + return out, nil +} + func (c *drpcSpaceClient) Stream(ctx context.Context) (DRPCSpace_StreamClient, error) { stream, err := c.cc.NewStream(ctx, "/anySpace.Space/Stream", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}) if err != nil { @@ -100,6 +110,7 @@ func (x *drpcSpace_StreamClient) RecvMsg(m *ObjectSyncMessage) error { type DRPCSpaceServer interface { HeadSync(context.Context, *HeadSyncRequest) (*HeadSyncResponse, error) + PushSpace(context.Context, *PushSpaceRequest) (*PushSpaceResponse, error) Stream(DRPCSpace_StreamStream) error } @@ -109,13 +120,17 @@ func (s *DRPCSpaceUnimplementedServer) HeadSync(context.Context, *HeadSyncReques return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } +func (s *DRPCSpaceUnimplementedServer) PushSpace(context.Context, *PushSpaceRequest) (*PushSpaceResponse, error) { + return nil, drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) +} + func (s *DRPCSpaceUnimplementedServer) Stream(DRPCSpace_StreamStream) error { return drpcerr.WithCode(errors.New("Unimplemented"), drpcerr.Unimplemented) } type DRPCSpaceDescription struct{} -func (DRPCSpaceDescription) NumMethods() int { return 2 } +func (DRPCSpaceDescription) NumMethods() int { return 3 } func (DRPCSpaceDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, interface{}, bool) { switch n { @@ -129,6 +144,15 @@ func (DRPCSpaceDescription) Method(n int) (string, drpc.Encoding, drpc.Receiver, ) }, DRPCSpaceServer.HeadSync, true case 1: + return "/anySpace.Space/PushSpace", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, + func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { + return srv.(DRPCSpaceServer). + PushSpace( + ctx, + in1.(*PushSpaceRequest), + ) + }, DRPCSpaceServer.PushSpace, true + case 2: return "/anySpace.Space/Stream", drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}, func(srv interface{}, ctx context.Context, in1, in2 interface{}) (drpc.Message, error) { return nil, srv.(DRPCSpaceServer). @@ -161,6 +185,22 @@ func (x *drpcSpace_HeadSyncStream) SendAndClose(m *HeadSyncResponse) error { return x.CloseSend() } +type DRPCSpace_PushSpaceStream interface { + drpc.Stream + SendAndClose(*PushSpaceResponse) error +} + +type drpcSpace_PushSpaceStream struct { + drpc.Stream +} + +func (x *drpcSpace_PushSpaceStream) SendAndClose(m *PushSpaceResponse) error { + if err := x.MsgSend(m, drpcEncoding_File_common_commonspace_spacesyncproto_protos_spacesync_proto{}); err != nil { + return err + } + return x.CloseSend() +} + type DRPCSpace_StreamStream interface { drpc.Stream Send(*ObjectSyncMessage) error diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index fb67e1df..d2869680 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -1,12 +1,27 @@ package storage import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" ) const CName = "commonspace.storage" -type Storage interface { +type SpaceStorage interface { storage.Provider StoredIds() ([]string, error) } + +type SpaceStorageCreatePayload struct { + RecWithId *aclrecordproto.RawACLRecordWithId + SpaceHeader *spacesyncproto.SpaceHeader + Id string +} + +type SpaceStorageProvider interface { + app.Component + SpaceStorage(id string) (SpaceStorage, error) + CreateSpaceStorage(payload SpaceStorageCreatePayload) (SpaceStorage, error) +} diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index ecf43dfe..4ba8c08b 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -101,7 +101,8 @@ func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) { if err != nil { continue } - + // sending empty message for the server to understand from which space is it coming + stream.Send(&spacesyncproto.ObjectSyncMessage{SpaceId: s.spaceId}) s.streamPool.AddAndReadStreamAsync(stream) } } diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 68ea48f4..a339b6fb 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -22,6 +22,30 @@ type SyncTree struct { listener UpdateListener } +func DeriveSyncTree( + ctx context.Context, + payload tree.ObjectTreeCreatePayload, + syncService syncservice.SyncService, + listener UpdateListener, + aclList list.ACLList, + createStorage storage.TreeStorageCreatorFunc) (t tree.ObjectTree, err error) { + t, err = tree.CreateDerivedObjectTree(payload, aclList, createStorage) + if err != nil { + return + } + t = &SyncTree{ + ObjectTree: t, + syncService: syncService, + listener: listener, + } + + err = syncService.NotifyHeadUpdate(ctx, t.ID(), t.Header(), &spacesyncproto.ObjectHeadUpdate{ + Heads: t.Heads(), + SnapshotPath: t.SnapshotPath(), + }) + return +} + func CreateSyncTree( ctx context.Context, payload tree.ObjectTreeCreatePayload, diff --git a/node/nodespace/rpchandler.go b/node/nodespace/rpchandler.go index 082e7b90..1c4e49d7 100644 --- a/node/nodespace/rpchandler.go +++ b/node/nodespace/rpchandler.go @@ -9,6 +9,10 @@ type rpcHandler struct { s *service } +func (r *rpcHandler) PushSpace(ctx context.Context, request *spacesyncproto.PushSpaceRequest) (*spacesyncproto.PushSpaceResponse, error) { + return nil, nil +} + func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { sp, err := r.s.GetSpace(ctx, req.SpaceId) if err != nil { diff --git a/node/nodespace/service.go b/node/nodespace/service.go index 9602a18b..9b3990c8 100644 --- a/node/nodespace/service.go +++ b/node/nodespace/service.go @@ -9,7 +9,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace/nodecache" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "time" ) @@ -38,11 +37,7 @@ func (s *service) Init(a *app.App) (err error) { s.commonSpace = a.MustComponent(commonspace.CName).(commonspace.Service) s.spaceCache = ocache.New( func(ctx context.Context, id string) (value ocache.Object, err error) { - deps := commonspace.SpaceDeps{ - Cache: nodecache.NewNodeCache(s.conf.GCTTL), - Storage: storage.NewInMemoryTreeStorageProvider(), - } - return s.commonSpace.CreateSpace(ctx, id, deps) + return s.commonSpace.GetSpace(ctx, id, nodecache.NewNodeCache(s.conf.GCTTL)) }, ocache.WithLogger(log.Sugar()), ocache.WithGCPeriod(time.Minute), diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 1a2e207b..885dff34 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -32,6 +32,7 @@ type InitialContent struct { SpaceId string Seed []byte ChangeType string + Timestamp int64 } type ChangeBuilder interface { @@ -100,7 +101,7 @@ func (c *changeBuilder) SetRootRawChange(rawIdChange *treechangeproto.RawTreeCha func (c *changeBuilder) BuildInitialContent(payload InitialContent) (ch *Change, rawIdChange *treechangeproto.RawTreeChangeWithId, err error) { change := &treechangeproto.RootChange{ AclHeadId: payload.AclHeadId, - Timestamp: int64(time.Now().Nanosecond()), + Timestamp: payload.Timestamp, Identity: payload.Identity, ChangeType: payload.ChangeType, SpaceId: payload.SpaceId, diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index 3a65fde8..61631412 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -8,12 +8,13 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" "go.uber.org/zap" + "math/rand" + "time" ) type ObjectTreeCreatePayload struct { SignKey signingkey.PrivKey ChangeType string - Seed []byte SpaceId string Identity []byte } @@ -27,10 +28,31 @@ func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (Obj return buildObjectTree(deps) } +func CreateDerivedObjectTree( + payload ObjectTreeCreatePayload, + aclList list.ACLList, + createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + return createObjectTree(payload, 0, nil, aclList, createStorage) +} + func CreateObjectTree( payload ObjectTreeCreatePayload, aclList list.ACLList, createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { + bytes := make([]byte, 32) + _, err = rand.Read(bytes) + if err != nil { + return + } + return createObjectTree(payload, time.Now().UnixNano(), bytes, aclList, createStorage) +} + +func createObjectTree( + payload ObjectTreeCreatePayload, + timestamp int64, + seed []byte, + aclList list.ACLList, + createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { aclList.RLock() var ( deps = defaultObjectTreeDeps(nil, nil, aclList) @@ -46,8 +68,9 @@ func CreateObjectTree( Identity: payload.Identity, SigningKey: payload.SignKey, SpaceId: payload.SpaceId, - Seed: payload.Seed, ChangeType: payload.ChangeType, + Timestamp: timestamp, + Seed: seed, } _, raw, err := deps.changeBuilder.BuildInitialContent(cnt) From 9be23b4ff7a148a4bceb5e6a6cf2ee5bb1130e12 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 28 Sep 2022 09:18:04 +0200 Subject: [PATCH 42/44] Add push space logic and change storage interface --- common/commonspace/diffservice/diffservice.go | 38 +++++- common/commonspace/space.go | 2 +- common/commonspace/spacesyncproto/errors.go | 13 ++ .../spacesyncproto/protos/spacesync.proto | 2 + .../spacesyncproto/spacesync.pb.go | 127 +++++++++--------- common/commonspace/storage/storage.go | 2 + common/commonspace/syncservice/syncservice.go | 2 + node/nodespace/rpchandler.go | 24 +++- node/nodespace/service.go | 9 +- pkg/acl/storage/inmemory.go | 29 +--- pkg/acl/storage/provider.go | 9 +- 11 files changed, 150 insertions(+), 107 deletions(-) create mode 100644 common/commonspace/spacesyncproto/errors.go diff --git a/common/commonspace/diffservice/diffservice.go b/common/commonspace/diffservice/diffservice.go index 71cf36ce..45ad5e0a 100644 --- a/common/commonspace/diffservice/diffservice.go +++ b/common/commonspace/diffservice/diffservice.go @@ -7,8 +7,8 @@ import ( "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/net/peer" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" - treestorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ldiff" "go.uber.org/zap" "strings" @@ -100,8 +100,12 @@ func (d *diffService) syncWithPeer(ctx context.Context, p peer.Peer) (err error) cl := spacesyncproto.NewDRPCSpaceClient(p) rdiff := remotediff.NewRemoteDiff(d.spaceId, cl) newIds, changedIds, removedIds, err := d.diff.Diff(ctx, rdiff) - if err != nil { - return nil + err = rpcerr.Unwrap(err) + if err != nil && err != spacesyncproto.ErrSpaceMissing { + return err + } + if err == spacesyncproto.ErrSpaceMissing { + return d.sendPushSpaceRequest(ctx, cl) } d.pingTreesInCache(ctx, newIds) @@ -122,11 +126,11 @@ func (d *diffService) pingTreesInCache(ctx context.Context, trees []string) { func (d *diffService) fillDiff(objectIds []string) { var els = make([]ldiff.Element, 0, len(objectIds)) for _, id := range objectIds { - st, err := d.storage.Storage(id) + st, err := d.storage.TreeStorage(id) if err != nil { continue } - heads, err := st.(treestorage.TreeStorage).Heads() + heads, err := st.Heads() if err != nil { continue } @@ -138,6 +142,30 @@ func (d *diffService) fillDiff(objectIds []string) { d.diff.Set(els...) } +func (d *diffService) sendPushSpaceRequest(ctx context.Context, cl spacesyncproto.DRPCSpaceClient) (err error) { + aclStorage, err := d.storage.ACLStorage() + if err != nil { + return + } + + root, err := aclStorage.Root() + if err != nil { + return + } + + header, err := d.storage.SpaceHeader() + if err != nil { + return + } + + _, err = cl.PushSpace(ctx, &spacesyncproto.PushSpaceRequest{ + SpaceId: d.spaceId, + SpaceHeader: header, + AclRoot: root, + }) + return +} + func concatStrings(strs []string) string { var ( b strings.Builder diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 31c2fdfa..50f0dfc9 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -114,7 +114,7 @@ func (s *space) BuildTree(ctx context.Context, id string, listener synctree.Upda ) } - store, err := s.storage.Storage(id) + store, err := s.storage.TreeStorage(id) if err != nil && err != treestorage.ErrUnknownTreeId { return } diff --git a/common/commonspace/spacesyncproto/errors.go b/common/commonspace/spacesyncproto/errors.go new file mode 100644 index 00000000..2011bf9c --- /dev/null +++ b/common/commonspace/spacesyncproto/errors.go @@ -0,0 +1,13 @@ +package spacesyncproto + +import ( + "errors" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr" +) + +var ( + errGroup = rpcerr.ErrGroup(ErrCodes_ErrorOffset) + + ErrUnexpected = errGroup.Register(errors.New("Unexpected error"), uint64(ErrCodes_Unexpected)) + ErrSpaceMissing = errGroup.Register(errors.New("Space is missing"), uint64(ErrCodes_SpaceMissing)) +) diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 8131db4f..4d834c17 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -7,6 +7,8 @@ import "pkg/acl/aclrecordproto/protos/aclrecord.proto"; enum ErrCodes { Unexpected = 0; + SpaceMissing = 1; + ErrorOffset = 16; } service Space { diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 8cffa076..f629510d 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -27,15 +27,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ErrCodes int32 const ( - ErrCodes_Unexpected ErrCodes = 0 + ErrCodes_Unexpected ErrCodes = 0 + ErrCodes_SpaceMissing ErrCodes = 1 + ErrCodes_ErrorOffset ErrCodes = 16 ) var ErrCodes_name = map[int32]string{ - 0: "Unexpected", + 0: "Unexpected", + 1: "SpaceMissing", + 16: "ErrorOffset", } var ErrCodes_value = map[string]int32{ - "Unexpected": 0, + "Unexpected": 0, + "SpaceMissing": 1, + "ErrorOffset": 16, } func (x ErrCodes) String() string { @@ -934,63 +940,64 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 887 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0x4f, 0x6f, 0x1b, 0x45, - 0x14, 0xf7, 0x3a, 0x4e, 0x6c, 0x3f, 0x27, 0xa9, 0x3b, 0x25, 0x65, 0x71, 0xa9, 0x6b, 0xf6, 0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, 0xc3, 0xad, 0xe0, 0x9d, 0xc3, 0xee, 0x32, 0x14, 0xa6, 0xf3, 0x48, - 0x9b, 0x58, 0x53, 0x91, 0x4e, 0x29, 0xd6, 0x36, 0xa7, 0x35, 0x3b, 0x84, 0x16, 0x46, 0x38, 0xc3, - 0x58, 0xa7, 0x6e, 0x7d, 0xb0, 0xb1, 0xdf, 0x19, 0xdd, 0x39, 0xc8, 0xb3, 0x3d, 0x58, 0xf5, 0x3f, - 0xb6, 0x38, 0xbe, 0x74, 0x30, 0x1b, 0xfb, 0x72, 0x1e, 0x2f, 0x37, 0x26, 0xc1, 0x3b, 0x84, 0xbd, - 0x4a, 0x47, 0xc3, 0x3b, 0x0c, 0x68, 0xf7, 0x36, 0xaf, 0x87, 0x01, 0xf1, 0x41, 0x11, 0x50, 0x26, - 0x6d, 0x4e, 0x6b, 0xef, 0x07, 0xb8, 0x56, 0x38, 0xff, 0x34, 0xc7, 0x54, 0x33, 0x17, 0x9a, 0xd4, - 0x90, 0x49, 0xee, 0x9b, 0x8b, 0x6c, 0x08, 0x5b, 0xca, 0x54, 0x29, 0xa7, 0xfe, 0x66, 0x05, 0x75, - 0x63, 0xe7, 0x19, 0xcc, 0x3b, 0x81, 0x6e, 0x89, 0x5a, 0x22, 0xe3, 0x14, 0xd9, 0x08, 0x9a, 0x8a, - 0x68, 0xa6, 0xae, 0x43, 0x51, 0xdc, 0x97, 0x15, 0x80, 0xe7, 0x40, 0xef, 0xc2, 0x81, 0xeb, 0xdf, - 0x3c, 0xf9, 0x11, 0x7d, 0x6d, 0xac, 0x5f, 0x61, 0x9a, 0x8a, 0x33, 0x7c, 0x05, 0xd1, 0x4f, 0xa1, - 0xe9, 0xcb, 0x58, 0x63, 0xac, 0x29, 0xd9, 0xce, 0x68, 0x50, 0xec, 0x51, 0xc4, 0x39, 0xb2, 0x90, - 0x6f, 0x45, 0x34, 0x47, 0x9e, 0x3b, 0xb0, 0xcf, 0x01, 0x94, 0x94, 0xfa, 0x88, 0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a5, 0x8e, 0x64, 0x80, 0x29, 0xdb, 0x05, 0x78, - 0x1c, 0xe3, 0x2f, 0x09, 0xfa, 0x1a, 0x83, 0x6e, 0x6d, 0xf4, 0xc2, 0x81, 0x4d, 0xe2, 0xcf, 0xee, - 0x41, 0x2b, 0xbf, 0x9b, 0xd9, 0x5b, 0x55, 0xf7, 0x35, 0x75, 0xa4, 0xd7, 0xab, 0xbc, 0xca, 0x6d, - 0x63, 0xbf, 0x80, 0xf6, 0xb2, 0x42, 0xac, 0x04, 0x5c, 0x6f, 0x6b, 0xef, 0x56, 0xa5, 0x2d, 0x8b, - 0x72, 0x02, 0x5b, 0xa7, 0x5a, 0xa1, 0x98, 0xb1, 0x5b, 0x55, 0x57, 0x7a, 0xf6, 0x34, 0xf4, 0x5e, - 0x65, 0xdc, 0x77, 0x3e, 0x74, 0xee, 0x1f, 0xfe, 0x73, 0xd1, 0x77, 0x9e, 0x5f, 0xf4, 0x9d, 0x7f, - 0x2f, 0xfa, 0xce, 0x1f, 0x97, 0xfd, 0xda, 0xf3, 0xcb, 0x7e, 0xed, 0xc5, 0x65, 0xbf, 0xf6, 0xfd, - 0x3b, 0x57, 0xfe, 0x6d, 0x79, 0xb2, 0x45, 0x9f, 0x8f, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0x7d, - 0x4c, 0x93, 0xdc, 0xe2, 0x08, 0x00, 0x00, + // 911 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x8e, 0x1b, 0x45, + 0x10, 0xf6, 0x78, 0x7f, 0x6c, 0x97, 0xf7, 0xc7, 0xe9, 0xb0, 0x61, 0x70, 0x88, 0x63, 0xe6, 0x80, + 0x56, 0x20, 0xd6, 0xc8, 0x1c, 0x02, 0x2c, 0x08, 0x25, 0xcb, 0xae, 0x6c, 0x85, 0x90, 0xa8, 0x37, + 0x01, 0x09, 0x71, 0xe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b, 0xb6, 0x88, 0xfe, 0x83, 0x50, + 0xeb, 0x30, 0x1e, 0xb5, 0x1c, 0xb6, 0x0b, 0x4d, 0x92, 0xeb, 0xe1, 0xd9, 0x99, 0x46, 0xd3, 0x6a, + 0xf5, 0x5f, 0x38, 0xb0, 0x41, 0x18, 0x76, 0x17, 0xea, 0xf9, 0xf5, 0xcd, 0xde, 0x59, 0x75, 0xa5, + 0x93, 0x68, 0xed, 0xf6, 0xca, 0xdb, 0x3e, 0xd5, 0xfe, 0x6b, 0x68, 0xcc, 0x8b, 0xc8, 0x4a, 0xc0, + 0x65, 0xe5, 0xdb, 0x37, 0x57, 0xce, 0x65, 0x59, 0x4e, 0x60, 0xf3, 0xd4, 0x28, 0x14, 0x13, 0x76, + 0x73, 0xd5, 0xad, 0x9f, 0xbd, 0x1e, 0xed, 0xd7, 0x4d, 0xee, 0x3b, 0x1f, 0x3b, 0xf7, 0x0e, 0xff, + 0xbd, 0xe8, 0x38, 0xcf, 0x2f, 0x3a, 0xce, 0x7f, 0x17, 0x1d, 0xe7, 0xcf, 0xcb, 0x4e, 0xe5, 0xf9, + 0x65, 0xa7, 0xf2, 0xe2, 0xb2, 0x53, 0xf9, 0xe1, 0xbd, 0x2b, 0xff, 0xd9, 0x3c, 0xdd, 0xa4, 0xcf, + 0x27, 0xff, 0x07, 0x00, 0x00, 0xff, 0xff, 0xd8, 0x19, 0x98, 0xcc, 0x05, 0x09, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index d2869680..818d9ba8 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -11,6 +11,8 @@ const CName = "commonspace.storage" type SpaceStorage interface { storage.Provider + ACLStorage() (storage.ListStorage, error) + SpaceHeader() (*spacesyncproto.SpaceHeader, error) StoredIds() ([]string, error) } diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 4ba8c08b..dc9b5caf 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -99,6 +99,8 @@ func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) { cl := spacesyncproto.NewDRPCSpaceClient(peer) stream, err := cl.Stream(ctx) if err != nil { + // so here probably the request is failed because there is no such space, + // but diffService should handle such cases by sending pushSpace continue } // sending empty message for the server to understand from which space is it coming diff --git a/node/nodespace/rpchandler.go b/node/nodespace/rpchandler.go index 1c4e49d7..486de544 100644 --- a/node/nodespace/rpchandler.go +++ b/node/nodespace/rpchandler.go @@ -3,20 +3,36 @@ package nodespace import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" ) type rpcHandler struct { s *service } -func (r *rpcHandler) PushSpace(ctx context.Context, request *spacesyncproto.PushSpaceRequest) (*spacesyncproto.PushSpaceResponse, error) { - return nil, nil +func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpaceRequest) (resp *spacesyncproto.PushSpaceResponse, err error) { + _, err = r.s.GetSpace(ctx, req.SpaceId) + if err == nil { + resp = &spacesyncproto.PushSpaceResponse{} + return + } + payload := storage.SpaceStorageCreatePayload{ + RecWithId: req.AclRoot, + SpaceHeader: req.SpaceHeader, + Id: req.SpaceId, + } + _, err = r.s.spaceStorageProvider.CreateSpaceStorage(payload) + if err != nil { + err = spacesyncproto.ErrUnexpected + return + } + return } func (r *rpcHandler) HeadSync(ctx context.Context, req *spacesyncproto.HeadSyncRequest) (*spacesyncproto.HeadSyncResponse, error) { sp, err := r.s.GetSpace(ctx, req.SpaceId) if err != nil { - return nil, err + return nil, spacesyncproto.ErrSpaceMissing } return sp.SpaceSyncRpc().HeadSync(ctx, req) } @@ -28,7 +44,7 @@ func (r *rpcHandler) Stream(stream spacesyncproto.DRPCSpace_StreamStream) error } sp, err := r.s.GetSpace(stream.Context(), msg.SpaceId) if err != nil { - return err + return spacesyncproto.ErrSpaceMissing } return sp.SpaceSyncRpc().Stream(stream) } diff --git a/node/nodespace/service.go b/node/nodespace/service.go index 9b3990c8..33093179 100644 --- a/node/nodespace/service.go +++ b/node/nodespace/service.go @@ -6,6 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace" "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/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace/nodecache" @@ -27,14 +28,16 @@ type Service interface { } type service struct { - conf config.Space - spaceCache ocache.OCache - commonSpace commonspace.Service + conf config.Space + spaceCache ocache.OCache + commonSpace commonspace.Service + spaceStorageProvider storage.SpaceStorageProvider } func (s *service) Init(a *app.App) (err error) { s.conf = a.MustComponent(config.CName).(*config.Config).Space s.commonSpace = a.MustComponent(commonspace.CName).(commonspace.Service) + s.spaceStorageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider) s.spaceCache = ocache.New( func(ctx context.Context, id string) (value ocache.Object, err error) { return s.commonSpace.GetSpace(ctx, id, nodecache.NewNodeCache(s.conf.GCTTL)) diff --git a/pkg/acl/storage/inmemory.go b/pkg/acl/storage/inmemory.go index 1e200e68..6ddbea57 100644 --- a/pkg/acl/storage/inmemory.go +++ b/pkg/acl/storage/inmemory.go @@ -134,22 +134,11 @@ func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) } type inMemoryStorageProvider struct { - objects map[string]Storage + objects map[string]TreeStorage sync.RWMutex } -func (i *inMemoryStorageProvider) AddStorage(id string, st Storage) error { - i.Lock() - defer i.Unlock() - if _, exists := i.objects[id]; exists { - return fmt.Errorf("storage already exists") - } - - i.objects[id] = st - return nil -} - -func (i *inMemoryStorageProvider) Storage(id string) (Storage, error) { +func (i *inMemoryStorageProvider) TreeStorage(id string) (TreeStorage, error) { i.RLock() defer i.RUnlock() if tree, exists := i.objects[id]; exists { @@ -170,20 +159,8 @@ func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePay return res, nil } -func (i *inMemoryStorageProvider) CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) { - i.Lock() - defer i.Unlock() - res, err := NewInMemoryACLListStorage(payload.ListId, payload.Records) - if err != nil { - return nil, err - } - - i.objects[payload.ListId] = res - return res, nil -} - func NewInMemoryTreeStorageProvider() Provider { return &inMemoryStorageProvider{ - objects: make(map[string]Storage), + objects: make(map[string]TreeStorage), } } diff --git a/pkg/acl/storage/provider.go b/pkg/acl/storage/provider.go index 3c2c7d91..4e738b28 100644 --- a/pkg/acl/storage/provider.go +++ b/pkg/acl/storage/provider.go @@ -2,7 +2,6 @@ package storage import ( "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) @@ -15,13 +14,7 @@ type TreeStorageCreatePayload struct { Heads []string } -type ACLListStorageCreatePayload struct { - ListId string - Records []*aclrecordproto.RawACLRecordWithId -} - type Provider interface { - Storage(id string) (Storage, error) + TreeStorage(id string) (TreeStorage, error) CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) - CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) } From 533880e9f131c82852b076c9b9526dac6643c240 Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 28 Sep 2022 19:55:47 +0200 Subject: [PATCH 43/44] Add better error handling --- common/commonspace/cache/treecache.go | 3 + common/commonspace/space.go | 2 - common/commonspace/spacesyncproto/errors.go | 5 +- .../spacesyncproto/protos/spacesync.proto | 3 +- .../spacesyncproto/spacesync.pb.go | 128 +++++++++--------- common/commonspace/storage/storage.go | 3 + common/commonspace/syncservice/syncservice.go | 11 +- node/nodespace/rpchandler.go | 11 +- 8 files changed, 97 insertions(+), 69 deletions(-) diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 1a6305b7..24be3590 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -2,12 +2,15 @@ package cache import ( "context" + "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) const CName = "commonspace.cache" +var ErrSpaceNotFound = errors.New("space not found") + type TreeContainer interface { Tree() tree.ObjectTree } diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 50f0dfc9..2df67d1b 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -40,8 +40,6 @@ type Space interface { Id() string SpaceSyncRpc() RpcHandler - SyncService() syncservice.SyncService - DiffService() diffservice.DiffService DeriveTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) CreateTree(ctx context.Context, payload tree.ObjectTreeCreatePayload, listener synctree.UpdateListener) (tree.ObjectTree, error) diff --git a/common/commonspace/spacesyncproto/errors.go b/common/commonspace/spacesyncproto/errors.go index 2011bf9c..9b7b3559 100644 --- a/common/commonspace/spacesyncproto/errors.go +++ b/common/commonspace/spacesyncproto/errors.go @@ -8,6 +8,7 @@ import ( var ( errGroup = rpcerr.ErrGroup(ErrCodes_ErrorOffset) - ErrUnexpected = errGroup.Register(errors.New("Unexpected error"), uint64(ErrCodes_Unexpected)) - ErrSpaceMissing = errGroup.Register(errors.New("Space is missing"), uint64(ErrCodes_SpaceMissing)) + ErrUnexpected = errGroup.Register(errors.New("unexpected error"), uint64(ErrCodes_Unexpected)) + ErrSpaceMissing = errGroup.Register(errors.New("space is missing"), uint64(ErrCodes_SpaceMissing)) + ErrSpaceExists = errGroup.Register(errors.New("space exists"), uint64(ErrCodes_SpaceMissing)) ) diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 4d834c17..2b45d366 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -8,7 +8,8 @@ import "pkg/acl/aclrecordproto/protos/aclrecord.proto"; enum ErrCodes { Unexpected = 0; SpaceMissing = 1; - ErrorOffset = 16; + SpaceExists = 2; + ErrorOffset = 100; } service Space { diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index f629510d..0c89fb20 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -29,19 +29,22 @@ type ErrCodes int32 const ( ErrCodes_Unexpected ErrCodes = 0 ErrCodes_SpaceMissing ErrCodes = 1 - ErrCodes_ErrorOffset ErrCodes = 16 + ErrCodes_SpaceExists ErrCodes = 2 + ErrCodes_ErrorOffset ErrCodes = 100 ) var ErrCodes_name = map[int32]string{ - 0: "Unexpected", - 1: "SpaceMissing", - 16: "ErrorOffset", + 0: "Unexpected", + 1: "SpaceMissing", + 2: "SpaceExists", + 100: "ErrorOffset", } var ErrCodes_value = map[string]int32{ "Unexpected": 0, "SpaceMissing": 1, - "ErrorOffset": 16, + "SpaceExists": 2, + "ErrorOffset": 100, } func (x ErrCodes) String() string { @@ -940,64 +943,65 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 911 bytes of a gzipped FileDescriptorProto + // 919 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x56, 0xcd, 0x8e, 0x1b, 0x45, - 0x10, 0xf6, 0x78, 0x7f, 0x6c, 0x97, 0xf7, 0xc7, 0xe9, 0xb0, 0x61, 0x70, 0x88, 0x63, 0xe6, 0x80, - 0x56, 0x20, 0xd6, 0xc8, 0x1c, 0x02, 0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 0x36, 0xd1, 0x7f, 0xe0, 0x2b, + 0xe5, 0x87, 0x93, 0xb6, 0xc5, 0xf6, 0xd2, 0x84, 0x86, 0x2f, 0x7c, 0xa5, 0x55, 0xbb, 0x6a, 0x14, + 0xd4, 0xbf, 0x47, 0x67, 0x67, 0x0a, 0x75, 0xdb, 0x1b, 0xbc, 0xb2, 0x60, 0x93, 0x20, 0xec, 0x2e, + 0x34, 0xb2, 0xfb, 0x9c, 0xbd, 0x57, 0x76, 0xc7, 0x53, 0x17, 0x3b, 0x9d, 0xd2, 0xeb, 0x3f, 0x19, + 0x86, 0x6f, 0xa0, 0xb9, 0xac, 0x2a, 0x2b, 0x00, 0xd7, 0x47, 0xa1, 0x73, 0xb3, 0xd4, 0x96, 0x46, + 0x39, 0x81, 0xad, 0x53, 0x1d, 0xa3, 0x98, 0xb1, 0x9b, 0x65, 0xcf, 0x40, 0xfa, 0x9c, 0x74, 0xde, + 0x64, 0x3c, 0xb0, 0x3e, 0xb5, 0xee, 0x1d, 0xfd, 0x73, 0xd1, 0xb5, 0x5e, 0x5e, 0x74, 0xad, 0x7f, + 0x2f, 0xba, 0xd6, 0x1f, 0x97, 0xdd, 0xca, 0xcb, 0xcb, 0x6e, 0xe5, 0xd5, 0x65, 0xb7, 0xf2, 0xc3, + 0x07, 0x57, 0xfe, 0xd5, 0x79, 0xb6, 0x45, 0x9f, 0xcf, 0xfe, 0x0b, 0x00, 0x00, 0xff, 0xff, 0xce, + 0x99, 0xdc, 0xc5, 0x16, 0x09, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { diff --git a/common/commonspace/storage/storage.go b/common/commonspace/storage/storage.go index 818d9ba8..add06e08 100644 --- a/common/commonspace/storage/storage.go +++ b/common/commonspace/storage/storage.go @@ -1,6 +1,7 @@ package storage import ( + "errors" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" @@ -9,6 +10,8 @@ import ( const CName = "commonspace.storage" +var ErrSpaceStorageExists = errors.New("space storage exists") + type SpaceStorage interface { storage.Provider ACLStorage() (storage.ListStorage, error) diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index dc9b5caf..68b74e69 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -2,13 +2,17 @@ package syncservice import ( "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/rpcerr" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "time" ) +var log = logger.NewNamed("syncservice").Sugar() + type SyncService interface { NotifyHeadUpdate( ctx context.Context, @@ -104,7 +108,12 @@ func (s *syncService) responsibleStreamCheckLoop(ctx context.Context) { continue } // sending empty message for the server to understand from which space is it coming - stream.Send(&spacesyncproto.ObjectSyncMessage{SpaceId: s.spaceId}) + err = stream.Send(&spacesyncproto.ObjectSyncMessage{SpaceId: s.spaceId}) + if err != nil { + err = rpcerr.Unwrap(err) + log.With("spaceId", s.spaceId).Errorf("failed to open stream: %v", err) + continue + } s.streamPool.AddAndReadStreamAsync(stream) } } diff --git a/node/nodespace/rpchandler.go b/node/nodespace/rpchandler.go index 486de544..dd050fde 100644 --- a/node/nodespace/rpchandler.go +++ b/node/nodespace/rpchandler.go @@ -2,6 +2,7 @@ package nodespace import ( "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" ) @@ -13,9 +14,14 @@ type rpcHandler struct { func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpaceRequest) (resp *spacesyncproto.PushSpaceResponse, err error) { _, err = r.s.GetSpace(ctx, req.SpaceId) if err == nil { - resp = &spacesyncproto.PushSpaceResponse{} + err = spacesyncproto.ErrSpaceExists return } + if err != cache.ErrSpaceNotFound { + err = spacesyncproto.ErrUnexpected + return + } + payload := storage.SpaceStorageCreatePayload{ RecWithId: req.AclRoot, SpaceHeader: req.SpaceHeader, @@ -24,6 +30,9 @@ func (r *rpcHandler) PushSpace(ctx context.Context, req *spacesyncproto.PushSpac _, err = r.s.spaceStorageProvider.CreateSpaceStorage(payload) if err != nil { err = spacesyncproto.ErrUnexpected + if err == storage.ErrSpaceStorageExists { + err = spacesyncproto.ErrSpaceExists + } return } return From 131f4a69682ce3b5d665d87a0f7d35beb61e45ca Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Wed, 28 Sep 2022 20:56:11 +0200 Subject: [PATCH 44/44] Change cache logic --- common/commonspace/cache/treecache.go | 7 +-- common/commonspace/diffservice/diffservice.go | 2 +- common/commonspace/service.go | 16 ++--- common/commonspace/space.go | 3 - common/commonspace/syncservice/synchandler.go | 10 +-- common/commonspace/syncservice/syncservice.go | 2 +- node/nodespace/nodecache/treecache.go | 61 +++++++++++++------ node/nodespace/service.go | 3 +- 8 files changed, 63 insertions(+), 41 deletions(-) diff --git a/common/commonspace/cache/treecache.go b/common/commonspace/cache/treecache.go index 24be3590..cd47f1c3 100644 --- a/common/commonspace/cache/treecache.go +++ b/common/commonspace/cache/treecache.go @@ -3,6 +3,7 @@ package cache import ( "context" "errors" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/synctree" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" ) @@ -23,8 +24,6 @@ type TreeResult struct { type BuildFunc = func(ctx context.Context, id string, listener synctree.UpdateListener) (tree.ObjectTree, error) type TreeCache interface { - GetTree(ctx context.Context, id string) (TreeResult, error) - SetBuildFunc(f BuildFunc) - - Close() error + app.ComponentRunnable + GetTree(ctx context.Context, spaceId, treeId string) (TreeResult, error) } diff --git a/common/commonspace/diffservice/diffservice.go b/common/commonspace/diffservice/diffservice.go index 45ad5e0a..ff376d31 100644 --- a/common/commonspace/diffservice/diffservice.go +++ b/common/commonspace/diffservice/diffservice.go @@ -119,7 +119,7 @@ func (d *diffService) syncWithPeer(ctx context.Context, p peer.Peer) (err error) func (d *diffService) pingTreesInCache(ctx context.Context, trees []string) { for _, tId := range trees { - _, _ = d.cache.GetTree(ctx, tId) + _, _ = d.cache.GetTree(ctx, d.spaceId, tId) } } diff --git a/common/commonspace/service.go b/common/commonspace/service.go index f5b10591..48f4b4cf 100644 --- a/common/commonspace/service.go +++ b/common/commonspace/service.go @@ -30,7 +30,7 @@ func New() Service { type Service interface { CreateSpace(ctx context.Context, cache cache.TreeCache, payload SpaceCreatePayload) (Space, error) DeriveSpace(ctx context.Context, cache cache.TreeCache, payload SpaceDerivePayload) (Space, error) - GetSpace(ctx context.Context, id string, cache cache.TreeCache) (sp Space, err error) + GetSpace(ctx context.Context, id string) (sp Space, err error) app.Component } @@ -38,12 +38,14 @@ type service struct { config config.Space configurationService nodeconf.Service storageProvider storage.SpaceStorageProvider + cache cache.TreeCache } func (s *service) Init(a *app.App) (err error) { s.config = a.MustComponent(config.CName).(*config.Config).Space s.storageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider) s.configurationService = a.MustComponent(nodeconf.CName).(nodeconf.Service) + s.cache = a.MustComponent(cache.CName).(cache.TreeCache) return nil } @@ -127,7 +129,7 @@ func (s *service) CreateSpace( return } - return s.GetSpace(ctx, spaceId, cache) + return s.GetSpace(ctx, spaceId) } func (s *service) DeriveSpace( @@ -219,22 +221,22 @@ func (s *service) DeriveSpace( return } - return s.GetSpace(ctx, spaceId, cache) + return s.GetSpace(ctx, spaceId) } -func (s *service) GetSpace(ctx context.Context, id string, cache cache.TreeCache) (Space, error) { +func (s *service) GetSpace(ctx context.Context, id string) (Space, error) { st, err := s.storageProvider.SpaceStorage(id) if err != nil { return nil, err } lastConfiguration := s.configurationService.GetLast() - diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, lastConfiguration, cache, log) - syncService := syncservice.NewSyncService(id, diffService, cache, lastConfiguration) + diffService := diffservice.NewDiffService(id, s.config.SyncPeriod, st, lastConfiguration, s.cache, log) + syncService := syncservice.NewSyncService(id, diffService, s.cache, lastConfiguration) sp := &space{ id: id, syncService: syncService, diffService: diffService, - cache: cache, + cache: s.cache, storage: st, } if err := sp.Init(ctx); err != nil { diff --git a/common/commonspace/space.go b/common/commonspace/space.go index 2df67d1b..83be2504 100644 --- a/common/commonspace/space.go +++ b/common/commonspace/space.go @@ -73,8 +73,6 @@ func (s *space) Init(ctx context.Context) (err error) { } s.diffService.Init(initialIds) s.syncService.Init() - // basically this provides access for the external cache to use space's tree building functions - s.cache.SetBuildFunc(s.BuildTree) return nil } @@ -148,6 +146,5 @@ func (s *space) BuildTree(ctx context.Context, id string, listener synctree.Upda func (s *space) Close() error { s.diffService.Close() - s.cache.Close() return s.syncService.Close() } diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index c8470de5..3a0da9fd 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -10,6 +10,7 @@ import ( ) type syncHandler struct { + spaceId string treeCache cache.TreeCache syncClient SyncClient } @@ -18,8 +19,9 @@ type SyncHandler interface { HandleMessage(ctx context.Context, senderId string, request *spacesyncproto.ObjectSyncMessage) (err error) } -func newSyncHandler(treeCache cache.TreeCache, syncClient SyncClient) *syncHandler { +func newSyncHandler(spaceId string, treeCache cache.TreeCache, syncClient SyncClient) *syncHandler { return &syncHandler{ + spaceId: spaceId, treeCache: treeCache, syncClient: syncClient, } @@ -48,7 +50,7 @@ func (s *syncHandler) HandleHeadUpdate( fullRequest *spacesyncproto.ObjectFullSyncRequest result tree.AddResult ) - res, err := s.treeCache.GetTree(ctx, msg.TreeId) + res, err := s.treeCache.GetTree(ctx, s.spaceId, msg.TreeId) if err != nil { return } @@ -100,7 +102,7 @@ func (s *syncHandler) HandleFullSyncRequest( } }() - res, err := s.treeCache.GetTree(ctx, msg.TreeId) + res, err := s.treeCache.GetTree(ctx, s.spaceId, msg.TreeId) if err != nil { return } @@ -136,7 +138,7 @@ func (s *syncHandler) HandleFullSyncResponse( senderId string, response *spacesyncproto.ObjectFullSyncResponse, msg *spacesyncproto.ObjectSyncMessage) (err error) { - res, err := s.treeCache.GetTree(ctx, msg.TreeId) + res, err := s.treeCache.GetTree(ctx, s.spaceId, msg.TreeId) if err != nil { return } diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index 68b74e69..59aa3621 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -49,7 +49,7 @@ func NewSyncService(spaceId string, headNotifiable HeadNotifiable, cache cache.T streamPool := newStreamPool(func(ctx context.Context, senderId string, message *spacesyncproto.ObjectSyncMessage) (err error) { return syncHandler.HandleMessage(ctx, senderId, message) }) - syncHandler = newSyncHandler(cache, streamPool) + syncHandler = newSyncHandler(spaceId, cache, streamPool) return newSyncService(spaceId, headNotifiable, syncHandler, streamPool, configuration) } diff --git a/node/nodespace/nodecache/treecache.go b/node/nodespace/nodecache/treecache.go index 926bced6..e0238528 100644 --- a/node/nodespace/nodecache/treecache.go +++ b/node/nodespace/nodecache/treecache.go @@ -3,8 +3,10 @@ package nodecache import ( "context" "errors" + "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" + "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "time" ) @@ -12,9 +14,45 @@ import ( var log = logger.NewNamed("treecache") var ErrCacheObjectWithoutTree = errors.New("cache object contains no tree") +type ctxKey int + +const spaceKey ctxKey = 0 + type treeCache struct { - gcttl int - cache ocache.OCache + gcttl int + cache ocache.OCache + nodeService nodespace.Service +} + +func (c *treeCache) Run(ctx context.Context) (err error) { + return nil +} + +func (c *treeCache) Close(ctx context.Context) (err error) { + return c.cache.Close() +} + +func (c *treeCache) Init(a *app.App) (err error) { + c.nodeService = a.MustComponent(nodespace.CName).(nodespace.Service) + c.cache = ocache.New( + func(ctx context.Context, id string) (value ocache.Object, err error) { + spaceId := ctx.Value(spaceKey).(string) + space, err := c.nodeService.GetSpace(ctx, spaceId) + if err != nil { + return + } + return space.BuildTree(ctx, id, nil) + }, + ocache.WithLogger(log.Sugar()), + ocache.WithGCPeriod(time.Minute), + ocache.WithTTL(time.Duration(c.gcttl)*time.Second), + ocache.WithRefCounter(false), + ) + return nil +} + +func (c *treeCache) Name() (name string) { + return cache.CName } func NewNodeCache(ttl int) cache.TreeCache { @@ -23,24 +61,9 @@ func NewNodeCache(ttl int) cache.TreeCache { } } -func (c *treeCache) SetBuildFunc(buildFunc cache.BuildFunc) { - c.cache = ocache.New( - func(ctx context.Context, id string) (value ocache.Object, err error) { - return buildFunc(ctx, id, nil) - }, - ocache.WithLogger(log.Sugar()), - ocache.WithGCPeriod(time.Minute), - ocache.WithTTL(time.Duration(c.gcttl)*time.Second), - ocache.WithRefCounter(false), - ) -} - -func (c *treeCache) Close() (err error) { - return c.cache.Close() -} - -func (c *treeCache) GetTree(ctx context.Context, id string) (res cache.TreeResult, err error) { +func (c *treeCache) GetTree(ctx context.Context, spaceId, id string) (res cache.TreeResult, err error) { var cacheRes ocache.Object + ctx = context.WithValue(ctx, spaceKey, spaceId) cacheRes, err = c.cache.Get(ctx, id) if err != nil { return cache.TreeResult{}, err diff --git a/node/nodespace/service.go b/node/nodespace/service.go index 33093179..0920ef42 100644 --- a/node/nodespace/service.go +++ b/node/nodespace/service.go @@ -9,7 +9,6 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/net/rpc/server" "github.com/anytypeio/go-anytype-infrastructure-experiments/config" - "github.com/anytypeio/go-anytype-infrastructure-experiments/node/nodespace/nodecache" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/ocache" "time" ) @@ -40,7 +39,7 @@ func (s *service) Init(a *app.App) (err error) { s.spaceStorageProvider = a.MustComponent(storage.CName).(storage.SpaceStorageProvider) s.spaceCache = ocache.New( func(ctx context.Context, id string) (value ocache.Object, err error) { - return s.commonSpace.GetSpace(ctx, id, nodecache.NewNodeCache(s.conf.GCTTL)) + return s.commonSpace.GetSpace(ctx, id) }, ocache.WithLogger(log.Sugar()), ocache.WithGCPeriod(time.Minute),