From 357e889dad0f3e7404184211107b8bb55aa57074 Mon Sep 17 00:00:00 2001 From: Sergey Cherepanov Date: Wed, 7 Sep 2022 19:43:01 +0300 Subject: [PATCH 1/7] 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 2/7] 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 3/7] 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, 0x33, 0x11, 0xd7, 0xd8, 0x29, 0x85, 0xf9, 0x65, 0x56, 0xb6, 0x72, - 0xfd, 0x6b, 0x0a, 0xfe, 0xc8, 0xb0, 0x27, 0x40, 0x1b, 0xf9, 0xb1, 0x95, 0xc6, 0x0e, 0x46, 0xe1, - 0x9f, 0x46, 0x5c, 0xf4, 0x84, 0x70, 0x28, 0x7b, 0x0a, 0xcb, 0x46, 0x9a, 0x5a, 0x2b, 0xe3, 0xe2, - 0xdf, 0xfb, 0xab, 0xac, 0x47, 0xc4, 0x08, 0x87, 0x9f, 0x08, 0xd0, 0xc1, 0x8d, 0x3d, 0x83, 0x45, - 0xd3, 0x71, 0x26, 0x20, 0xf1, 0x34, 0x59, 0xa5, 0xf1, 0xf1, 0x3f, 0x73, 0xec, 0xc4, 0xc0, 0x87, - 0x2f, 0x60, 0xde, 0xa7, 0x67, 0x30, 0xdb, 0x36, 0xba, 0xc2, 0xe8, 0x33, 0x81, 0x35, 0xbb, 0x05, - 0x9e, 0xd5, 0x98, 0x6a, 0x26, 0x3c, 0xab, 0xd9, 0x6d, 0x98, 0x97, 0x45, 0x55, 0xd8, 0x60, 0x1a, - 0x93, 0xe4, 0xa6, 0xe8, 0x9b, 0xf0, 0x27, 0x81, 0xa5, 0xcb, 0xc7, 0x9e, 0x77, 0x97, 0x60, 0xda, - 0xd2, 0xba, 0x28, 0xeb, 0x7f, 0x6c, 0xd3, 0x15, 0x6d, 0x89, 0x97, 0x81, 0x92, 0xf0, 0x2b, 0x81, - 0x45, 0x3f, 0xeb, 0xf2, 0x5c, 0x64, 0xe6, 0x02, 0xf3, 0xdc, 0x10, 0x58, 0xb3, 0x33, 0x58, 0xca, - 0x52, 0x56, 0x52, 0x59, 0x13, 0x78, 0xe8, 0x7e, 0xff, 0xff, 0xee, 0xfc, 0x75, 0x2f, 0x11, 0xa3, - 0xb6, 0xdb, 0x63, 0xa3, 0x5b, 0x35, 0xee, 0x81, 0x4d, 0xf8, 0x00, 0xe8, 0x80, 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, 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, 0xcd, 0x5e, 0x83, 0x6f, 0x13, 0xef, 0x09, 0x9a, 0x3b, 0x2b, + 0x54, 0x8b, 0x99, 0xce, 0xbc, 0xa6, 0x81, 0x9a, 0x92, 0xd7, 0x4f, 0x4e, 0x31, 0x1b, 0x82, 0x8d, + 0x33, 0x9c, 0xa3, 0xd0, 0xca, 0xb1, 0xba, 0xa5, 0xde, 0x8f, 0xc1, 0x3f, 0x3f, 0xa7, 0xf1, 0xbf, + 0xeb, 0x47, 0xdb, 0x3e, 0xbe, 0x13, 0x64, 0x83, 0x43, 0xb9, 0x10, 0xbb, 0xc1, 0x94, 0x78, 0x43, + 0xf8, 0x53, 0x28, 0xcc, 0xb8, 0xe3, 0x88, 0xa6, 0xd7, 0xb9, 0x15, 0x47, 0xc4, 0x83, 0x41, 0x44, + 0x2f, 0xa9, 0x73, 0x8a, 0xbd, 0x1b, 0xf8, 0xb5, 0x17, 0x3f, 0x2c, 0x50, 0x69, 0xe6, 0x40, 0x8d, + 0x16, 0x36, 0xce, 0xb5, 0x79, 0xca, 0xfa, 0x50, 0x4d, 0xb3, 0x2d, 0xe5, 0xe8, 0xed, 0x02, 0xf4, + 0xec, 0x3f, 0xff, 0x6c, 0xf3, 0xce, 0xa1, 0xf5, 0x05, 0x2d, 0x91, 0x42, 0x21, 0x1b, 0x40, 0x2d, + 0x25, 0x4c, 0xe5, 0x98, 0xe4, 0xe2, 0x1c, 0x5a, 0x00, 0xcf, 0x1b, 0xff, 0x77, 0xc0, 0x1e, 0xa5, + 0xe9, 0x99, 0x8c, 0x50, 0xb1, 0x26, 0xc0, 0x95, 0xc0, 0xe7, 0x04, 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 4/7] 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 5/7] 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/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml +++ b/etc/configs/12D3KooWT3c7Y5zvWhhjSxd5Ve3GKZi6WCsG6JHxcxgXixRFdBbw.yml @@ -11,6 +11,9 @@ account: encryptionKey: JgG4CcCbae1qEpe7mKXzp7m5hNc56SSyZd9DwUaEStKJrq7RToAC2Vgd3i6hKRwa58zCWeN6Wjc3o6qrdKPEPRvcyEPysamajVo5mdQiUgWAmr97pGEsyjuRjQoC2GY2LvLiEQxEgwFgJxKGMHMiaWMtDfxCDUaDEm4bu5RdMhqRZekAWho6c3WoEeruSr14iX1TrocFNfBkBY7CjEw8kcywXCTNgtvhb2Qiwgj5AxEF4wyw4bzaNA9ctXb1hoHPFVMu6C51pkFY7jUD9zwyH3ukgnAewkGAcPNbKmaTAtMosKRVaAN97mAwXh2VRt1hWmRvVk7r76EjnVKhD4vbsKZc56RVcHTVWRVdhU7FGyPsiE5rSQAz1JQGYzxnZpX7EG77CyrmUGyfueVfRHhwY2oq8A4uQCRaQxSaJHYLowjXSxh8DQ2V6MTqyzti32C27utBYdHzLVCJSGkmdzGwrFcHqsq7nLDxmvJVErPvyReixEe8kFmqopJ3e6LLm8WdYw9K6JYBjXnEfwPzm7Von9sf3dcaGDUHYfttMyeke7fAXJkvPRje69hYVyzdQGAauuojzGkkvQWCSMK1KCMNMznRaPDCNvofrQhYrub24WhmwpKhorufdfW8Cb4T6reBDCtaWVsbuinjtL6F6Sui5aYHJFLJ6e4pPewr1P4EuZYRbMBZwN5KvDLhTGLBuBnaTqUUdF6bj2U22NoRYMogiHiftqKqiexKNDXX1Zg9RQEvxgjuVo6SBW42mVEA8agrLhruRqCmiduJxVrfqLNGeYXHXrcmMEgW7uosJbPXvTcfRvdFWS1ov7oSALvj6vhDQ28Yi9D2ETNdNsfVWAFQuwvPpW7CHQGXTitprVbqH8JYxNZuGygcLmr5efbB22Vzu4ntd1HoraQpG12qeDEUA7tXYUpoYyuSdWwKPjSAMtaQcCSfVrhKQHQuKJargrVrez8vjWuwLfvSucV7ZHe7gjqvYgULdE1ubRCRSd7DuLjEN2Vd6obzV2c3MRet7ZSf4Sp88WM5AuTyW7BjArBc4S3gUQ8rYaiZ8Tu7NCxkEzbFwWRaemZkwfvcsX3XxqjyF37tFSGkEqE5kuBvpZW72675LkDffj7kH1zA8yE6dVujJjWsNYVFJWndUtz5Vy2KCdZAbBgq19q4AtsxWPodU2N3yZXzFAFAzTrxS6V4P7Scpdau1avgRvHLcBQPunA37xaYMy8YMifJwtmRY25mnAQwZAk3eANk7tXwZd58SDnciLNvARJvwKzTQBXcshkwyy52SX8XmXDJsPnRLaHmiYBJ63Yzr5XpZuuAtxb9qrWG2NHCNxfomHokWacV1hjZPPd6ZxT1FuRozB6Qt2NLcyqY7bnTcQJb1jPUaTAGXXCR8WVmmmYo2fDQe8CdBmgyPvbzNTEJUyScBz4RdycB5PZap4SurJCWtHbuMyQbQUB6jJgURDstfXS5Akfe4oruNq9rnYcNtnsDJPtrhXHBqzDizmf1BDxR5FB2RCxzCgeAfg8WQ1Ug9PVAGTzob6ZqCrGXzWXEUniZnf1vjr7QhGKBYXEX9SWDoSMUpP4FreVDTnx15ijRZTV3p8xG5fE9e36TnugRVvTyq7XzmyPBjW2r66f1bior 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 6/7] 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 7/7] 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, 0xcd, 0x5e, 0x83, 0x6f, 0x13, 0xef, 0x09, 0x9a, 0x3b, 0x2b, - 0x54, 0x8b, 0x99, 0xce, 0xbc, 0xa6, 0x81, 0x9a, 0x92, 0xd7, 0x4f, 0x4e, 0x31, 0x1b, 0x82, 0x8d, - 0x33, 0x9c, 0xa3, 0xd0, 0xca, 0xb1, 0xba, 0xa5, 0xde, 0x8f, 0xc1, 0x3f, 0x3f, 0xa7, 0xf1, 0xbf, - 0xeb, 0x47, 0xdb, 0x3e, 0xbe, 0x13, 0x64, 0x83, 0x43, 0xb9, 0x10, 0xbb, 0xc1, 0x94, 0x78, 0x43, - 0xf8, 0x53, 0x28, 0xcc, 0xb8, 0xe3, 0x88, 0xa6, 0xd7, 0xb9, 0x15, 0x47, 0xc4, 0x83, 0x41, 0x44, - 0x2f, 0xa9, 0x73, 0x8a, 0xbd, 0x1b, 0xf8, 0xb5, 0x17, 0x3f, 0x2c, 0x50, 0x69, 0xe6, 0x40, 0x8d, - 0x16, 0x36, 0xce, 0xb5, 0x79, 0xca, 0xfa, 0x50, 0x4d, 0xb3, 0x2d, 0xe5, 0xe8, 0xed, 0x02, 0xf4, - 0xec, 0x3f, 0xff, 0x6c, 0xf3, 0xce, 0xa1, 0xf5, 0x05, 0x2d, 0x91, 0x42, 0x21, 0x1b, 0x40, 0x2d, - 0x25, 0x4c, 0xe5, 0x98, 0xe4, 0xe2, 0x1c, 0x5a, 0x00, 0xcf, 0x1b, 0xff, 0x77, 0xc0, 0x1e, 0xa5, - 0xe9, 0x99, 0x8c, 0x50, 0xb1, 0x26, 0xc0, 0x95, 0xc0, 0xe7, 0x04, 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, +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, 0x62, 0xa1, 0x58, 0x73, 0x4a, 0xa1, 0xf9, + 0x2d, 0x97, 0x29, 0xe2, 0x9a, 0x0c, 0x73, 0xda, 0x07, 0x53, 0x4b, 0xdb, 0xc4, 0x8e, 0xa9, 0x25, + 0x7d, 0x0a, 0xad, 0x6d, 0x92, 0x26, 0xda, 0x6e, 0x8c, 0x88, 0xdf, 0x63, 0x65, 0xe1, 0xfd, 0x84, + 0xfe, 0x59, 0x8a, 0xab, 0xdd, 0x56, 0x17, 0x5a, 0x9b, 0x50, 0x6d, 0x50, 0xeb, 0x31, 0xc3, 0x9c, + 0xce, 0xc0, 0xe2, 0x5b, 0x9e, 0x72, 0xa1, 0x95, 0x6d, 0x8e, 0x1a, 0xfe, 0xa3, 0xe9, 0x70, 0x52, + 0xd9, 0x9d, 0x5c, 0xf3, 0xe7, 0x25, 0x8e, 0x9d, 0x09, 0xc5, 0xe0, 0x48, 0xee, 0xc4, 0x79, 0x30, + 0x16, 0xde, 0x0c, 0x9e, 0xd5, 0x12, 0x0b, 0xdf, 0x49, 0xb5, 0xb1, 0x99, 0xc4, 0xe8, 0x87, 0x87, + 0x31, 0x6e, 0xd2, 0x65, 0x98, 0x7b, 0x5f, 0xe0, 0xc9, 0x85, 0xfc, 0x7d, 0xc7, 0x95, 0xbe, 0x7d, + 0x2d, 0x1a, 0x40, 0x3b, 0x2f, 0xae, 0x54, 0x59, 0x7f, 0x5e, 0x63, 0xbd, 0xf8, 0xce, 0xee, 0x60, + 0xde, 0x07, 0x18, 0xdc, 0xb3, 0x96, 0x49, 0xa1, 0x38, 0x9d, 0x42, 0x27, 0x47, 0x9b, 0xca, 0x26, + 0xa8, 0x62, 0xdf, 0x3a, 0x00, 0xab, 0x80, 0x63, 0x07, 0xac, 0x79, 0x9e, 0xbf, 0x97, 0x31, 0x57, + 0xb4, 0x0f, 0xf0, 0x49, 0xf0, 0x5f, 0x19, 0x8f, 0x34, 0x8f, 0x07, 0xc6, 0xf4, 0x07, 0xb4, 0x90, + 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()