From de1e6af58f29ac35ee80f2e3c98e88754d0987db Mon Sep 17 00:00:00 2001 From: mcrakhman Date: Mon, 11 Jul 2022 23:40:44 +0200 Subject: [PATCH] Add thread header and make snapshot --- Makefile | 11 +- aclchanges/pb/aclchanges.pb.go | 152 +++++++------- acltree/aclstate.go | 27 +++ acltree/changebuilder.go | 6 +- thread/models.go | 3 + thread/pb/protos/thread.proto | 8 + thread/pb/thread.pb.go | 355 +++++++++++++++++++++++++++++++++ 7 files changed, 482 insertions(+), 80 deletions(-) create mode 100644 thread/pb/protos/thread.proto create mode 100644 thread/pb/thread.pb.go diff --git a/Makefile b/Makefile index 31dda6ee..fb87ac1e 100644 --- a/Makefile +++ b/Makefile @@ -17,8 +17,11 @@ protos-go: @echo 'Generating protobuf packages (Go)...' $(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types) $(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types) - @$(eval P_ACL_CHANGES := Mdata/pb/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb) - @$(eval P_PLAINTEXT_CHANGES := Mdata/pb/protos/plaintextchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb) + @$(eval P_ACL_CHANGES := Mdata/pb/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges/pb) + @$(eval P_THREAD := Mdata/pb/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/thread/pb) + @$(eval P_PLAINTEXT_CHANGES := Mdata/pb/protos/plaintextchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/testutils/testchanges/pb) - $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT),$$(P_ACL_CHANGES),$$(P_PLAINTEXT_CHANGES)) - GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./data/pb data/pb/protos/*.*; mv data/pb/data/pb/protos/*.go data/pb; rm -rf data/pb/data + $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT),$$(P_ACL_CHANGES)) + GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./aclchanges/pb aclchanges/pb/protos/*.*; mv aclchanges/pb/aclchanges/pb/protos/*.go aclchanges/pb; rm -rf aclchanges/pb/aclchanges + $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT),$$(P_THREAD)) + GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./thread/pb thread/pb/protos/*.*; mv thread/pb/thread/pb/protos/*.go thread/pb; rm -rf thread/pb/thread diff --git a/aclchanges/pb/aclchanges.pb.go b/aclchanges/pb/aclchanges.pb.go index 925d68d4..d872a7bb 100644 --- a/aclchanges/pb/aclchanges.pb.go +++ b/aclchanges/pb/aclchanges.pb.go @@ -1,5 +1,5 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: data/pb/protos/aclchanges.proto +// source: aclchanges/pb/protos/aclchanges.proto package pb @@ -50,7 +50,7 @@ func (x ACLChangeUserPermissions) String() string { } func (ACLChangeUserPermissions) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 0} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 0} } // the element of change tree used to store and internal apply smartBlock history @@ -70,7 +70,7 @@ func (m *ACLChange) Reset() { *m = ACLChange{} } func (m *ACLChange) String() string { return proto.CompactTextString(m) } func (*ACLChange) ProtoMessage() {} func (*ACLChange) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0} + return fileDescriptor_ffc88c8445fc0f24, []int{0} } func (m *ACLChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -170,7 +170,7 @@ func (m *ACLChangeACLContentValue) Reset() { *m = ACLChangeACLContentVal func (m *ACLChangeACLContentValue) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLContentValue) ProtoMessage() {} func (*ACLChangeACLContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 0} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 0} } func (m *ACLChangeACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -301,7 +301,7 @@ func (m *ACLChangeACLData) Reset() { *m = ACLChangeACLData{} } func (m *ACLChangeACLData) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLData) ProtoMessage() {} func (*ACLChangeACLData) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 1} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 1} } func (m *ACLChangeACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -353,7 +353,7 @@ func (m *ACLChangeACLSnapshot) Reset() { *m = ACLChangeACLSnapshot{} } func (m *ACLChangeACLSnapshot) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLSnapshot) ProtoMessage() {} func (*ACLChangeACLSnapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 2} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 2} } func (m *ACLChangeACLSnapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -399,7 +399,7 @@ func (m *ACLChangeACLState) Reset() { *m = ACLChangeACLState{} } func (m *ACLChangeACLState) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLState) ProtoMessage() {} func (*ACLChangeACLState) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 3} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 3} } func (m *ACLChangeACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -461,7 +461,7 @@ func (m *ACLChangeUserState) Reset() { *m = ACLChangeUserState{} } func (m *ACLChangeUserState) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserState) ProtoMessage() {} func (*ACLChangeUserState) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 4} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 4} } func (m *ACLChangeUserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -537,7 +537,7 @@ func (m *ACLChangeUserAdd) Reset() { *m = ACLChangeUserAdd{} } func (m *ACLChangeUserAdd) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserAdd) ProtoMessage() {} func (*ACLChangeUserAdd) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 5} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 5} } func (m *ACLChangeUserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -604,7 +604,7 @@ func (m *ACLChangeUserConfirm) Reset() { *m = ACLChangeUserConfirm{} } func (m *ACLChangeUserConfirm) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserConfirm) ProtoMessage() {} func (*ACLChangeUserConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 6} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 6} } func (m *ACLChangeUserConfirm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -658,7 +658,7 @@ func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} } func (m *ACLChangeUserInvite) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserInvite) ProtoMessage() {} func (*ACLChangeUserInvite) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 7} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 7} } func (m *ACLChangeUserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -727,7 +727,7 @@ func (m *ACLChangeUserJoin) Reset() { *m = ACLChangeUserJoin{} } func (m *ACLChangeUserJoin) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserJoin) ProtoMessage() {} func (*ACLChangeUserJoin) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 8} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 8} } func (m *ACLChangeUserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -800,7 +800,7 @@ func (m *ACLChangeUserRemove) Reset() { *m = ACLChangeUserRemove{} } func (m *ACLChangeUserRemove) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserRemove) ProtoMessage() {} func (*ACLChangeUserRemove) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 9} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 9} } func (m *ACLChangeUserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -853,7 +853,7 @@ func (m *ACLChangeReadKeyReplace) Reset() { *m = ACLChangeReadKeyReplace func (m *ACLChangeReadKeyReplace) String() string { return proto.CompactTextString(m) } func (*ACLChangeReadKeyReplace) ProtoMessage() {} func (*ACLChangeReadKeyReplace) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 10} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 10} } func (m *ACLChangeReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -912,7 +912,7 @@ func (m *ACLChangeUserPermissionChange) Reset() { *m = ACLChangeUserPerm func (m *ACLChangeUserPermissionChange) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserPermissionChange) ProtoMessage() {} func (*ACLChangeUserPermissionChange) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 11} + return fileDescriptor_ffc88c8445fc0f24, []int{0, 11} } func (m *ACLChangeUserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -973,67 +973,69 @@ func init() { proto.RegisterType((*ACLChangeUserPermissionChange)(nil), "anytype.ACLChange.UserPermissionChange") } -func init() { proto.RegisterFile("data/pb/protos/aclchanges.proto", fileDescriptor_5a15109171a9dc49) } +func init() { + proto.RegisterFile("aclchanges/pb/protos/aclchanges.proto", fileDescriptor_ffc88c8445fc0f24) +} -var fileDescriptor_5a15109171a9dc49 = []byte{ - // 898 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4d, 0x6f, 0xe3, 0x44, - 0x18, 0xf6, 0x24, 0x6d, 0x1d, 0xbf, 0x0e, 0x6d, 0x18, 0xf5, 0x60, 0x79, 0x8b, 0x09, 0x15, 0x82, - 0x08, 0xa1, 0x54, 0xca, 0x22, 0xbe, 0x84, 0x04, 0x4d, 0x17, 0x48, 0x28, 0x87, 0xd5, 0xac, 0x00, - 0x81, 0xc4, 0x61, 0x6a, 0x0f, 0x5b, 0x8b, 0xc4, 0xb6, 0x3c, 0x93, 0x0a, 0x5f, 0xf8, 0x07, 0x08, - 0xfe, 0x07, 0x37, 0xfe, 0x00, 0x57, 0x8e, 0x7b, 0x40, 0x88, 0x23, 0x6a, 0xff, 0x08, 0x9a, 0x0f, - 0x3b, 0x4e, 0x6a, 0x17, 0x09, 0x55, 0x42, 0xdc, 0x66, 0x9e, 0x79, 0xde, 0xf1, 0xf3, 0x7e, 0x8e, - 0xe1, 0xc5, 0x88, 0x0a, 0x7a, 0x92, 0x5d, 0x9c, 0x64, 0x79, 0x2a, 0x52, 0x7e, 0x42, 0xc3, 0x45, - 0x78, 0x49, 0x93, 0xa7, 0x8c, 0x8f, 0x15, 0x82, 0x6d, 0x9a, 0x14, 0xa2, 0xc8, 0xd8, 0xf1, 0xcf, - 0x87, 0xe0, 0x9c, 0x9e, 0x7d, 0x7a, 0xa6, 0x4e, 0xf1, 0x10, 0x5c, 0x91, 0x33, 0x36, 0x63, 0x34, - 0x9a, 0x47, 0xdc, 0x43, 0xc3, 0xee, 0xc8, 0x21, 0x75, 0x08, 0x07, 0x00, 0x34, 0x5c, 0x94, 0x84, - 0x8e, 0x22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 0xa3, 0x2f, 0x29, 0xef, 0x7e, 0x0a, - 0x00, 0x00, +var fileDescriptor_ffc88c8445fc0f24 = []byte{ + // 897 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcb, 0x6e, 0xeb, 0x44, + 0x18, 0xf6, 0x24, 0x6d, 0x1d, 0xff, 0x0e, 0x6d, 0x18, 0x75, 0x61, 0xf9, 0x14, 0x2b, 0x54, 0x5c, + 0x22, 0x84, 0x52, 0x29, 0x07, 0x71, 0x13, 0x12, 0x34, 0x3d, 0x40, 0x42, 0x59, 0x1c, 0xcd, 0x11, + 0x20, 0x90, 0x58, 0x4c, 0xed, 0xe1, 0xd4, 0x22, 0xb1, 0x2d, 0xcf, 0xa4, 0x22, 0x1b, 0xde, 0x00, + 0xc1, 0x7b, 0xb0, 0xe3, 0x05, 0xd8, 0xb2, 0x3c, 0x0b, 0x84, 0x58, 0xa2, 0xf6, 0x45, 0xd0, 0x5c, + 0x7c, 0x49, 0x6a, 0x17, 0x09, 0x55, 0x42, 0xec, 0x66, 0xbe, 0xf9, 0xfe, 0xf1, 0xf7, 0x5f, 0xc7, + 0xf0, 0x32, 0x0d, 0x17, 0xe1, 0x25, 0x4d, 0x9e, 0x32, 0x7e, 0x92, 0x5d, 0x9c, 0x64, 0x79, 0x2a, + 0x52, 0x7e, 0x52, 0x81, 0x63, 0x85, 0x60, 0x9b, 0x26, 0x6b, 0xb1, 0xce, 0xd8, 0xf1, 0xcf, 0x87, + 0xe0, 0x9c, 0x9e, 0x7d, 0x7a, 0xa6, 0x4e, 0xf1, 0x10, 0x5c, 0x91, 0x33, 0x36, 0x63, 0x34, 0x9a, + 0x47, 0xdc, 0x43, 0xc3, 0xee, 0xc8, 0x21, 0x75, 0x08, 0x07, 0x00, 0x34, 0x5c, 0x14, 0x84, 0x8e, + 0x22, 0xd4, 0x10, 0xfc, 0x0a, 0xec, 0xf3, 0x84, 0x66, 0xfc, 0x32, 0x15, 0x53, 0xca, 0xd9, 0x3c, + 0xf2, 0xba, 0x43, 0x34, 0x72, 0xc8, 0x16, 0x8a, 0xdf, 0x00, 0x9b, 0x86, 0x8b, 0x47, 0x54, 0x50, + 0x6f, 0x67, 0x88, 0x46, 0xee, 0xc4, 0x1f, 0x1b, 0x49, 0xe3, 0x52, 0x8e, 0x5c, 0x49, 0x06, 0x29, + 0xa8, 0x52, 0x9f, 0xf1, 0x43, 0x59, 0xee, 0x0e, 0xd1, 0xa8, 0x4f, 0xea, 0x10, 0x1e, 0x03, 0x0e, + 0x57, 0x79, 0xce, 0x12, 0x41, 0x18, 0x8d, 0xce, 0xd9, 0x7a, 0x46, 0xf9, 0xa5, 0xb7, 0x37, 0x44, + 0xa3, 0x1d, 0xd2, 0x70, 0x82, 0x8f, 0xc0, 0x11, 0xf1, 0x92, 0x71, 0x41, 0x97, 0x99, 0x67, 0x0f, + 0xd1, 0xa8, 0x4b, 0x2a, 0x00, 0xfb, 0xd0, 0x8b, 0x23, 0x96, 0x88, 0x58, 0xac, 0xbd, 0x9e, 0xf2, + 0xa3, 0xdc, 0xfb, 0xbf, 0x74, 0xe1, 0x40, 0x4a, 0x4d, 0x13, 0xc1, 0x12, 0xf1, 0x39, 0x5d, 0xac, + 0x18, 0x7e, 0x13, 0xec, 0x15, 0x67, 0xf9, 0x69, 0x14, 0x79, 0xa8, 0xd5, 0xab, 0xcf, 0x34, 0x63, + 0x66, 0x91, 0x82, 0x8c, 0xdf, 0x07, 0x90, 0x4b, 0xc2, 0x96, 0xe9, 0x15, 0xf3, 0x3a, 0xca, 0xf4, + 0x85, 0x16, 0x53, 0x4d, 0x9a, 0x59, 0xa4, 0x66, 0x82, 0xbf, 0x86, 0x43, 0xb9, 0x7b, 0xcc, 0xf2, + 0x65, 0xcc, 0x79, 0x9c, 0x26, 0xda, 0x40, 0x05, 0xdf, 0x9d, 0xbc, 0xda, 0x72, 0xd5, 0x36, 0x7d, + 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} func (m *ACLChange) Marshal() (dAtA []byte, err error) { diff --git a/acltree/aclstate.go b/acltree/aclstate.go index f2eaad3e..fd92cca6 100644 --- a/acltree/aclstate.go +++ b/acltree/aclstate.go @@ -27,6 +27,20 @@ type ACLState struct { identity string } +func newACLState( + identity string, + encryptionKey keys.EncryptionPrivKey, + signingPubKeyDecoder keys.SigningPubKeyDecoder) *ACLState { + return &ACLState{ + identity: identity, + encryptionKey: encryptionKey, + userReadKeys: make(map[uint64]*symmetric.Key), + userStates: make(map[string]*pb.ACLChangeUserState), + userInvites: make(map[string]*pb.ACLChangeUserInvite), + signingPubKeyDecoder: signingPubKeyDecoder, + } +} + func newACLStateFromSnapshot( snapshot *pb.ACLChangeACLSnapshot, identity string, @@ -74,6 +88,19 @@ func (st *ACLState) recreateFromSnapshot(snapshot *pb.ACLChangeACLSnapshot) erro return nil } +func (st *ACLState) makeSnapshot() *pb.ACLChangeACLSnapshot { + var userStates []*pb.ACLChangeUserState + for _, st := range st.userStates { + userStates = append(userStates, st) + } + + return &pb.ACLChangeACLSnapshot{AclState: &pb.ACLChangeACLState{ + ReadKeyHashes: nil, + UserStates: userStates, // TODO: make states and invites in same format + Invites: st.userInvites, + }} +} + func (st *ACLState) applyChange(changeId string, change *pb.ACLChange) error { // we can't check this for the user which is joining, because it will not be in our list if !st.isUserJoin(change) { diff --git a/acltree/changebuilder.go b/acltree/changebuilder.go index 458bc85b..423bbca4 100644 --- a/acltree/changebuilder.go +++ b/acltree/changebuilder.go @@ -68,10 +68,14 @@ func (c *changeBuilder) Build() (*Change, []byte, error) { return nil, nil, err } + if c.makeSnapshot { + c.aclData.AclSnapshot = c.aclState.makeSnapshot() + } + aclChange := &pb.ACLChange{ TreeHeadIds: c.tree.Heads(), AclHeadIds: c.tree.ACLHeads(), - SnapshotBaseId: c.tree.RootId(), // TODO: add logic for ACL snapshot + SnapshotBaseId: c.tree.RootId(), AclData: c.aclData, ChangesData: encrypted, CurrentReadKeyHash: c.aclState.currentReadKeyHash, diff --git a/thread/models.go b/thread/models.go index 1e57beb7..7a10ff67 100644 --- a/thread/models.go +++ b/thread/models.go @@ -2,6 +2,7 @@ package thread import ( "context" + "github.com/anytypeio/go-anytype-infrastructure-experiments/thread/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/aclchanges" ) @@ -10,6 +11,7 @@ import ( type Thread interface { ID() string + Header() *pb.ThreadHeader Heads() []string Orphans() []string SetHeads(heads []string) @@ -18,6 +20,7 @@ type Thread interface { AddRawChange(change *RawChange) error AddChange(change aclchanges.Change) error + // TODO: have methods with raw changes also GetChange(ctx context.Context, recordID string) (*RawChange, error) } diff --git a/thread/pb/protos/thread.proto b/thread/pb/protos/thread.proto new file mode 100644 index 00000000..d3930e4c --- /dev/null +++ b/thread/pb/protos/thread.proto @@ -0,0 +1,8 @@ +syntax = "proto3"; +package anytype; +option go_package = "pb"; + +message ThreadHeader { + string firstRecordId = 1; + bool isWorkspace = 2; +} \ No newline at end of file diff --git a/thread/pb/thread.pb.go b/thread/pb/thread.pb.go new file mode 100644 index 00000000..f6b0ef5c --- /dev/null +++ b/thread/pb/thread.pb.go @@ -0,0 +1,355 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: thread/pb/protos/thread.proto + +package pb + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type ThreadHeader struct { + FirstRecordId string `protobuf:"bytes,1,opt,name=firstRecordId,proto3" json:"firstRecordId,omitempty"` + IsWorkspace bool `protobuf:"varint,2,opt,name=isWorkspace,proto3" json:"isWorkspace,omitempty"` +} + +func (m *ThreadHeader) Reset() { *m = ThreadHeader{} } +func (m *ThreadHeader) String() string { return proto.CompactTextString(m) } +func (*ThreadHeader) ProtoMessage() {} +func (*ThreadHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_b228ffbfd554b168, []int{0} +} +func (m *ThreadHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ThreadHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ThreadHeader.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 *ThreadHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_ThreadHeader.Merge(m, src) +} +func (m *ThreadHeader) XXX_Size() int { + return m.Size() +} +func (m *ThreadHeader) XXX_DiscardUnknown() { + xxx_messageInfo_ThreadHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_ThreadHeader proto.InternalMessageInfo + +func (m *ThreadHeader) GetFirstRecordId() string { + if m != nil { + return m.FirstRecordId + } + return "" +} + +func (m *ThreadHeader) GetIsWorkspace() bool { + if m != nil { + return m.IsWorkspace + } + return false +} + +func init() { + proto.RegisterType((*ThreadHeader)(nil), "anytype.ThreadHeader") +} + +func init() { proto.RegisterFile("thread/pb/protos/thread.proto", fileDescriptor_b228ffbfd554b168) } + +var fileDescriptor_b228ffbfd554b168 = []byte{ + // 156 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x92, 0x2d, 0xc9, 0x28, 0x4a, + 0x4d, 0x4c, 0xd1, 0x2f, 0x48, 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0xd6, 0x87, 0x08, 0xe8, + 0x81, 0x79, 0x42, 0xec, 0x89, 0x79, 0x95, 0x25, 0x95, 0x05, 0xa9, 0x4a, 0x61, 0x5c, 0x3c, 0x21, + 0x60, 0x09, 0x8f, 0xd4, 0xc4, 0x94, 0xd4, 0x22, 0x21, 0x15, 0x2e, 0xde, 0xb4, 0xcc, 0xa2, 0xe2, + 0x92, 0xa0, 0xd4, 0xe4, 0xfc, 0xa2, 0x14, 0xcf, 0x14, 0x09, 0x46, 0x05, 0x46, 0x0d, 0xce, 0x20, + 0x54, 0x41, 0x21, 0x05, 0x2e, 0xee, 0xcc, 0xe2, 0xf0, 0xfc, 0xa2, 0xec, 0xe2, 0x82, 0xc4, 0xe4, + 0x54, 0x09, 0x26, 0x05, 0x46, 0x0d, 0x8e, 0x20, 0x64, 0x21, 0x27, 0x99, 0x13, 0x8f, 0xe4, 0x18, + 0x2f, 0x3c, 0x92, 0x63, 0x7c, 0xf0, 0x48, 0x8e, 0x71, 0xc2, 0x63, 0x39, 0x86, 0x0b, 0x8f, 0xe5, + 0x18, 0x6e, 0x3c, 0x96, 0x63, 0x88, 0x62, 0x2a, 0x48, 0x4a, 0x62, 0x03, 0xbb, 0xc2, 0x18, 0x10, + 0x00, 0x00, 0xff, 0xff, 0x05, 0x80, 0xf4, 0xa3, 0xa6, 0x00, 0x00, 0x00, +} + +func (m *ThreadHeader) 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 *ThreadHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ThreadHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsWorkspace { + i-- + if m.IsWorkspace { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x10 + } + if len(m.FirstRecordId) > 0 { + i -= len(m.FirstRecordId) + copy(dAtA[i:], m.FirstRecordId) + i = encodeVarintThread(dAtA, i, uint64(len(m.FirstRecordId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintThread(dAtA []byte, offset int, v uint64) int { + offset -= sovThread(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *ThreadHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.FirstRecordId) + if l > 0 { + n += 1 + l + sovThread(uint64(l)) + } + if m.IsWorkspace { + n += 2 + } + return n +} + +func sovThread(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozThread(x uint64) (n int) { + return sovThread(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *ThreadHeader) 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 ErrIntOverflowThread + } + 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: ThreadHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ThreadHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field FirstRecordId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowThread + } + 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 ErrInvalidLengthThread + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthThread + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.FirstRecordId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsWorkspace", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowThread + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsWorkspace = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipThread(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthThread + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipThread(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowThread + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowThread + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowThread + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthThread + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupThread + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthThread + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthThread = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowThread = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupThread = fmt.Errorf("proto: unexpected end of group") +)