diff --git a/Makefile b/Makefile index b75d2d22..e9143f01 100644 --- a/Makefile +++ b/Makefile @@ -12,26 +12,25 @@ endif export PATH=$(GOPATH)/bin:$(shell echo $$PATH) -# TODO: folders were changed, so we should update Makefile and protos generation proto: @echo 'Generating protobuf packages (Go)...' # Uncomment if needed @$(eval ROOT_PKG := pkg) @$(eval GOGO_START := GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1) - @$(eval P_ACL_CHANGES_PATH_PB := $(ROOT_PKG)/acl/aclchanges/aclpb) + @$(eval P_ACL_RECORDS_PATH_PB := $(ROOT_PKG)/acl/aclrecordproto) + @$(eval P_TREE_CHANGES_PATH_PB := $(ROOT_PKG)/acl/treechangeproto) @$(eval P_SYNC_CHANGES_PATH_PB := syncproto) @$(eval P_TEST_CHANGES_PATH_PB := $(ROOT_PKG)/acl/testutils/testchanges) - @$(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types) - @$(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types) - @$(eval P_ACL_CHANGES := M$(P_ACL_CHANGES_PATH_PB)/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_CHANGES_PATH_PB)) + @$(eval P_ACL_RECORDS := M$(P_ACL_RECORDS_PATH_PB)/protos/aclrecord.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_ACL_RECORDS_PATH_PB)) + @$(eval P_TREE_CHANGES := M$(P_TREE_CHANGES_PATH_PB)/protos/treechange.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/$(P_TREE_CHANGES_PATH_PB)) - # use if needed $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT)) - $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_CHANGES_PATH_PB)/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=:. $(P_ACL_RECORDS_PATH_PB)/protos/*.proto + $(GOGO_START) protoc --gogofaster_out=:. $(P_TREE_CHANGES_PATH_PB)/protos/*.proto $(GOGO_START) protoc --gogofaster_out=:. $(P_TEST_CHANGES_PATH_PB)/proto/*.proto - $(eval PKGMAP := $$(P_ACL_CHANGES)) - $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. $(P_SYNC_CHANGES_PATH_PB)/proto/*.proto + $(eval PKGMAP := $$(P_TREE_CHANGES)) $(GOGO_START) protoc --gogofaster_out=$(PKGMAP):. --go-drpc_out=protolib=github.com/gogo/protobuf:. common/commonspace/spacesyncproto/protos/*.proto + build: @$(eval FLAGS := $$(shell govvv -flags -pkg github.com/anytypeio/go-anytype-infrastructure-experiments/app)) go build -v -o bin/anytype-node -ldflags "$(FLAGS)" cmd/node/node.go \ No newline at end of file diff --git a/common/commonspace/spacesyncproto/protos/spacesync.proto b/common/commonspace/spacesyncproto/protos/spacesync.proto index 22f7e82d..a4bb3171 100644 --- a/common/commonspace/spacesyncproto/protos/spacesync.proto +++ b/common/commonspace/spacesyncproto/protos/spacesync.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package anySpace; option go_package = "common/commonspace/spacesyncproto"; -import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto"; +import "pkg/acl/treechangeproto/protos/treechange.proto"; enum ErrCodes { Unexpected = 0; @@ -49,7 +49,7 @@ message HeadSyncResponse { message ObjectSyncMessage { string spaceId = 1; ObjectSyncContentValue content = 2; - acl.TreeHeader treeHeader = 3; + treechange.RootChange treeHeader = 3; string treeId = 4; string trackingId = 5; // @@ -70,24 +70,32 @@ message ObjectSyncContentValue { // ObjectHeadUpdate is a message sent on document head update message ObjectHeadUpdate { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } // ObjectHeadUpdate is a message sent when document needs full sync message ObjectFullSyncRequest { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } // ObjectFullSyncResponse is a message sent as a response for a specific full sync message ObjectFullSyncResponse { repeated string heads = 1; - repeated acl.RawTreeChangeWithId changes = 2; + repeated treechange.RawTreeChangeWithId changes = 2; repeated string snapshotPath = 3; } message ObjectErrorResponse { string error = 1; } + +message SpaceHeader { + bytes identity = 1; + int64 timestamp = 2; + string spaceType = 3; + uint64 replicationKey = 4; + bytes seed = 5; +} diff --git a/common/commonspace/spacesyncproto/spacesync.go b/common/commonspace/spacesyncproto/spacesync.go index 25ec1ba6..6ac07962 100644 --- a/common/commonspace/spacesyncproto/spacesync.go +++ b/common/commonspace/spacesyncproto/spacesync.go @@ -1,6 +1,6 @@ package spacesyncproto -import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" +import "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" type SpaceStream = DRPCSpace_StreamStream diff --git a/common/commonspace/spacesyncproto/spacesync.pb.go b/common/commonspace/spacesyncproto/spacesync.pb.go index 04b77518..a0e6bf89 100644 --- a/common/commonspace/spacesyncproto/spacesync.pb.go +++ b/common/commonspace/spacesyncproto/spacesync.pb.go @@ -5,7 +5,7 @@ package spacesyncproto import ( fmt "fmt" - aclpb "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + treechangeproto "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" proto "github.com/gogo/protobuf/proto" io "io" math "math" @@ -320,11 +320,11 @@ func (m *HeadSyncResponse) GetResults() []*HeadSyncResult { // ObjectSyncMessage is a message sent on object sync type ObjectSyncMessage struct { - SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` - Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` - TreeHeader *aclpb.TreeHeader `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` - TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` - TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` + SpaceId string `protobuf:"bytes,1,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + Content *ObjectSyncContentValue `protobuf:"bytes,2,opt,name=content,proto3" json:"content,omitempty"` + TreeHeader *treechangeproto.RootChange `protobuf:"bytes,3,opt,name=treeHeader,proto3" json:"treeHeader,omitempty"` + TreeId string `protobuf:"bytes,4,opt,name=treeId,proto3" json:"treeId,omitempty"` + TrackingId string `protobuf:"bytes,5,opt,name=trackingId,proto3" json:"trackingId,omitempty"` } func (m *ObjectSyncMessage) Reset() { *m = ObjectSyncMessage{} } @@ -374,7 +374,7 @@ func (m *ObjectSyncMessage) GetContent() *ObjectSyncContentValue { return nil } -func (m *ObjectSyncMessage) GetTreeHeader() *aclpb.TreeHeader { +func (m *ObjectSyncMessage) GetTreeHeader() *treechangeproto.RootChange { if m != nil { return m.TreeHeader } @@ -509,9 +509,9 @@ func (*ObjectSyncContentValue) XXX_OneofWrappers() []interface{} { // ObjectHeadUpdate is a message sent on document head update type ObjectHeadUpdate struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectHeadUpdate) Reset() { *m = ObjectHeadUpdate{} } @@ -554,7 +554,7 @@ func (m *ObjectHeadUpdate) GetHeads() []string { return nil } -func (m *ObjectHeadUpdate) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectHeadUpdate) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -570,9 +570,9 @@ func (m *ObjectHeadUpdate) GetSnapshotPath() []string { // ObjectHeadUpdate is a message sent when document needs full sync type ObjectFullSyncRequest struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectFullSyncRequest) Reset() { *m = ObjectFullSyncRequest{} } @@ -615,7 +615,7 @@ func (m *ObjectFullSyncRequest) GetHeads() []string { return nil } -func (m *ObjectFullSyncRequest) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectFullSyncRequest) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -631,9 +631,9 @@ func (m *ObjectFullSyncRequest) GetSnapshotPath() []string { // ObjectFullSyncResponse is a message sent as a response for a specific full sync type ObjectFullSyncResponse struct { - Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` - Changes []*aclpb.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` - SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` + Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"` + Changes []*treechangeproto.RawTreeChangeWithId `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"` + SnapshotPath []string `protobuf:"bytes,3,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"` } func (m *ObjectFullSyncResponse) Reset() { *m = ObjectFullSyncResponse{} } @@ -676,7 +676,7 @@ func (m *ObjectFullSyncResponse) GetHeads() []string { return nil } -func (m *ObjectFullSyncResponse) GetChanges() []*aclpb.RawTreeChangeWithId { +func (m *ObjectFullSyncResponse) GetChanges() []*treechangeproto.RawTreeChangeWithId { if m != nil { return m.Changes } @@ -734,6 +734,82 @@ func (m *ObjectErrorResponse) GetError() string { return "" } +type SpaceHeader struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + Timestamp int64 `protobuf:"varint,2,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + SpaceType string `protobuf:"bytes,3,opt,name=spaceType,proto3" json:"spaceType,omitempty"` + ReplicationKey uint64 `protobuf:"varint,4,opt,name=replicationKey,proto3" json:"replicationKey,omitempty"` + Seed []byte `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"` +} + +func (m *SpaceHeader) Reset() { *m = SpaceHeader{} } +func (m *SpaceHeader) String() string { return proto.CompactTextString(m) } +func (*SpaceHeader) ProtoMessage() {} +func (*SpaceHeader) Descriptor() ([]byte, []int) { + return fileDescriptor_5855f4ef9cf24cdb, []int{11} +} +func (m *SpaceHeader) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *SpaceHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_SpaceHeader.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *SpaceHeader) XXX_Merge(src proto.Message) { + xxx_messageInfo_SpaceHeader.Merge(m, src) +} +func (m *SpaceHeader) XXX_Size() int { + return m.Size() +} +func (m *SpaceHeader) XXX_DiscardUnknown() { + xxx_messageInfo_SpaceHeader.DiscardUnknown(m) +} + +var xxx_messageInfo_SpaceHeader proto.InternalMessageInfo + +func (m *SpaceHeader) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *SpaceHeader) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *SpaceHeader) GetSpaceType() string { + if m != nil { + return m.SpaceType + } + return "" +} + +func (m *SpaceHeader) GetReplicationKey() uint64 { + if m != nil { + return m.ReplicationKey + } + return 0 +} + +func (m *SpaceHeader) GetSeed() []byte { + if m != nil { + return m.Seed + } + return nil +} + func init() { proto.RegisterEnum("anySpace.ErrCodes", ErrCodes_name, ErrCodes_value) proto.RegisterType((*HeadSyncRange)(nil), "anySpace.HeadSyncRange") @@ -747,6 +823,7 @@ func init() { proto.RegisterType((*ObjectFullSyncRequest)(nil), "anySpace.ObjectFullSyncRequest") proto.RegisterType((*ObjectFullSyncResponse)(nil), "anySpace.ObjectFullSyncResponse") proto.RegisterType((*ObjectErrorResponse)(nil), "anySpace.ObjectErrorResponse") + proto.RegisterType((*SpaceHeader)(nil), "anySpace.SpaceHeader") } func init() { @@ -754,52 +831,57 @@ func init() { } var fileDescriptor_5855f4ef9cf24cdb = []byte{ - // 712 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x55, 0x4b, 0x6f, 0xd3, 0x40, - 0x10, 0xf6, 0xa6, 0x79, 0x75, 0xd2, 0x47, 0x58, 0x68, 0x31, 0x41, 0xa4, 0xc1, 0xa7, 0x08, 0xa4, - 0xa4, 0x0a, 0x17, 0x44, 0xb9, 0xd0, 0x2a, 0x55, 0x22, 0xc4, 0x43, 0x5b, 0x0a, 0x12, 0xe2, 0xb2, - 0xb5, 0xb7, 0x49, 0xa8, 0x63, 0x1b, 0xef, 0x86, 0xd2, 0x1b, 0x17, 0x38, 0x23, 0xfe, 0x12, 0x17, - 0x8e, 0x15, 0x27, 0x8e, 0xa8, 0xfd, 0x23, 0x68, 0xc7, 0x76, 0x5e, 0xb8, 0xe5, 0xd6, 0x43, 0xec, - 0x9d, 0xd9, 0xf9, 0xbe, 0xfd, 0xf6, 0x9b, 0xf5, 0x06, 0x1e, 0xda, 0xfe, 0x70, 0xe8, 0x7b, 0xcd, - 0xe8, 0x25, 0x03, 0x6e, 0x8b, 0x26, 0x3e, 0xe5, 0x89, 0x67, 0x07, 0xa1, 0xaf, 0xfc, 0x26, 0x3e, - 0xe5, 0x24, 0xdb, 0xc0, 0x04, 0x2d, 0x72, 0xef, 0x64, 0x4f, 0xe7, 0x2a, 0x9b, 0xc1, 0x51, 0xaf, - 0xc9, 0x6d, 0x57, 0xff, 0xec, 0x3e, 0xf7, 0x7a, 0x42, 0xea, 0x61, 0x70, 0x90, 0x40, 0x27, 0xf9, - 0x08, 0x6b, 0x75, 0x61, 0xb9, 0x23, 0xb8, 0xb3, 0x77, 0xe2, 0xd9, 0x4c, 0xe7, 0x29, 0x85, 0xec, - 0x61, 0xe8, 0x0f, 0x4d, 0x52, 0x23, 0xf5, 0x2c, 0xc3, 0x31, 0x5d, 0x81, 0x8c, 0xf2, 0xcd, 0x0c, - 0x66, 0x32, 0xca, 0xa7, 0x37, 0x20, 0xe7, 0x0e, 0x86, 0x03, 0x65, 0x2e, 0xd4, 0x48, 0x7d, 0x99, - 0x45, 0x81, 0x75, 0x0c, 0x2b, 0x63, 0x2a, 0x21, 0x47, 0xae, 0xd2, 0x5c, 0x7d, 0x2e, 0xfb, 0xc8, - 0xb5, 0xc4, 0x70, 0x4c, 0xb7, 0xa0, 0x28, 0x5c, 0x31, 0x14, 0x9e, 0x92, 0x66, 0xa6, 0xb6, 0x50, - 0x2f, 0xb5, 0x36, 0x1a, 0x89, 0xfe, 0xc6, 0x2c, 0xbe, 0x1d, 0xd5, 0xb1, 0x31, 0x40, 0x2f, 0x6c, - 0xfb, 0x23, 0x6f, 0xbc, 0x30, 0x06, 0xd6, 0x16, 0xac, 0xa5, 0x02, 0xb5, 0xee, 0x81, 0x83, 0xab, - 0x2f, 0xb2, 0xcc, 0xc0, 0x41, 0x3d, 0x82, 0x3b, 0xb8, 0x93, 0x45, 0x86, 0x63, 0xeb, 0x1d, 0xac, - 0x4e, 0xc0, 0x1f, 0x46, 0x42, 0x2a, 0x6a, 0x42, 0x01, 0x2d, 0xee, 0x26, 0xd8, 0x24, 0xa4, 0x4d, - 0xc8, 0x87, 0xe8, 0x5e, 0x2c, 0xfd, 0x66, 0x8a, 0x74, 0x3d, 0xcf, 0xe2, 0x32, 0x6b, 0x17, 0xca, - 0x53, 0xd2, 0x02, 0xdf, 0x93, 0x82, 0xb6, 0xa0, 0x10, 0xa2, 0x4c, 0x69, 0x12, 0x64, 0x31, 0x2f, - 0x32, 0x80, 0x25, 0x85, 0xd6, 0x2f, 0x02, 0xd7, 0x5e, 0x1c, 0xbc, 0x17, 0xb6, 0xd2, 0xb3, 0xcf, - 0x84, 0x94, 0xbc, 0x27, 0x2e, 0x11, 0xfa, 0x08, 0x0a, 0xb6, 0xef, 0x29, 0xe1, 0x29, 0xdc, 0x6c, - 0xa9, 0x55, 0x9b, 0xac, 0x31, 0xe1, 0xd9, 0x89, 0x4a, 0x5e, 0x73, 0x77, 0x24, 0x58, 0x02, 0xa0, - 0x4d, 0x00, 0x15, 0x0a, 0xa1, 0xa5, 0x88, 0x10, 0x9d, 0x2e, 0xb5, 0x56, 0x1b, 0xdc, 0x76, 0x1b, - 0xaf, 0xc6, 0x69, 0x36, 0x55, 0x42, 0xd7, 0x21, 0xaf, 0xa3, 0xae, 0x63, 0x66, 0x51, 0x45, 0x1c, - 0xd1, 0xaa, 0x26, 0xe2, 0xf6, 0xd1, 0xc0, 0xeb, 0x75, 0x1d, 0x33, 0x87, 0x73, 0x53, 0x19, 0xeb, - 0x47, 0x06, 0xd6, 0xd3, 0xc5, 0xd0, 0xc7, 0x00, 0xba, 0x3b, 0xfb, 0x81, 0xc3, 0x95, 0xc0, 0xcd, - 0x95, 0x5a, 0x95, 0xf9, 0x2d, 0x74, 0xc6, 0x15, 0x1d, 0x83, 0x4d, 0xd5, 0xd3, 0xa7, 0xb0, 0x7a, - 0x38, 0x72, 0xdd, 0xa9, 0x9e, 0xc6, 0x2e, 0x6c, 0xcc, 0x53, 0xec, 0xce, 0x96, 0x75, 0x0c, 0x36, - 0x8f, 0xa4, 0xcf, 0xa1, 0x3c, 0x49, 0x45, 0x2d, 0x8c, 0x4d, 0xa9, 0x5d, 0xcc, 0x16, 0xd5, 0x75, - 0x0c, 0xf6, 0x0f, 0x96, 0xb6, 0x61, 0x59, 0x84, 0xa1, 0x1f, 0x8e, 0xc9, 0xb2, 0x48, 0x76, 0x67, - 0x9e, 0xac, 0x3d, 0x5d, 0xd4, 0x31, 0xd8, 0x2c, 0x6a, 0xbb, 0x00, 0xb9, 0x8f, 0xda, 0x2a, 0xeb, - 0x33, 0x81, 0xf2, 0xbc, 0x1f, 0xfa, 0x43, 0xd1, 0x7e, 0x44, 0x27, 0x6c, 0x91, 0x45, 0x81, 0x3e, - 0x79, 0xf1, 0xd7, 0x1f, 0x9f, 0x5f, 0x13, 0xdb, 0xca, 0xf8, 0xb1, 0xee, 0xec, 0x0e, 0x4e, 0xbd, - 0x19, 0xa8, 0x7e, 0xd7, 0x61, 0x49, 0x21, 0xb5, 0x60, 0x49, 0x7a, 0x3c, 0x90, 0x7d, 0x5f, 0xbd, - 0xe4, 0xaa, 0x6f, 0x2e, 0x20, 0xe1, 0x4c, 0xce, 0xfa, 0x42, 0x60, 0x2d, 0xd5, 0xcf, 0x2b, 0xd6, - 0xf1, 0x95, 0x24, 0x07, 0x6a, 0xbe, 0x13, 0x57, 0x2c, 0xe4, 0x3e, 0x5c, 0x4f, 0x69, 0xa2, 0x16, - 0x81, 0x4d, 0x8c, 0xbf, 0xd6, 0x28, 0xb8, 0x57, 0x81, 0x62, 0x3b, 0x0c, 0x77, 0x7c, 0x47, 0x48, - 0xba, 0x02, 0xb0, 0xef, 0x89, 0x4f, 0x81, 0xb0, 0x95, 0x70, 0xca, 0x46, 0xeb, 0x3b, 0x81, 0x1c, - 0x1e, 0x0a, 0xfa, 0x04, 0x8a, 0xc9, 0xe5, 0x40, 0x6f, 0xa5, 0x5d, 0x18, 0x68, 0x78, 0xa5, 0x92, - 0x7a, 0x97, 0x44, 0xcb, 0xef, 0x42, 0x7e, 0x4f, 0x85, 0x82, 0x0f, 0xe9, 0xed, 0xb4, 0xdb, 0x20, - 0xbe, 0x55, 0x2a, 0x97, 0x4d, 0xd6, 0xc9, 0x26, 0xd9, 0xde, 0xfa, 0x79, 0x56, 0x25, 0xa7, 0x67, - 0x55, 0xf2, 0xe7, 0xac, 0x4a, 0xbe, 0x9d, 0x57, 0x8d, 0xd3, 0xf3, 0xaa, 0xf1, 0xfb, 0xbc, 0x6a, - 0xbc, 0xbd, 0xfb, 0xdf, 0xff, 0xb0, 0x83, 0x3c, 0xbe, 0x1e, 0xfc, 0x0d, 0x00, 0x00, 0xff, 0xff, - 0x93, 0x27, 0x56, 0x41, 0xef, 0x06, 0x00, 0x00, + // 797 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xc4, 0x55, 0xcd, 0x8e, 0xe3, 0x44, + 0x10, 0xb6, 0x33, 0x99, 0x49, 0x52, 0x99, 0x99, 0x0d, 0x0d, 0x3b, 0x98, 0x00, 0xd9, 0xe0, 0x03, + 0x8a, 0x40, 0x4a, 0x50, 0x90, 0x10, 0x30, 0x5c, 0xd8, 0x51, 0x46, 0x89, 0x56, 0xfc, 0xa8, 0x67, + 0x17, 0x24, 0xc4, 0xa5, 0xd7, 0xae, 0x4d, 0xcc, 0xda, 0x6e, 0xe3, 0xee, 0xb0, 0xe4, 0x09, 0xb8, + 0x80, 0x84, 0x78, 0x03, 0x9e, 0x85, 0x0b, 0xc7, 0x3d, 0xc2, 0x0d, 0xcd, 0xbc, 0x08, 0xea, 0xb2, + 0x1d, 0x3b, 0xc1, 0xbb, 0x1c, 0xf7, 0x12, 0x77, 0x7d, 0x5d, 0xf5, 0xf5, 0xd7, 0x55, 0xd5, 0x15, + 0xf8, 0xd0, 0x93, 0x51, 0x24, 0xe3, 0x49, 0xf6, 0x51, 0x89, 0xf0, 0x70, 0x42, 0xbf, 0x6a, 0x13, + 0x7b, 0x49, 0x2a, 0xb5, 0x9c, 0xd0, 0xaf, 0x2a, 0xd1, 0x31, 0x01, 0xac, 0x2d, 0xe2, 0xcd, 0x95, + 0xc1, 0xfa, 0x93, 0xe4, 0xf1, 0x72, 0x22, 0xbc, 0x70, 0xa2, 0x53, 0x44, 0x6f, 0x25, 0xe2, 0x25, + 0xee, 0x44, 0x96, 0x70, 0x16, 0xea, 0x2e, 0xe0, 0x64, 0x8e, 0xc2, 0xbf, 0xda, 0xc4, 0x1e, 0x37, + 0x30, 0x63, 0xd0, 0x7c, 0x94, 0xca, 0xc8, 0xb1, 0x87, 0xf6, 0xa8, 0xc9, 0x69, 0xcd, 0x4e, 0xa1, + 0xa1, 0xa5, 0xd3, 0x20, 0xa4, 0xa1, 0x25, 0x7b, 0x05, 0x0e, 0xc3, 0x20, 0x0a, 0xb4, 0x73, 0x30, + 0xb4, 0x47, 0x27, 0x3c, 0x33, 0xdc, 0x27, 0x70, 0xba, 0xa5, 0x42, 0xb5, 0x0e, 0xb5, 0xe1, 0x5a, + 0x09, 0xb5, 0x22, 0xae, 0x63, 0x4e, 0x6b, 0x76, 0x0e, 0x6d, 0x0c, 0x31, 0xc2, 0x58, 0x2b, 0xa7, + 0x31, 0x3c, 0x18, 0x75, 0xa7, 0x77, 0xc6, 0x85, 0xfc, 0xf1, 0x6e, 0xfc, 0x2c, 0xf3, 0xe3, 0xdb, + 0x00, 0x73, 0xb0, 0x27, 0xd7, 0xf1, 0xf6, 0x60, 0x32, 0xdc, 0x73, 0xb8, 0x5d, 0x1b, 0x68, 0x74, + 0x07, 0x3e, 0x9d, 0xde, 0xe1, 0x8d, 0xc0, 0x27, 0x3d, 0x28, 0x7c, 0xba, 0x49, 0x87, 0xd3, 0xda, + 0xfd, 0x16, 0x6e, 0x95, 0xc1, 0xdf, 0xaf, 0x51, 0x69, 0xe6, 0x40, 0x8b, 0x32, 0xbc, 0x28, 0x62, + 0x0b, 0x93, 0x4d, 0xe0, 0x28, 0x35, 0x59, 0x2a, 0xa4, 0xbf, 0x5a, 0x23, 0xdd, 0xec, 0xf3, 0xdc, + 0xcd, 0xbd, 0x84, 0x5e, 0x45, 0x5a, 0x22, 0x63, 0x85, 0x6c, 0x0a, 0xad, 0x94, 0x64, 0x2a, 0xc7, + 0x26, 0x16, 0xe7, 0x59, 0x09, 0xe0, 0x85, 0xa3, 0xfb, 0xb7, 0x0d, 0x2f, 0x7d, 0xf1, 0xf0, 0x3b, + 0xf4, 0xb4, 0xd9, 0xfd, 0x0c, 0x95, 0x12, 0x4b, 0x7c, 0x8e, 0xd0, 0x8f, 0xa1, 0xe5, 0xc9, 0x58, + 0x63, 0xac, 0xe9, 0xb2, 0xdd, 0xe9, 0xb0, 0x3c, 0xa3, 0xe4, 0xb9, 0xc8, 0x5c, 0xbe, 0x12, 0xe1, + 0x1a, 0x79, 0x11, 0xc0, 0x3e, 0x00, 0x30, 0x6d, 0x62, 0xa4, 0x60, 0x4a, 0x99, 0xee, 0x4e, 0xcf, + 0xc6, 0x95, 0xce, 0xe1, 0x52, 0xea, 0x0b, 0x5a, 0xf2, 0x8a, 0x27, 0x3b, 0x83, 0x23, 0x63, 0x2d, + 0x7c, 0xa7, 0x49, 0x62, 0x72, 0x8b, 0x0d, 0x0c, 0x9f, 0xf0, 0x1e, 0x07, 0xf1, 0x72, 0xe1, 0x3b, + 0x87, 0xb4, 0x57, 0x41, 0xdc, 0x3f, 0x1a, 0x70, 0x56, 0xaf, 0x89, 0x7d, 0x02, 0x60, 0x8a, 0xf4, + 0x20, 0xf1, 0x85, 0x46, 0xba, 0x63, 0x77, 0xda, 0xdf, 0xbf, 0xc9, 0x7c, 0xeb, 0x31, 0xb7, 0x78, + 0xc5, 0x9f, 0xdd, 0x83, 0x5b, 0x8f, 0xd6, 0x61, 0x58, 0x29, 0x6d, 0x9e, 0x8c, 0x3b, 0xfb, 0x14, + 0x97, 0xbb, 0x6e, 0x73, 0x8b, 0xef, 0x47, 0xb2, 0xcf, 0xa1, 0x57, 0x42, 0x59, 0x25, 0xf3, 0xdc, + 0x0c, 0x9f, 0xcd, 0x96, 0xf9, 0xcd, 0x2d, 0xfe, 0x9f, 0x58, 0x36, 0x83, 0x13, 0x4c, 0x53, 0x99, + 0x6e, 0xc9, 0x9a, 0x44, 0xf6, 0xe6, 0x3e, 0xd9, 0xac, 0xea, 0x34, 0xb7, 0xf8, 0x6e, 0xd4, 0xdd, + 0x16, 0x1c, 0xfe, 0x60, 0x52, 0xe5, 0xfe, 0x64, 0x43, 0x6f, 0x3f, 0x1f, 0xe6, 0xbd, 0x98, 0x7c, + 0x64, 0x8d, 0xd6, 0xe1, 0x99, 0xc1, 0x3e, 0x82, 0x56, 0x56, 0xc9, 0xf2, 0x05, 0x56, 0xab, 0x2b, + 0x9e, 0xdc, 0x4f, 0x11, 0xb3, 0x02, 0x7f, 0x1d, 0xe8, 0xd5, 0xc2, 0xe7, 0x85, 0x3f, 0x73, 0xe1, + 0x58, 0xc5, 0x22, 0x51, 0x2b, 0xa9, 0xbf, 0x14, 0x7a, 0xe5, 0x1c, 0x10, 0xef, 0x0e, 0xe6, 0xfe, + 0x6c, 0xc3, 0xed, 0xda, 0xb4, 0xbe, 0x18, 0x39, 0xbf, 0xd8, 0x45, 0x7b, 0xed, 0xd7, 0xe5, 0xc5, + 0xe8, 0x79, 0x17, 0x5e, 0xae, 0xa9, 0xac, 0xd1, 0x42, 0x95, 0xcd, 0x5f, 0x72, 0x66, 0xb8, 0xbf, + 0xdb, 0xd0, 0xa5, 0x6e, 0xc8, 0xdf, 0x58, 0x1f, 0xda, 0x81, 0x8f, 0xb1, 0x0e, 0xf4, 0x26, 0x9f, + 0xaa, 0x5b, 0x9b, 0xbd, 0x01, 0x1d, 0x1d, 0x44, 0xa8, 0xb4, 0x88, 0x12, 0x6a, 0xf4, 0x03, 0x5e, + 0x02, 0x66, 0x97, 0x86, 0xc3, 0xfd, 0x4d, 0x92, 0x35, 0x6e, 0x87, 0x97, 0x00, 0x7b, 0x1b, 0x4e, + 0x53, 0x4c, 0xc2, 0xc0, 0x13, 0x3a, 0x90, 0xf1, 0x3d, 0xdc, 0x50, 0x3b, 0x36, 0xf9, 0x1e, 0x6a, + 0x26, 0xa8, 0x42, 0xcc, 0x5e, 0xf1, 0x31, 0xa7, 0xf5, 0x3b, 0x7d, 0x68, 0xcf, 0xd2, 0xf4, 0x42, + 0xfa, 0xa8, 0xd8, 0x29, 0xc0, 0x83, 0x18, 0x7f, 0x4c, 0xd0, 0xd3, 0xe8, 0xf7, 0xac, 0xe9, 0x6f, + 0x36, 0x1c, 0x92, 0x7e, 0xf6, 0x29, 0xb4, 0x8b, 0xe1, 0xc6, 0x5e, 0xab, 0x1b, 0x78, 0xd4, 0x22, + 0xfd, 0x7e, 0xed, 0x2c, 0xcc, 0x52, 0x74, 0x09, 0x47, 0x57, 0x3a, 0x45, 0x11, 0xb1, 0xd7, 0xeb, + 0xa6, 0x59, 0x3e, 0x15, 0xfb, 0xcf, 0xdb, 0x1c, 0xd9, 0xef, 0xd9, 0x77, 0xcf, 0xff, 0xbc, 0x1e, + 0xd8, 0x4f, 0xaf, 0x07, 0xf6, 0x3f, 0xd7, 0x03, 0xfb, 0xd7, 0x9b, 0x81, 0xf5, 0xf4, 0x66, 0x60, + 0xfd, 0x75, 0x33, 0xb0, 0xbe, 0x79, 0xeb, 0x7f, 0xff, 0x82, 0x1f, 0x1e, 0xd1, 0xe7, 0xfd, 0x7f, + 0x03, 0x00, 0x00, 0xff, 0xff, 0x7b, 0x1f, 0x02, 0x55, 0xae, 0x07, 0x00, 0x00, } func (m *HeadSyncRange) Marshal() (dAtA []byte, err error) { @@ -1386,6 +1468,60 @@ func (m *ObjectErrorResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *SpaceHeader) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *SpaceHeader) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *SpaceHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Seed) > 0 { + i -= len(m.Seed) + copy(dAtA[i:], m.Seed) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Seed))) + i-- + dAtA[i] = 0x2a + } + if m.ReplicationKey != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.ReplicationKey)) + i-- + dAtA[i] = 0x20 + } + if len(m.SpaceType) > 0 { + i -= len(m.SpaceType) + copy(dAtA[i:], m.SpaceType) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.SpaceType))) + i-- + dAtA[i] = 0x1a + } + if m.Timestamp != 0 { + i = encodeVarintSpacesync(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x10 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintSpacesync(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func encodeVarintSpacesync(dAtA []byte, offset int, v uint64) int { offset -= sovSpacesync(v) base := offset @@ -1671,6 +1807,33 @@ func (m *ObjectErrorResponse) Size() (n int) { return n } +func (m *SpaceHeader) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovSpacesync(uint64(m.Timestamp)) + } + l = len(m.SpaceType) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + if m.ReplicationKey != 0 { + n += 1 + sovSpacesync(uint64(m.ReplicationKey)) + } + l = len(m.Seed) + if l > 0 { + n += 1 + l + sovSpacesync(uint64(l)) + } + return n +} + func sovSpacesync(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } @@ -2362,7 +2525,7 @@ func (m *ObjectSyncMessage) Unmarshal(dAtA []byte) error { return io.ErrUnexpectedEOF } if m.TreeHeader == nil { - m.TreeHeader = &aclpb.TreeHeader{} + m.TreeHeader = &treechangeproto.RootChange{} } if err := m.TreeHeader.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err @@ -2733,7 +2896,7 @@ func (m *ObjectHeadUpdate) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -2881,7 +3044,7 @@ func (m *ObjectFullSyncRequest) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3029,7 +3192,7 @@ func (m *ObjectFullSyncResponse) Unmarshal(dAtA []byte) error { if postIndex > l { return io.ErrUnexpectedEOF } - m.Changes = append(m.Changes, &aclpb.RawTreeChangeWithId{}) + m.Changes = append(m.Changes, &treechangeproto.RawTreeChangeWithId{}) if err := m.Changes[len(m.Changes)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { return err } @@ -3169,6 +3332,194 @@ func (m *ObjectErrorResponse) Unmarshal(dAtA []byte) error { } return nil } +func (m *SpaceHeader) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: SpaceHeader: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: SpaceHeader: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field ReplicationKey", wireType) + } + m.ReplicationKey = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.ReplicationKey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowSpacesync + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthSpacesync + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthSpacesync + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Seed = append(m.Seed[:0], dAtA[iNdEx:postIndex]...) + if m.Seed == nil { + m.Seed = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipSpacesync(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthSpacesync + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func skipSpacesync(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 diff --git a/common/commonspace/syncservice/synchandler.go b/common/commonspace/syncservice/synchandler.go index 12798bc3..0d3be042 100644 --- a/common/commonspace/syncservice/synchandler.go +++ b/common/commonspace/syncservice/synchandler.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" ) diff --git a/common/commonspace/syncservice/syncservice.go b/common/commonspace/syncservice/syncservice.go index ed88f8ab..c7039a73 100644 --- a/common/commonspace/syncservice/syncservice.go +++ b/common/commonspace/syncservice/syncservice.go @@ -5,7 +5,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/cache" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/nodeconf" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "time" ) diff --git a/common/commonspace/synctree/synctree.go b/common/commonspace/synctree/synctree.go index 7e4341e2..149c7c9b 100644 --- a/common/commonspace/synctree/synctree.go +++ b/common/commonspace/synctree/synctree.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/spacesyncproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/commonspace/syncservice" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/go.mod b/go.mod index 47537c53..9c60aa54 100644 --- a/go.mod +++ b/go.mod @@ -3,6 +3,7 @@ module github.com/anytypeio/go-anytype-infrastructure-experiments go 1.18 require ( + github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 github.com/awalterschulze/gographviz v0.0.0-20190522210029-fa59802746ab github.com/cespare/xxhash v1.1.0 github.com/goccy/go-graphviz v0.0.9 @@ -16,6 +17,7 @@ require ( github.com/multiformats/go-multihash v0.1.0 github.com/stretchr/testify v1.8.0 github.com/zeebo/blake3 v0.2.3 + github.com/zeebo/errs v1.3.0 go.uber.org/zap v1.21.0 gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 gopkg.in/yaml.v3 v3.0.1 @@ -24,7 +26,6 @@ require ( require ( github.com/OneOfOne/xxhash v1.2.8 // indirect - github.com/anytypeio/go-chash v0.0.0-20220629194632-4ad1154fe232 // indirect github.com/btcsuite/btcd v0.22.1 // indirect github.com/btcsuite/btcd/btcec/v2 v2.1.3 // indirect github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect @@ -32,7 +33,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 // indirect github.com/fogleman/gg v1.3.0 // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/golang/protobuf v1.5.2 // indirect github.com/klauspost/cpuid/v2 v2.0.12 // indirect github.com/libp2p/go-buffer-pool v0.0.2 // indirect github.com/libp2p/go-openssl v0.0.7 // indirect @@ -47,13 +47,11 @@ require ( github.com/pmezard/go-difflib v1.0.0 // indirect github.com/spacemonkeygo/spacelog v0.0.0-20180420211403-2296661a0572 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/zeebo/errs v1.3.0 // indirect go.uber.org/atomic v1.9.0 // indirect go.uber.org/multierr v1.8.0 // indirect golang.org/x/crypto v0.0.0-20220411220226-7b82a4e95df4 // indirect golang.org/x/image v0.0.0-20200119044424-58c23975cae1 // indirect golang.org/x/sys v0.0.0-20220422013727-9388b58f7150 // indirect - google.golang.org/protobuf v1.28.1 // indirect gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect lukechampine.com/blake3 v1.1.6 // indirect diff --git a/go.sum b/go.sum index ba61ef8a..34c05834 100644 --- a/go.sum +++ b/go.sum @@ -32,10 +32,6 @@ github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.2 h1:ROPKBNFfQgOUMifHyP+KYbvpjbdoFNs+aK7DXlji0Tw= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/huandu/go-assert v1.1.5 h1:fjemmA7sSfYHJD7CUqs9qTwwfdNAx7/j2/ZlHXzNB3c= github.com/huandu/go-assert v1.1.5/go.mod h1:yOLvuqZwmcHIC5rIzrBhT7D3Q9c3GFnd0JrPVhn/06U= github.com/huandu/skiplist v1.2.0 h1:gox56QD77HzSC0w+Ws3MH3iie755GBJU1OER3h5VsYw= @@ -117,8 +113,6 @@ github.com/zeebo/assert v1.1.0/go.mod h1:Pq9JiuJQpG8JLJdtkwrJESF0Foym2/D9XMU5ciN github.com/zeebo/assert v1.3.0 h1:g7C04CbJuIDKNPFHmsk4hwZDO5O+kntRxzaUoNXj+IQ= github.com/zeebo/blake3 v0.2.3 h1:TFoLXsjeXqRNFxSbk35Dk4YtszE/MQQGK10BH4ptoTg= github.com/zeebo/blake3 v0.2.3/go.mod h1:mjJjZpnsyIVtVgTOSpJ9vmRE4wgDeyt2HU3qXvvKCaQ= -github.com/zeebo/errs v1.2.2 h1:5NFypMTuSdoySVTqlNs1dEoU21QVamMQJxW/Fii5O7g= -github.com/zeebo/errs v1.2.2/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/errs v1.3.0 h1:hmiaKqgYZzcVgRL1Vkc1Mn2914BbzB0IBxs+ebeutGs= github.com/zeebo/errs v1.3.0/go.mod h1:sgbWHsvVuTPHcqJJGQ1WhI5KbWlHYz+2+2C/LSEtCw4= github.com/zeebo/pcg v1.0.1 h1:lyqfGeWiv4ahac6ttHs+I5hwtH/+1mrhlCtVNQM2kHo= @@ -184,10 +178,6 @@ golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.1 h1:d0NfwRgPtno5B1Wa6L2DAG+KivqkdutMf1UhdNx175w= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= diff --git a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto b/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto deleted file mode 100644 index 5d69e94f..00000000 --- a/pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +++ /dev/null @@ -1,143 +0,0 @@ -syntax = "proto3"; -package acl; -option go_package = "pkg/acl/aclchanges/aclpb"; - -// ACL protos - -message RawACLRecord { - bytes payload = 1; - bytes signature = 2; - string id = 3; // this field is only used on user side for convenience, it should be empty when saving to db -} - -message ACLContentValue { - oneof value { - ACLUserAdd userAdd = 1; - ACLUserRemove userRemove = 2; - ACLUserPermissionChange userPermissionChange = 3; - ACLUserInvite userInvite = 4; - ACLUserJoin userJoin = 5; - ACLUserConfirm userConfirm = 6; - } -} - -message ACLData { - repeated ACLContentValue aclContent = 1; -} - -message ACLState { - repeated uint64 readKeyHashes = 1; - repeated ACLUserState userStates = 2; - map invites = 3; // TODO: later - // repeated string unconfirmedUsers = 4; // TODO: later -} - -message ACLUserState { - bytes identity = 1; - bytes encryptionKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know - ACLUserPermissions permissions = 4; - bool isConfirmed = 5; -} - -// we already know identity and encryptionKey -message ACLUserAdd { - bytes identity = 1; // public signing key - bytes encryptionKey = 2; // public encryption key - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - ACLUserPermissions permissions = 4; -} - -// TODO: this is not used as of now -message ACLUserConfirm { // not needed for read permissions - bytes identity = 1; // not needed - string userAddId = 2; -} - -message ACLUserInvite { - bytes acceptPublicKey = 1; - bytes encryptPublicKey = 2; - repeated bytes encryptedReadKeys = 3; // all read keys that we know for the user - ACLUserPermissions permissions = 4; - string inviteId = 5; -} - -message ACLUserJoin { - bytes identity = 1; - bytes encryptionKey = 2; - bytes acceptSignature = 3; // sign acceptPublicKey - string userInviteId = 4; - repeated bytes encryptedReadKeys = 5; // the idea is that user should itself reencrypt the keys with the pub key -} - -message ACLUserRemove { - bytes identity = 1; - repeated ACLReadKeyReplace readKeyReplaces = 3; // new read key encrypted for all users -} - -message ACLReadKeyReplace { - bytes identity = 1; - bytes encryptionKey = 2; - bytes encryptedReadKey = 3; -} - -message ACLUserPermissionChange { - bytes identity = 1; - ACLUserPermissions permissions = 2; -} - -enum ACLUserPermissions { - Admin = 0; - Writer = 1; - Reader = 2; - Removed = 3; -} - -message ACLRecord { - string prevId = 1; - bytes identity = 2; - bytes data = 3; - uint64 currentReadKeyHash = 4; - int64 timestamp = 5; -} - -message ACLHeader { - string firstId = 1; - bytes identity = 2; // the identity of the creator -} - -// Tree protos - -message RawTreeChange { - bytes payload = 1; - bytes signature = 2; -} - -message RawTreeChangeWithId { - bytes rawChange = 1; - string id = 2; -} - -message TreeChange { - repeated string treeHeadIds = 1; - string aclHeadId = 2; - string snapshotBaseId = 3; - bytes changesData = 4; - uint64 currentReadKeyHash = 5; - int64 timestamp = 6; - bytes identity = 7; - bool isSnapshot = 8; -} - -enum TreeHeaderType { - Object = 0; - Space = 1; -} - -message TreeHeader { - string firstId = 1; - string aclId = 2; - TreeHeaderType treeHeaderType = 3; - bytes identity = 4; - bytes data = 5; // this should be reserved for the client to add the data it needs -} diff --git a/pkg/acl/aclchanges/change.go b/pkg/acl/aclchanges/change.go deleted file mode 100644 index 3d3b4376..00000000 --- a/pkg/acl/aclchanges/change.go +++ /dev/null @@ -1,12 +0,0 @@ -package aclchanges - -import ( - "github.com/gogo/protobuf/proto" -) - -type Change interface { - ProtoChange() proto.Marshaler - DecryptedChangeContent() []byte - Signature() []byte - CID() string -} diff --git a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go b/pkg/acl/aclrecordproto/aclrecord.pb.go similarity index 60% rename from pkg/acl/aclchanges/aclpb/aclchanges.pb.go rename to pkg/acl/aclrecordproto/aclrecord.pb.go index 60437c7e..69035b70 100644 --- a/pkg/acl/aclchanges/aclpb/aclchanges.pb.go +++ b/pkg/acl/aclrecordproto/aclrecord.pb.go @@ -1,7 +1,7 @@ // Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: pkg/acl/aclchanges/aclpb/protos/aclchanges.proto +// source: pkg/acl/aclrecordproto/protos/aclrecord.proto -package aclpb +package aclrecordproto import ( fmt "fmt" @@ -25,24 +25,21 @@ const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package type ACLUserPermissions int32 const ( - ACLUserPermissions_Admin ACLUserPermissions = 0 - ACLUserPermissions_Writer ACLUserPermissions = 1 - ACLUserPermissions_Reader ACLUserPermissions = 2 - ACLUserPermissions_Removed ACLUserPermissions = 3 + ACLUserPermissions_Admin ACLUserPermissions = 0 + ACLUserPermissions_Writer ACLUserPermissions = 1 + ACLUserPermissions_Reader ACLUserPermissions = 2 ) var ACLUserPermissions_name = map[int32]string{ 0: "Admin", 1: "Writer", 2: "Reader", - 3: "Removed", } var ACLUserPermissions_value = map[string]int32{ - "Admin": 0, - "Writer": 1, - "Reader": 2, - "Removed": 3, + "Admin": 0, + "Writer": 1, + "Reader": 2, } func (x ACLUserPermissions) String() string { @@ -50,45 +47,19 @@ func (x ACLUserPermissions) String() string { } func (ACLUserPermissions) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{0} -} - -type TreeHeaderType int32 - -const ( - TreeHeaderType_Object TreeHeaderType = 0 - TreeHeaderType_Space TreeHeaderType = 1 -) - -var TreeHeaderType_name = map[int32]string{ - 0: "Object", - 1: "Space", -} - -var TreeHeaderType_value = map[string]int32{ - "Object": 0, - "Space": 1, -} - -func (x TreeHeaderType) String() string { - return proto.EnumName(TreeHeaderType_name, int32(x)) -} - -func (TreeHeaderType) EnumDescriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{1} + return fileDescriptor_14abe0d1b4206d54, []int{0} } type RawACLRecord struct { Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` - Id string `protobuf:"bytes,3,opt,name=id,proto3" json:"id,omitempty"` } func (m *RawACLRecord) Reset() { *m = RawACLRecord{} } func (m *RawACLRecord) String() string { return proto.CompactTextString(m) } func (*RawACLRecord) ProtoMessage() {} func (*RawACLRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{0} + return fileDescriptor_14abe0d1b4206d54, []int{0} } func (m *RawACLRecord) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -131,13 +102,210 @@ func (m *RawACLRecord) GetSignature() []byte { return nil } -func (m *RawACLRecord) GetId() string { +type RawACLRecordWithId struct { + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *RawACLRecordWithId) Reset() { *m = RawACLRecordWithId{} } +func (m *RawACLRecordWithId) String() string { return proto.CompactTextString(m) } +func (*RawACLRecordWithId) ProtoMessage() {} +func (*RawACLRecordWithId) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{1} +} +func (m *RawACLRecordWithId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawACLRecordWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawACLRecordWithId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RawACLRecordWithId) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawACLRecordWithId.Merge(m, src) +} +func (m *RawACLRecordWithId) XXX_Size() int { + return m.Size() +} +func (m *RawACLRecordWithId) XXX_DiscardUnknown() { + xxx_messageInfo_RawACLRecordWithId.DiscardUnknown(m) +} + +var xxx_messageInfo_RawACLRecordWithId proto.InternalMessageInfo + +func (m *RawACLRecordWithId) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + +func (m *RawACLRecordWithId) GetId() string { if m != nil { return m.Id } return "" } +type ACLRecord struct { + PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` + Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` + Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` + CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` +} + +func (m *ACLRecord) Reset() { *m = ACLRecord{} } +func (m *ACLRecord) String() string { return proto.CompactTextString(m) } +func (*ACLRecord) ProtoMessage() {} +func (*ACLRecord) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{2} +} +func (m *ACLRecord) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLRecord.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLRecord) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLRecord.Merge(m, src) +} +func (m *ACLRecord) XXX_Size() int { + return m.Size() +} +func (m *ACLRecord) XXX_DiscardUnknown() { + xxx_messageInfo_ACLRecord.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLRecord proto.InternalMessageInfo + +func (m *ACLRecord) GetPrevId() string { + if m != nil { + return m.PrevId + } + return "" +} + +func (m *ACLRecord) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *ACLRecord) GetData() []byte { + if m != nil { + return m.Data + } + return nil +} + +func (m *ACLRecord) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *ACLRecord) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +type ACLRoot struct { + Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` + EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` + SpaceId string `protobuf:"bytes,3,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + EncryptedReadKey []byte `protobuf:"bytes,4,opt,name=encryptedReadKey,proto3" json:"encryptedReadKey,omitempty"` + DerivationScheme string `protobuf:"bytes,5,opt,name=derivationScheme,proto3" json:"derivationScheme,omitempty"` +} + +func (m *ACLRoot) Reset() { *m = ACLRoot{} } +func (m *ACLRoot) String() string { return proto.CompactTextString(m) } +func (*ACLRoot) ProtoMessage() {} +func (*ACLRoot) Descriptor() ([]byte, []int) { + return fileDescriptor_14abe0d1b4206d54, []int{3} +} +func (m *ACLRoot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *ACLRoot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_ACLRoot.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *ACLRoot) XXX_Merge(src proto.Message) { + xxx_messageInfo_ACLRoot.Merge(m, src) +} +func (m *ACLRoot) XXX_Size() int { + return m.Size() +} +func (m *ACLRoot) XXX_DiscardUnknown() { + xxx_messageInfo_ACLRoot.DiscardUnknown(m) +} + +var xxx_messageInfo_ACLRoot proto.InternalMessageInfo + +func (m *ACLRoot) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *ACLRoot) GetEncryptionKey() []byte { + if m != nil { + return m.EncryptionKey + } + return nil +} + +func (m *ACLRoot) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *ACLRoot) GetEncryptedReadKey() []byte { + if m != nil { + return m.EncryptedReadKey + } + return nil +} + +func (m *ACLRoot) GetDerivationScheme() string { + if m != nil { + return m.DerivationScheme + } + return "" +} + type ACLContentValue struct { // Types that are valid to be assigned to Value: // *ACLContentValue_UserAdd @@ -145,7 +313,6 @@ type ACLContentValue struct { // *ACLContentValue_UserPermissionChange // *ACLContentValue_UserInvite // *ACLContentValue_UserJoin - // *ACLContentValue_UserConfirm Value isACLContentValue_Value `protobuf_oneof:"value"` } @@ -153,7 +320,7 @@ func (m *ACLContentValue) Reset() { *m = ACLContentValue{} } func (m *ACLContentValue) String() string { return proto.CompactTextString(m) } func (*ACLContentValue) ProtoMessage() {} func (*ACLContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{1} + return fileDescriptor_14abe0d1b4206d54, []int{4} } func (m *ACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -203,16 +370,12 @@ type ACLContentValue_UserInvite struct { type ACLContentValue_UserJoin struct { UserJoin *ACLUserJoin `protobuf:"bytes,5,opt,name=userJoin,proto3,oneof" json:"userJoin,omitempty"` } -type ACLContentValue_UserConfirm struct { - UserConfirm *ACLUserConfirm `protobuf:"bytes,6,opt,name=userConfirm,proto3,oneof" json:"userConfirm,omitempty"` -} func (*ACLContentValue_UserAdd) isACLContentValue_Value() {} func (*ACLContentValue_UserRemove) isACLContentValue_Value() {} func (*ACLContentValue_UserPermissionChange) isACLContentValue_Value() {} func (*ACLContentValue_UserInvite) isACLContentValue_Value() {} func (*ACLContentValue_UserJoin) isACLContentValue_Value() {} -func (*ACLContentValue_UserConfirm) isACLContentValue_Value() {} func (m *ACLContentValue) GetValue() isACLContentValue_Value { if m != nil { @@ -256,13 +419,6 @@ func (m *ACLContentValue) GetUserJoin() *ACLUserJoin { return nil } -func (m *ACLContentValue) GetUserConfirm() *ACLUserConfirm { - if x, ok := m.GetValue().(*ACLContentValue_UserConfirm); ok { - return x.UserConfirm - } - return nil -} - // XXX_OneofWrappers is for the internal use of the proto package. func (*ACLContentValue) XXX_OneofWrappers() []interface{} { return []interface{}{ @@ -271,7 +427,6 @@ func (*ACLContentValue) XXX_OneofWrappers() []interface{} { (*ACLContentValue_UserPermissionChange)(nil), (*ACLContentValue_UserInvite)(nil), (*ACLContentValue_UserJoin)(nil), - (*ACLContentValue_UserConfirm)(nil), } } @@ -283,7 +438,7 @@ func (m *ACLData) Reset() { *m = ACLData{} } func (m *ACLData) String() string { return proto.CompactTextString(m) } func (*ACLData) ProtoMessage() {} func (*ACLData) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{2} + return fileDescriptor_14abe0d1b4206d54, []int{5} } func (m *ACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -329,7 +484,7 @@ func (m *ACLState) Reset() { *m = ACLState{} } func (m *ACLState) String() string { return proto.CompactTextString(m) } func (*ACLState) ProtoMessage() {} func (*ACLState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{3} + return fileDescriptor_14abe0d1b4206d54, []int{6} } func (m *ACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -383,7 +538,7 @@ type ACLUserState struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` IsConfirmed bool `protobuf:"varint,5,opt,name=isConfirmed,proto3" json:"isConfirmed,omitempty"` } @@ -391,7 +546,7 @@ func (m *ACLUserState) Reset() { *m = ACLUserState{} } func (m *ACLUserState) String() string { return proto.CompactTextString(m) } func (*ACLUserState) ProtoMessage() {} func (*ACLUserState) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{4} + return fileDescriptor_14abe0d1b4206d54, []int{7} } func (m *ACLUserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -455,19 +610,18 @@ func (m *ACLUserState) GetIsConfirmed() bool { return false } -// we already know identity and encryptionKey type ACLUserAdd struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` } func (m *ACLUserAdd) Reset() { *m = ACLUserAdd{} } func (m *ACLUserAdd) String() string { return proto.CompactTextString(m) } func (*ACLUserAdd) ProtoMessage() {} func (*ACLUserAdd) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{5} + return fileDescriptor_14abe0d1b4206d54, []int{8} } func (m *ACLUserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -524,64 +678,11 @@ func (m *ACLUserAdd) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } -// TODO: this is not used as of now -type ACLUserConfirm struct { - Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - UserAddId string `protobuf:"bytes,2,opt,name=userAddId,proto3" json:"userAddId,omitempty"` -} - -func (m *ACLUserConfirm) Reset() { *m = ACLUserConfirm{} } -func (m *ACLUserConfirm) String() string { return proto.CompactTextString(m) } -func (*ACLUserConfirm) ProtoMessage() {} -func (*ACLUserConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{6} -} -func (m *ACLUserConfirm) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLUserConfirm) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLUserConfirm.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ACLUserConfirm) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLUserConfirm.Merge(m, src) -} -func (m *ACLUserConfirm) XXX_Size() int { - return m.Size() -} -func (m *ACLUserConfirm) XXX_DiscardUnknown() { - xxx_messageInfo_ACLUserConfirm.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLUserConfirm proto.InternalMessageInfo - -func (m *ACLUserConfirm) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *ACLUserConfirm) GetUserAddId() string { - if m != nil { - return m.UserAddId - } - return "" -} - type ACLUserInvite struct { AcceptPublicKey []byte `protobuf:"bytes,1,opt,name=acceptPublicKey,proto3" json:"acceptPublicKey,omitempty"` EncryptPublicKey []byte `protobuf:"bytes,2,opt,name=encryptPublicKey,proto3" json:"encryptPublicKey,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,3,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,4,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` InviteId string `protobuf:"bytes,5,opt,name=inviteId,proto3" json:"inviteId,omitempty"` } @@ -589,7 +690,7 @@ func (m *ACLUserInvite) Reset() { *m = ACLUserInvite{} } func (m *ACLUserInvite) String() string { return proto.CompactTextString(m) } func (*ACLUserInvite) ProtoMessage() {} func (*ACLUserInvite) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{7} + return fileDescriptor_14abe0d1b4206d54, []int{9} } func (m *ACLUserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -657,7 +758,7 @@ type ACLUserJoin struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` EncryptionKey []byte `protobuf:"bytes,2,opt,name=encryptionKey,proto3" json:"encryptionKey,omitempty"` AcceptSignature []byte `protobuf:"bytes,3,opt,name=acceptSignature,proto3" json:"acceptSignature,omitempty"` - UserInviteId string `protobuf:"bytes,4,opt,name=userInviteId,proto3" json:"userInviteId,omitempty"` + InviteId string `protobuf:"bytes,4,opt,name=inviteId,proto3" json:"inviteId,omitempty"` EncryptedReadKeys [][]byte `protobuf:"bytes,5,rep,name=encryptedReadKeys,proto3" json:"encryptedReadKeys,omitempty"` } @@ -665,7 +766,7 @@ func (m *ACLUserJoin) Reset() { *m = ACLUserJoin{} } func (m *ACLUserJoin) String() string { return proto.CompactTextString(m) } func (*ACLUserJoin) ProtoMessage() {} func (*ACLUserJoin) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{8} + return fileDescriptor_14abe0d1b4206d54, []int{10} } func (m *ACLUserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -715,9 +816,9 @@ func (m *ACLUserJoin) GetAcceptSignature() []byte { return nil } -func (m *ACLUserJoin) GetUserInviteId() string { +func (m *ACLUserJoin) GetInviteId() string { if m != nil { - return m.UserInviteId + return m.InviteId } return "" } @@ -738,7 +839,7 @@ func (m *ACLUserRemove) Reset() { *m = ACLUserRemove{} } func (m *ACLUserRemove) String() string { return proto.CompactTextString(m) } func (*ACLUserRemove) ProtoMessage() {} func (*ACLUserRemove) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{9} + return fileDescriptor_14abe0d1b4206d54, []int{11} } func (m *ACLUserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -791,7 +892,7 @@ func (m *ACLReadKeyReplace) Reset() { *m = ACLReadKeyReplace{} } func (m *ACLReadKeyReplace) String() string { return proto.CompactTextString(m) } func (*ACLReadKeyReplace) ProtoMessage() {} func (*ACLReadKeyReplace) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{10} + return fileDescriptor_14abe0d1b4206d54, []int{12} } func (m *ACLReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -843,14 +944,14 @@ func (m *ACLReadKeyReplace) GetEncryptedReadKey() []byte { type ACLUserPermissionChange struct { Identity []byte `protobuf:"bytes,1,opt,name=identity,proto3" json:"identity,omitempty"` - Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=acl.ACLUserPermissions" json:"permissions,omitempty"` + Permissions ACLUserPermissions `protobuf:"varint,2,opt,name=permissions,proto3,enum=aclrecord.ACLUserPermissions" json:"permissions,omitempty"` } func (m *ACLUserPermissionChange) Reset() { *m = ACLUserPermissionChange{} } func (m *ACLUserPermissionChange) String() string { return proto.CompactTextString(m) } func (*ACLUserPermissionChange) ProtoMessage() {} func (*ACLUserPermissionChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{11} + return fileDescriptor_14abe0d1b4206d54, []int{13} } func (m *ACLUserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -893,512 +994,85 @@ func (m *ACLUserPermissionChange) GetPermissions() ACLUserPermissions { return ACLUserPermissions_Admin } -type ACLRecord struct { - PrevId string `protobuf:"bytes,1,opt,name=prevId,proto3" json:"prevId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` - Data []byte `protobuf:"bytes,3,opt,name=data,proto3" json:"data,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,4,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,5,opt,name=timestamp,proto3" json:"timestamp,omitempty"` -} - -func (m *ACLRecord) Reset() { *m = ACLRecord{} } -func (m *ACLRecord) String() string { return proto.CompactTextString(m) } -func (*ACLRecord) ProtoMessage() {} -func (*ACLRecord) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{12} -} -func (m *ACLRecord) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLRecord) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLRecord.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ACLRecord) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLRecord.Merge(m, src) -} -func (m *ACLRecord) XXX_Size() int { - return m.Size() -} -func (m *ACLRecord) XXX_DiscardUnknown() { - xxx_messageInfo_ACLRecord.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLRecord proto.InternalMessageInfo - -func (m *ACLRecord) GetPrevId() string { - if m != nil { - return m.PrevId - } - return "" -} - -func (m *ACLRecord) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *ACLRecord) GetData() []byte { - if m != nil { - return m.Data - } - return nil -} - -func (m *ACLRecord) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *ACLRecord) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -type ACLHeader struct { - FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - Identity []byte `protobuf:"bytes,2,opt,name=identity,proto3" json:"identity,omitempty"` -} - -func (m *ACLHeader) Reset() { *m = ACLHeader{} } -func (m *ACLHeader) String() string { return proto.CompactTextString(m) } -func (*ACLHeader) ProtoMessage() {} -func (*ACLHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{13} -} -func (m *ACLHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *ACLHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_ACLHeader.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *ACLHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_ACLHeader.Merge(m, src) -} -func (m *ACLHeader) XXX_Size() int { - return m.Size() -} -func (m *ACLHeader) XXX_DiscardUnknown() { - xxx_messageInfo_ACLHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_ACLHeader proto.InternalMessageInfo - -func (m *ACLHeader) GetFirstId() string { - if m != nil { - return m.FirstId - } - return "" -} - -func (m *ACLHeader) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -type RawTreeChange struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` - Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` -} - -func (m *RawTreeChange) Reset() { *m = RawTreeChange{} } -func (m *RawTreeChange) String() string { return proto.CompactTextString(m) } -func (*RawTreeChange) ProtoMessage() {} -func (*RawTreeChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{14} -} -func (m *RawTreeChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RawTreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RawTreeChange.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RawTreeChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawTreeChange.Merge(m, src) -} -func (m *RawTreeChange) XXX_Size() int { - return m.Size() -} -func (m *RawTreeChange) XXX_DiscardUnknown() { - xxx_messageInfo_RawTreeChange.DiscardUnknown(m) -} - -var xxx_messageInfo_RawTreeChange proto.InternalMessageInfo - -func (m *RawTreeChange) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -func (m *RawTreeChange) GetSignature() []byte { - if m != nil { - return m.Signature - } - return nil -} - -type RawTreeChangeWithId struct { - RawChange []byte `protobuf:"bytes,1,opt,name=rawChange,proto3" json:"rawChange,omitempty"` - Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` -} - -func (m *RawTreeChangeWithId) Reset() { *m = RawTreeChangeWithId{} } -func (m *RawTreeChangeWithId) String() string { return proto.CompactTextString(m) } -func (*RawTreeChangeWithId) ProtoMessage() {} -func (*RawTreeChangeWithId) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{15} -} -func (m *RawTreeChangeWithId) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *RawTreeChangeWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_RawTreeChangeWithId.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *RawTreeChangeWithId) XXX_Merge(src proto.Message) { - xxx_messageInfo_RawTreeChangeWithId.Merge(m, src) -} -func (m *RawTreeChangeWithId) XXX_Size() int { - return m.Size() -} -func (m *RawTreeChangeWithId) XXX_DiscardUnknown() { - xxx_messageInfo_RawTreeChangeWithId.DiscardUnknown(m) -} - -var xxx_messageInfo_RawTreeChangeWithId proto.InternalMessageInfo - -func (m *RawTreeChangeWithId) GetRawChange() []byte { - if m != nil { - return m.RawChange - } - return nil -} - -func (m *RawTreeChangeWithId) GetId() string { - if m != nil { - return m.Id - } - return "" -} - -type TreeChange struct { - TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` - AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` - SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` - ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` - IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` -} - -func (m *TreeChange) Reset() { *m = TreeChange{} } -func (m *TreeChange) String() string { return proto.CompactTextString(m) } -func (*TreeChange) ProtoMessage() {} -func (*TreeChange) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{16} -} -func (m *TreeChange) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TreeChange.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TreeChange) XXX_Merge(src proto.Message) { - xxx_messageInfo_TreeChange.Merge(m, src) -} -func (m *TreeChange) XXX_Size() int { - return m.Size() -} -func (m *TreeChange) XXX_DiscardUnknown() { - xxx_messageInfo_TreeChange.DiscardUnknown(m) -} - -var xxx_messageInfo_TreeChange proto.InternalMessageInfo - -func (m *TreeChange) GetTreeHeadIds() []string { - if m != nil { - return m.TreeHeadIds - } - return nil -} - -func (m *TreeChange) GetAclHeadId() string { - if m != nil { - return m.AclHeadId - } - return "" -} - -func (m *TreeChange) GetSnapshotBaseId() string { - if m != nil { - return m.SnapshotBaseId - } - return "" -} - -func (m *TreeChange) GetChangesData() []byte { - if m != nil { - return m.ChangesData - } - return nil -} - -func (m *TreeChange) GetCurrentReadKeyHash() uint64 { - if m != nil { - return m.CurrentReadKeyHash - } - return 0 -} - -func (m *TreeChange) GetTimestamp() int64 { - if m != nil { - return m.Timestamp - } - return 0 -} - -func (m *TreeChange) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *TreeChange) GetIsSnapshot() bool { - if m != nil { - return m.IsSnapshot - } - return false -} - -type TreeHeader struct { - FirstId string `protobuf:"bytes,1,opt,name=firstId,proto3" json:"firstId,omitempty"` - AclId string `protobuf:"bytes,2,opt,name=aclId,proto3" json:"aclId,omitempty"` - TreeHeaderType TreeHeaderType `protobuf:"varint,3,opt,name=treeHeaderType,proto3,enum=acl.TreeHeaderType" json:"treeHeaderType,omitempty"` - Identity []byte `protobuf:"bytes,4,opt,name=identity,proto3" json:"identity,omitempty"` - Data []byte `protobuf:"bytes,5,opt,name=data,proto3" json:"data,omitempty"` -} - -func (m *TreeHeader) Reset() { *m = TreeHeader{} } -func (m *TreeHeader) String() string { return proto.CompactTextString(m) } -func (*TreeHeader) ProtoMessage() {} -func (*TreeHeader) Descriptor() ([]byte, []int) { - return fileDescriptor_37a022c841a51877, []int{17} -} -func (m *TreeHeader) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *TreeHeader) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_TreeHeader.Marshal(b, m, deterministic) - } else { - b = b[:cap(b)] - n, err := m.MarshalToSizedBuffer(b) - if err != nil { - return nil, err - } - return b[:n], nil - } -} -func (m *TreeHeader) XXX_Merge(src proto.Message) { - xxx_messageInfo_TreeHeader.Merge(m, src) -} -func (m *TreeHeader) XXX_Size() int { - return m.Size() -} -func (m *TreeHeader) XXX_DiscardUnknown() { - xxx_messageInfo_TreeHeader.DiscardUnknown(m) -} - -var xxx_messageInfo_TreeHeader proto.InternalMessageInfo - -func (m *TreeHeader) GetFirstId() string { - if m != nil { - return m.FirstId - } - return "" -} - -func (m *TreeHeader) GetAclId() string { - if m != nil { - return m.AclId - } - return "" -} - -func (m *TreeHeader) GetTreeHeaderType() TreeHeaderType { - if m != nil { - return m.TreeHeaderType - } - return TreeHeaderType_Object -} - -func (m *TreeHeader) GetIdentity() []byte { - if m != nil { - return m.Identity - } - return nil -} - -func (m *TreeHeader) GetData() []byte { - if m != nil { - return m.Data - } - return nil +func init() { + proto.RegisterEnum("aclrecord.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) + proto.RegisterType((*RawACLRecord)(nil), "aclrecord.RawACLRecord") + proto.RegisterType((*RawACLRecordWithId)(nil), "aclrecord.RawACLRecordWithId") + proto.RegisterType((*ACLRecord)(nil), "aclrecord.ACLRecord") + proto.RegisterType((*ACLRoot)(nil), "aclrecord.ACLRoot") + proto.RegisterType((*ACLContentValue)(nil), "aclrecord.ACLContentValue") + proto.RegisterType((*ACLData)(nil), "aclrecord.ACLData") + proto.RegisterType((*ACLState)(nil), "aclrecord.ACLState") + proto.RegisterMapType((map[string]*ACLUserInvite)(nil), "aclrecord.ACLState.InvitesEntry") + proto.RegisterType((*ACLUserState)(nil), "aclrecord.ACLUserState") + proto.RegisterType((*ACLUserAdd)(nil), "aclrecord.ACLUserAdd") + proto.RegisterType((*ACLUserInvite)(nil), "aclrecord.ACLUserInvite") + proto.RegisterType((*ACLUserJoin)(nil), "aclrecord.ACLUserJoin") + proto.RegisterType((*ACLUserRemove)(nil), "aclrecord.ACLUserRemove") + proto.RegisterType((*ACLReadKeyReplace)(nil), "aclrecord.ACLReadKeyReplace") + proto.RegisterType((*ACLUserPermissionChange)(nil), "aclrecord.ACLUserPermissionChange") } func init() { - proto.RegisterEnum("acl.ACLUserPermissions", ACLUserPermissions_name, ACLUserPermissions_value) - proto.RegisterEnum("acl.TreeHeaderType", TreeHeaderType_name, TreeHeaderType_value) - proto.RegisterType((*RawACLRecord)(nil), "acl.RawACLRecord") - proto.RegisterType((*ACLContentValue)(nil), "acl.ACLContentValue") - proto.RegisterType((*ACLData)(nil), "acl.ACLData") - proto.RegisterType((*ACLState)(nil), "acl.ACLState") - proto.RegisterMapType((map[string]*ACLUserInvite)(nil), "acl.ACLState.InvitesEntry") - proto.RegisterType((*ACLUserState)(nil), "acl.ACLUserState") - proto.RegisterType((*ACLUserAdd)(nil), "acl.ACLUserAdd") - proto.RegisterType((*ACLUserConfirm)(nil), "acl.ACLUserConfirm") - proto.RegisterType((*ACLUserInvite)(nil), "acl.ACLUserInvite") - proto.RegisterType((*ACLUserJoin)(nil), "acl.ACLUserJoin") - proto.RegisterType((*ACLUserRemove)(nil), "acl.ACLUserRemove") - proto.RegisterType((*ACLReadKeyReplace)(nil), "acl.ACLReadKeyReplace") - proto.RegisterType((*ACLUserPermissionChange)(nil), "acl.ACLUserPermissionChange") - proto.RegisterType((*ACLRecord)(nil), "acl.ACLRecord") - proto.RegisterType((*ACLHeader)(nil), "acl.ACLHeader") - proto.RegisterType((*RawTreeChange)(nil), "acl.RawTreeChange") - proto.RegisterType((*RawTreeChangeWithId)(nil), "acl.RawTreeChangeWithId") - proto.RegisterType((*TreeChange)(nil), "acl.TreeChange") - proto.RegisterType((*TreeHeader)(nil), "acl.TreeHeader") + proto.RegisterFile("pkg/acl/aclrecordproto/protos/aclrecord.proto", fileDescriptor_14abe0d1b4206d54) } -func init() { - proto.RegisterFile("pkg/acl/aclchanges/aclpb/protos/aclchanges.proto", fileDescriptor_37a022c841a51877) -} - -var fileDescriptor_37a022c841a51877 = []byte{ - // 1078 bytes of a gzipped FileDescriptorProto +var fileDescriptor_14abe0d1b4206d54 = []byte{ + // 862 bytes of a gzipped FileDescriptorProto 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xcd, 0x6e, 0x23, 0x45, - 0x10, 0xf6, 0x8c, 0xe3, 0x38, 0x2e, 0x3b, 0x8e, 0xd3, 0x1b, 0xed, 0x8e, 0xa2, 0xc8, 0x8a, 0x46, - 0x08, 0xa2, 0x80, 0xbc, 0x60, 0x56, 0xe2, 0xef, 0x00, 0x8e, 0x17, 0x61, 0x6f, 0x22, 0x58, 0x75, - 0xc2, 0xae, 0xc4, 0xad, 0x33, 0xd3, 0x9b, 0x34, 0x6b, 0xcf, 0x8c, 0xa6, 0x3b, 0x89, 0x7c, 0xe4, - 0x0d, 0x78, 0x04, 0x38, 0xf2, 0x04, 0xbc, 0x02, 0x12, 0x97, 0x3d, 0x22, 0x71, 0x41, 0xc9, 0x09, - 0x4e, 0x3c, 0x02, 0xea, 0x9f, 0x99, 0xe9, 0xb1, 0x93, 0xf0, 0xa3, 0x15, 0xd2, 0x1e, 0x46, 0xea, - 0xfe, 0xaa, 0xaa, 0xbb, 0xea, 0xab, 0x9a, 0xea, 0x82, 0xb7, 0x93, 0xe7, 0x27, 0xf7, 0x49, 0x30, - 0x91, 0x5f, 0x70, 0x4a, 0xa2, 0x13, 0xca, 0xe5, 0x32, 0x39, 0xbe, 0x9f, 0xa4, 0xb1, 0x88, 0xb9, - 0x85, 0xf7, 0x14, 0x82, 0xaa, 0x24, 0x98, 0xf8, 0x4f, 0xa0, 0x85, 0xc9, 0xc5, 0x60, 0x78, 0x80, - 0x69, 0x10, 0xa7, 0x21, 0xf2, 0xa0, 0x9e, 0x90, 0xd9, 0x24, 0x26, 0xa1, 0xe7, 0x6c, 0x3b, 0x3b, - 0x2d, 0x9c, 0x6d, 0xd1, 0x16, 0x34, 0x38, 0x3b, 0x89, 0x88, 0x38, 0x4b, 0xa9, 0xe7, 0x2a, 0x59, - 0x01, 0xa0, 0x36, 0xb8, 0x2c, 0xf4, 0xaa, 0xdb, 0xce, 0x4e, 0x03, 0xbb, 0x2c, 0xf4, 0xff, 0x74, - 0x61, 0x6d, 0x30, 0x3c, 0x18, 0xc6, 0x91, 0xa0, 0x91, 0x78, 0x42, 0x26, 0x67, 0x14, 0xbd, 0x09, - 0xf5, 0x33, 0x4e, 0xd3, 0x41, 0xa8, 0xcf, 0x6e, 0xf6, 0xd7, 0x7a, 0x24, 0x98, 0xf4, 0x06, 0xc3, - 0x83, 0x2f, 0x35, 0x3c, 0xaa, 0xe0, 0x4c, 0x03, 0x3d, 0x00, 0x90, 0x4b, 0x4c, 0xa7, 0xf1, 0xb9, - 0xbe, 0xaf, 0xd9, 0x47, 0xb6, 0xbe, 0x96, 0x8c, 0x2a, 0xd8, 0xd2, 0x43, 0x18, 0x36, 0xe4, 0xee, - 0x31, 0x4d, 0xa7, 0x8c, 0x73, 0x16, 0x47, 0x43, 0x15, 0xb2, 0x72, 0xac, 0xd9, 0xdf, 0xb2, 0xed, - 0xe7, 0x75, 0x46, 0x15, 0x7c, 0xad, 0x6d, 0xe6, 0xc9, 0x38, 0x3a, 0x67, 0x82, 0x7a, 0x4b, 0x8b, - 0x9e, 0x68, 0x49, 0xe6, 0x89, 0xde, 0xa1, 0x1e, 0xac, 0xc8, 0xdd, 0xa3, 0x98, 0x45, 0x5e, 0x4d, - 0xd9, 0x74, 0x6c, 0x1b, 0x89, 0x8f, 0x2a, 0x38, 0xd7, 0x41, 0xef, 0x41, 0x53, 0xae, 0x87, 0x71, - 0xf4, 0x8c, 0xa5, 0x53, 0x6f, 0x59, 0x99, 0xdc, 0xb1, 0x4d, 0x8c, 0x68, 0x54, 0xc1, 0xb6, 0xe6, - 0x5e, 0x1d, 0x6a, 0xe7, 0x92, 0x5e, 0xff, 0x63, 0xa8, 0x0f, 0x86, 0x07, 0x0f, 0x89, 0x20, 0xd2, - 0x65, 0x12, 0x4c, 0x0c, 0xf9, 0x9e, 0xb3, 0x5d, 0xdd, 0x69, 0xf6, 0x37, 0xb2, 0xb3, 0xec, 0x9c, - 0x60, 0x4b, 0xcf, 0xff, 0xdd, 0x81, 0x95, 0xc1, 0xf0, 0xe0, 0x50, 0x10, 0x41, 0xd1, 0x6b, 0xb0, - 0x9a, 0x52, 0x12, 0xee, 0xd3, 0xd9, 0x88, 0xf0, 0x53, 0xca, 0xd5, 0x29, 0x4b, 0xb8, 0x0c, 0xa2, - 0x77, 0x34, 0x37, 0xca, 0x84, 0x7b, 0xae, 0xba, 0x68, 0xdd, 0x76, 0x5a, 0x49, 0xb0, 0xa5, 0x84, - 0x1e, 0x40, 0x9d, 0x29, 0x8a, 0xb8, 0x57, 0x55, 0xfa, 0x9b, 0x99, 0xbe, 0x52, 0xe8, 0x69, 0xfe, - 0xf8, 0xa7, 0x91, 0x48, 0x67, 0x38, 0x53, 0xdd, 0xfc, 0x1c, 0x5a, 0xb6, 0x00, 0x75, 0xa0, 0xfa, - 0x9c, 0xce, 0x54, 0x1d, 0x35, 0xb0, 0x5c, 0xa2, 0x1d, 0xc3, 0xc3, 0x75, 0xb5, 0xa2, 0x4d, 0xb1, - 0x56, 0xf8, 0xd0, 0x7d, 0xdf, 0xf1, 0x7f, 0x75, 0xa0, 0x65, 0xbb, 0x88, 0x36, 0x61, 0x85, 0x85, - 0x34, 0x12, 0x4c, 0xcc, 0x4c, 0xe5, 0xe7, 0x7b, 0xc9, 0x05, 0x8d, 0x82, 0x74, 0x96, 0x08, 0x16, - 0x47, 0xfb, 0x74, 0x66, 0xca, 0xbf, 0x0c, 0xa2, 0xb7, 0x60, 0xdd, 0x00, 0x34, 0xc4, 0x9a, 0x25, - 0x1d, 0x62, 0x0b, 0x2f, 0x0a, 0xd0, 0x07, 0xd0, 0x4c, 0xf2, 0x4a, 0xe3, 0xaa, 0xac, 0xda, 0xfd, - 0x7b, 0xd7, 0x17, 0x28, 0xc7, 0xb6, 0x2e, 0xda, 0x86, 0x26, 0xe3, 0x26, 0xfd, 0x34, 0x54, 0xd5, - 0xb5, 0x82, 0x6d, 0xc8, 0xff, 0xd1, 0x01, 0x28, 0x7e, 0xab, 0x57, 0x28, 0x36, 0xff, 0x11, 0xb4, - 0xcb, 0xe5, 0x7e, 0xab, 0xf3, 0x5b, 0xd0, 0x30, 0xfd, 0x62, 0x1c, 0x2a, 0xc7, 0x1b, 0xb8, 0x00, - 0xfc, 0x3f, 0x1c, 0x58, 0x2d, 0x15, 0x00, 0xda, 0x81, 0x35, 0x12, 0x04, 0x34, 0x11, 0x8f, 0xcf, - 0x8e, 0x27, 0x2c, 0xd8, 0xa7, 0xd9, 0x91, 0xf3, 0x30, 0xda, 0x85, 0x8e, 0x89, 0xab, 0x50, 0xd5, - 0xcc, 0x2c, 0xe0, 0xff, 0x5f, 0xe2, 0x25, 0x15, 0x2a, 0x90, 0xb1, 0xce, 0x7a, 0x03, 0xe7, 0x7b, - 0xff, 0x67, 0x07, 0x9a, 0x56, 0x6f, 0x79, 0x09, 0x39, 0xcf, 0xc9, 0x3a, 0xcc, 0xdb, 0x7e, 0xd5, - 0x26, 0x2b, 0x87, 0x91, 0x0f, 0xad, 0xa2, 0xf3, 0x8d, 0x43, 0x15, 0x53, 0x03, 0x97, 0xb0, 0xeb, - 0x49, 0xaa, 0xdd, 0x40, 0x92, 0x3f, 0xcd, 0x33, 0x67, 0x1a, 0xfb, 0x6d, 0xe1, 0x7c, 0x02, 0x6b, - 0xa6, 0x2b, 0x61, 0x9a, 0x4c, 0x48, 0x90, 0x77, 0x96, 0xbb, 0x19, 0xab, 0xb8, 0x24, 0xc6, 0xf3, - 0xea, 0xfe, 0x37, 0x0e, 0xac, 0x2f, 0xa8, 0xbd, 0x04, 0x0a, 0x8b, 0x2a, 0xca, 0x63, 0x33, 0x1c, - 0x2e, 0xe0, 0x7e, 0x02, 0xf7, 0x6e, 0x78, 0x99, 0x6e, 0x75, 0x64, 0xae, 0x9c, 0xdc, 0x7f, 0xf1, - 0xaf, 0x7d, 0xef, 0x40, 0xa3, 0x78, 0xf9, 0xef, 0xc2, 0x72, 0x92, 0xd2, 0xf3, 0x71, 0x68, 0x9a, - 0xaa, 0xd9, 0x95, 0x2e, 0x77, 0xe7, 0x2e, 0x47, 0xb0, 0x14, 0x12, 0x41, 0x4c, 0x4c, 0x6a, 0x8d, - 0x7a, 0x80, 0x82, 0xb3, 0x34, 0xa5, 0x91, 0xc0, 0xc5, 0x53, 0xa1, 0x4a, 0x62, 0x09, 0x5f, 0x23, - 0x91, 0xff, 0xb0, 0x60, 0x53, 0xca, 0x05, 0x99, 0x26, 0xaa, 0xaa, 0xab, 0xb8, 0x00, 0xfc, 0x81, - 0x72, 0x71, 0x44, 0x49, 0x48, 0x53, 0x39, 0x9c, 0x3c, 0x63, 0x29, 0x17, 0xb9, 0x8f, 0xd9, 0xf6, - 0x36, 0x27, 0xfd, 0xcf, 0x60, 0x15, 0x93, 0x8b, 0xa3, 0x94, 0x52, 0x43, 0xe7, 0x7f, 0x9c, 0x71, - 0xfc, 0x21, 0xdc, 0x29, 0x1d, 0xf4, 0x94, 0x89, 0xd3, 0xb1, 0x32, 0x4a, 0xc9, 0x85, 0x19, 0x34, - 0xf4, 0x81, 0x05, 0x60, 0x06, 0x23, 0x37, 0x1f, 0x8c, 0xbe, 0x73, 0x01, 0x2c, 0x5f, 0xb6, 0xa1, - 0x29, 0x52, 0x4a, 0x65, 0x80, 0xe3, 0x50, 0x3f, 0xb2, 0x0d, 0x6c, 0x43, 0xf2, 0x78, 0x12, 0x4c, - 0xf4, 0x2e, 0xeb, 0x71, 0x39, 0x80, 0x5e, 0x87, 0x36, 0x8f, 0x48, 0xc2, 0x4f, 0x63, 0xb1, 0x47, - 0xb8, 0xfc, 0xf9, 0xf4, 0x0c, 0x36, 0x87, 0xca, 0x7b, 0xcc, 0xf4, 0x27, 0x07, 0x04, 0x95, 0x8e, - 0x16, 0xb6, 0xa1, 0x1b, 0xf2, 0x56, 0xfb, 0x67, 0x79, 0x5b, 0x9e, 0xcb, 0x5b, 0x29, 0x21, 0xf5, - 0xb9, 0xaa, 0xe9, 0x02, 0x30, 0x7e, 0x68, 0xfc, 0xf3, 0x56, 0xd4, 0xf3, 0x65, 0x21, 0xfe, 0x0f, - 0x8e, 0xa6, 0xe8, 0x6f, 0xb3, 0xbe, 0x01, 0x35, 0x12, 0x4c, 0x72, 0x5a, 0xf4, 0x06, 0x7d, 0x04, - 0x6d, 0x91, 0x5b, 0x1f, 0xcd, 0x12, 0xdd, 0xb6, 0xda, 0x66, 0x98, 0x3a, 0x2a, 0x89, 0xf0, 0x9c, - 0x6a, 0xc9, 0xef, 0xa5, 0x1b, 0xaa, 0xbd, 0x56, 0x54, 0xfb, 0xee, 0x43, 0x40, 0x8b, 0xbf, 0x19, - 0x6a, 0x40, 0x6d, 0x10, 0x4e, 0x59, 0xd4, 0xa9, 0x20, 0x80, 0xe5, 0xa7, 0x29, 0x13, 0x34, 0xed, - 0x38, 0x72, 0x8d, 0xd5, 0x55, 0x1d, 0x17, 0x35, 0xa1, 0xae, 0x5b, 0x5b, 0xd8, 0xa9, 0xee, 0xbe, - 0x01, 0xed, 0xb2, 0x5f, 0x52, 0xf5, 0x8b, 0xe3, 0xaf, 0x69, 0x20, 0x3a, 0x15, 0x79, 0xda, 0x61, - 0x42, 0x02, 0xda, 0x71, 0xf6, 0xfa, 0x3f, 0x5d, 0x76, 0x9d, 0x17, 0x97, 0x5d, 0xe7, 0xb7, 0xcb, - 0xae, 0xf3, 0xed, 0x55, 0xb7, 0xf2, 0xe2, 0xaa, 0x5b, 0xf9, 0xe5, 0xaa, 0x5b, 0xf9, 0xca, 0xbb, - 0x69, 0xfe, 0x3f, 0x5e, 0x56, 0xe3, 0xfe, 0xbb, 0x7f, 0x05, 0x00, 0x00, 0xff, 0xff, 0x0c, 0x62, - 0x40, 0x97, 0x22, 0x0c, 0x00, 0x00, + 0x10, 0x76, 0x8f, 0x9d, 0x38, 0x53, 0xe3, 0xdd, 0x78, 0x5b, 0x90, 0x1d, 0x45, 0x8b, 0x65, 0x8d, + 0x38, 0x58, 0x2b, 0xf0, 0x82, 0x41, 0x5a, 0x94, 0x03, 0xc8, 0x6b, 0x76, 0x65, 0x93, 0x1c, 0x56, + 0x1d, 0x60, 0x11, 0xb7, 0xde, 0x99, 0x26, 0x69, 0xad, 0x3d, 0x33, 0xea, 0x6e, 0x1b, 0xf9, 0xc8, + 0x1b, 0xf0, 0x0a, 0x3c, 0x08, 0x27, 0x2e, 0x1c, 0x73, 0x41, 0xe2, 0x08, 0xc9, 0x0b, 0x70, 0xe7, + 0x82, 0xba, 0xe7, 0xdf, 0xe3, 0x58, 0x42, 0x8a, 0x90, 0x38, 0x24, 0x9e, 0xaa, 0xfa, 0xaa, 0xfc, + 0xd5, 0xd7, 0x35, 0xd5, 0x86, 0xf7, 0xe3, 0x37, 0x17, 0x4f, 0xa8, 0x3f, 0xd7, 0x7f, 0x82, 0xf9, + 0x91, 0x08, 0x62, 0x11, 0xa9, 0xe8, 0x89, 0xf9, 0x2f, 0x0b, 0xef, 0xd0, 0x38, 0xb0, 0x9d, 0x3b, + 0xbc, 0x17, 0xd0, 0x21, 0xf4, 0xfb, 0xf1, 0xe4, 0x8c, 0x18, 0x1b, 0xbb, 0xd0, 0x8e, 0xe9, 0x7a, + 0x1e, 0xd1, 0xc0, 0x45, 0x7d, 0x34, 0xe8, 0x90, 0xcc, 0xc4, 0x8f, 0xc0, 0x96, 0xfc, 0x22, 0xa4, + 0x6a, 0x29, 0x98, 0x6b, 0x99, 0x58, 0xe1, 0xf0, 0x3e, 0x05, 0x5c, 0xae, 0xf3, 0x8a, 0xab, 0xcb, + 0xd9, 0xae, 0x6a, 0xf7, 0xc1, 0xe2, 0x81, 0x29, 0x63, 0x13, 0x8b, 0x07, 0xde, 0x4f, 0x08, 0xec, + 0x82, 0xc5, 0x11, 0xec, 0xc7, 0x82, 0xad, 0x66, 0x49, 0x9a, 0x4d, 0x52, 0x0b, 0x1f, 0xc3, 0x01, + 0x0f, 0x58, 0xa8, 0xb8, 0x5a, 0xa7, 0x14, 0x72, 0x1b, 0x63, 0x68, 0x05, 0x54, 0x51, 0xb7, 0x69, + 0xfc, 0xe6, 0x19, 0x0f, 0x01, 0xfb, 0x4b, 0x21, 0x58, 0xa8, 0x08, 0xa3, 0xc1, 0x29, 0x5b, 0x4f, + 0xa9, 0xbc, 0x74, 0x5b, 0x7d, 0x34, 0x68, 0x91, 0x2d, 0x11, 0xdd, 0xa3, 0xe2, 0x0b, 0x26, 0x15, + 0x5d, 0xc4, 0xee, 0x5e, 0x1f, 0x0d, 0x9a, 0xa4, 0x70, 0x78, 0x3f, 0x23, 0x68, 0x6b, 0x8e, 0x51, + 0xa4, 0x2a, 0x4c, 0xd0, 0x06, 0x93, 0x77, 0xe1, 0x1e, 0x0b, 0x7d, 0xb1, 0x8e, 0x15, 0x8f, 0xc2, + 0x53, 0x96, 0x51, 0xad, 0x3a, 0xb5, 0x36, 0x32, 0xa6, 0x3e, 0x9b, 0x05, 0x86, 0xb2, 0x4d, 0x32, + 0x13, 0x3f, 0x86, 0x6e, 0x0a, 0x65, 0x41, 0xca, 0xce, 0x70, 0xee, 0x90, 0x9a, 0x5f, 0x63, 0x03, + 0x26, 0xf8, 0x8a, 0xea, 0xb2, 0xe7, 0xfe, 0x25, 0x5b, 0x30, 0x43, 0xdc, 0x26, 0x35, 0xbf, 0xf7, + 0x9b, 0x05, 0x87, 0xe3, 0xc9, 0xd9, 0x24, 0x0a, 0x15, 0x0b, 0xd5, 0xd7, 0x74, 0xbe, 0x64, 0xf8, + 0x43, 0x68, 0x2f, 0x25, 0x13, 0xe3, 0x20, 0x91, 0xda, 0x19, 0xbd, 0x3d, 0x2c, 0xa6, 0x65, 0x3c, + 0x39, 0xfb, 0x2a, 0x09, 0x4e, 0x1b, 0x24, 0xc3, 0xe1, 0x13, 0x00, 0xfd, 0x48, 0xd8, 0x22, 0x5a, + 0x25, 0x93, 0xe0, 0x8c, 0xdc, 0x7a, 0x56, 0x12, 0x9f, 0x36, 0x48, 0x09, 0x8d, 0xbf, 0x81, 0xb7, + 0xb4, 0xf5, 0x92, 0x89, 0x05, 0x97, 0x92, 0x47, 0xe1, 0xe4, 0x92, 0x86, 0x17, 0xcc, 0x28, 0xe0, + 0x8c, 0xbc, 0x7a, 0x95, 0x4d, 0xe4, 0xb4, 0x41, 0xb6, 0x56, 0xc8, 0x58, 0xcd, 0xc2, 0x15, 0x57, + 0xcc, 0xc8, 0xb5, 0x95, 0x55, 0x12, 0xcf, 0x58, 0x25, 0x16, 0xfe, 0x18, 0x0e, 0xb4, 0xf5, 0x45, + 0xc4, 0x43, 0x23, 0x9e, 0x33, 0x3a, 0xaa, 0x67, 0xea, 0xe8, 0xb4, 0x41, 0x72, 0xe4, 0xb3, 0x36, + 0xec, 0xad, 0xb4, 0x86, 0xde, 0x73, 0x33, 0x16, 0x9f, 0xeb, 0x81, 0x3b, 0x01, 0xa0, 0xfe, 0x3c, + 0x55, 0xd8, 0x45, 0xfd, 0xe6, 0xc0, 0x19, 0x1d, 0x57, 0x6b, 0x95, 0xe5, 0x27, 0x25, 0xb4, 0xf7, + 0x37, 0x82, 0x83, 0xf1, 0xe4, 0xec, 0x5c, 0x51, 0xc5, 0xf4, 0x0c, 0x89, 0x62, 0x30, 0x99, 0x34, + 0xb5, 0x5a, 0xa4, 0xea, 0xc4, 0x4f, 0x93, 0xa6, 0x4d, 0x8a, 0x74, 0x2d, 0xf3, 0x75, 0x0f, 0xeb, + 0xd4, 0x4d, 0x9c, 0x94, 0xa0, 0xf8, 0x04, 0xda, 0xdc, 0xf4, 0x2e, 0xdd, 0xa6, 0xc9, 0xea, 0x57, + 0xb3, 0x0c, 0x6c, 0x98, 0xc8, 0x23, 0x9f, 0x87, 0x4a, 0xac, 0x49, 0x96, 0x70, 0xfc, 0x25, 0x74, + 0xca, 0x01, 0xdc, 0x85, 0xe6, 0x1b, 0xb6, 0x4e, 0xdf, 0x54, 0xfd, 0x88, 0x87, 0xa9, 0x32, 0xb7, + 0x0f, 0x47, 0x52, 0x80, 0x24, 0xb0, 0x13, 0xeb, 0x13, 0xe4, 0xfd, 0x89, 0xa0, 0x53, 0xa6, 0x7b, + 0x07, 0x6f, 0xd8, 0x7b, 0xf0, 0x60, 0xf3, 0x7d, 0x49, 0xda, 0xed, 0x90, 0x7a, 0x00, 0x7f, 0x06, + 0x4e, 0x9c, 0x0f, 0x95, 0x34, 0x13, 0x74, 0x7f, 0xf4, 0xce, 0xae, 0x89, 0x94, 0xa4, 0x9c, 0x81, + 0xfb, 0xe0, 0x70, 0x39, 0x89, 0xc2, 0xef, 0xb8, 0x58, 0xb0, 0xc0, 0x0c, 0xd2, 0x01, 0x29, 0xbb, + 0xf4, 0x02, 0x81, 0xe2, 0x9d, 0xfa, 0xdf, 0x75, 0xe8, 0xfd, 0x85, 0xe0, 0x5e, 0xe5, 0x00, 0xf1, + 0x00, 0x0e, 0xa9, 0xef, 0xb3, 0x58, 0xbd, 0x5c, 0xbe, 0x9e, 0x73, 0xff, 0x94, 0x65, 0x9d, 0x6c, + 0xba, 0x4b, 0x4b, 0xad, 0x80, 0x5a, 0x95, 0xa5, 0x56, 0x60, 0xff, 0xe3, 0x83, 0xd3, 0xe7, 0x60, + 0xda, 0x99, 0x05, 0xe9, 0xee, 0xcc, 0x6d, 0xef, 0x17, 0x04, 0x4e, 0x69, 0x01, 0xdc, 0xc1, 0x99, + 0xe5, 0x92, 0x9d, 0xe7, 0xb7, 0x69, 0xb3, 0x2c, 0x59, 0xee, 0xae, 0xf0, 0x6a, 0x55, 0x79, 0x6d, + 0x97, 0x68, 0xef, 0x16, 0x89, 0x3c, 0x99, 0x9f, 0x5b, 0xba, 0x87, 0x77, 0xb5, 0xf1, 0x02, 0x0e, + 0xd3, 0x2d, 0x43, 0x58, 0x3c, 0xa7, 0x7e, 0xbe, 0x23, 0x1e, 0x55, 0x35, 0x25, 0x15, 0x10, 0xd9, + 0x4c, 0xf2, 0x7e, 0x40, 0xf0, 0xa0, 0x06, 0xbb, 0x03, 0x01, 0xb7, 0x5d, 0x8f, 0xcd, 0xed, 0xd7, + 0xa3, 0xb7, 0x82, 0x87, 0xb7, 0x5c, 0x24, 0x3b, 0x89, 0x6c, 0x8c, 0x94, 0xf5, 0x6f, 0x47, 0xea, + 0xf1, 0x53, 0xc0, 0x75, 0x08, 0xb6, 0x61, 0x6f, 0x1c, 0x2c, 0x78, 0xd8, 0x6d, 0x60, 0x80, 0xfd, + 0x57, 0x82, 0x2b, 0x26, 0xba, 0x48, 0x3f, 0x6b, 0xbe, 0x4c, 0x74, 0xad, 0x67, 0x1f, 0xfc, 0x7a, + 0xdd, 0x43, 0x57, 0xd7, 0x3d, 0xf4, 0xc7, 0x75, 0x0f, 0xfd, 0x78, 0xd3, 0x6b, 0x5c, 0xdd, 0xf4, + 0x1a, 0xbf, 0xdf, 0xf4, 0x1a, 0xdf, 0x1e, 0x6d, 0xff, 0x8d, 0xf7, 0x7a, 0xdf, 0x7c, 0x7c, 0xf4, + 0x4f, 0x00, 0x00, 0x00, 0xff, 0xff, 0x93, 0x89, 0xed, 0xeb, 0x04, 0x0a, 0x00, 0x00, } func (m *RawACLRecord) Marshal() (dAtA []byte, err error) { @@ -1421,24 +1095,166 @@ func (m *RawACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x1a - } if len(m.Signature) > 0 { i -= len(m.Signature) copy(dAtA[i:], m.Signature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Signature))) i-- dAtA[i] = 0x12 } if len(m.Payload) > 0 { i -= len(m.Payload) copy(dAtA[i:], m.Payload) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawACLRecordWithId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RawACLRecordWithId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawACLRecordWithId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ACLRecord) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLRecord) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Timestamp != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x28 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintAclrecord(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x20 + } + if len(m.Data) > 0 { + i -= len(m.Data) + copy(dAtA[i:], m.Data) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Data))) + i-- + dAtA[i] = 0x1a + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x12 + } + if len(m.PrevId) > 0 { + i -= len(m.PrevId) + copy(dAtA[i:], m.PrevId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.PrevId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *ACLRoot) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *ACLRoot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *ACLRoot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.DerivationScheme) > 0 { + i -= len(m.DerivationScheme) + copy(dAtA[i:], m.DerivationScheme) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.DerivationScheme))) + i-- + dAtA[i] = 0x2a + } + if len(m.EncryptedReadKey) > 0 { + i -= len(m.EncryptedReadKey) + copy(dAtA[i:], m.EncryptedReadKey) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKey))) + i-- + dAtA[i] = 0x22 + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x1a + } + if len(m.EncryptionKey) > 0 { + i -= len(m.EncryptionKey) + copy(dAtA[i:], m.EncryptionKey) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) + i-- + dAtA[i] = 0x12 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1491,7 +1307,7 @@ func (m *ACLContentValue_UserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -1512,7 +1328,7 @@ func (m *ACLContentValue_UserRemove) MarshalToSizedBuffer(dAtA []byte) (int, err return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 @@ -1533,7 +1349,7 @@ func (m *ACLContentValue_UserPermissionChange) MarshalToSizedBuffer(dAtA []byte) return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -1554,7 +1370,7 @@ func (m *ACLContentValue_UserInvite) MarshalToSizedBuffer(dAtA []byte) (int, err return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x22 @@ -1575,34 +1391,13 @@ func (m *ACLContentValue_UserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x2a } return len(dAtA) - i, nil } -func (m *ACLContentValue_UserConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLContentValue_UserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.UserConfirm != nil { - { - size, err := m.UserConfirm.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x32 - } - return len(dAtA) - i, nil -} func (m *ACLData) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -1631,7 +1426,7 @@ func (m *ACLData) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0xa @@ -1671,17 +1466,17 @@ func (m *ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } i -= len(k) copy(dAtA[i:], k) - i = encodeVarintAclchanges(dAtA, i, uint64(len(k))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(k))) i-- dAtA[i] = 0xa - i = encodeVarintAclchanges(dAtA, i, uint64(baseI-i)) + i = encodeVarintAclrecord(dAtA, i, uint64(baseI-i)) i-- dAtA[i] = 0x1a } @@ -1694,27 +1489,27 @@ func (m *ACLState) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x12 } } if len(m.ReadKeyHashes) > 0 { - dAtA9 := make([]byte, len(m.ReadKeyHashes)*10) - var j8 int + dAtA8 := make([]byte, len(m.ReadKeyHashes)*10) + var j7 int for _, num := range m.ReadKeyHashes { for num >= 1<<7 { - dAtA9[j8] = uint8(uint64(num)&0x7f | 0x80) + dAtA8[j7] = uint8(uint64(num)&0x7f | 0x80) num >>= 7 - j8++ + j7++ } - dAtA9[j8] = uint8(num) - j8++ + dAtA8[j7] = uint8(num) + j7++ } - i -= j8 - copy(dAtA[i:], dAtA9[:j8]) - i = encodeVarintAclchanges(dAtA, i, uint64(j8)) + i -= j7 + copy(dAtA[i:], dAtA8[:j7]) + i = encodeVarintAclrecord(dAtA, i, uint64(j7)) i-- dAtA[i] = 0xa } @@ -1752,7 +1547,7 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { dAtA[i] = 0x28 } if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1760,7 +1555,7 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1768,14 +1563,14 @@ func (m *ACLUserState) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1803,7 +1598,7 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { var l int _ = l if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1811,7 +1606,7 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1819,51 +1614,14 @@ func (m *ACLUserAdd) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLUserConfirm) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ACLUserConfirm) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLUserConfirm) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.UserAddId) > 0 { - i -= len(m.UserAddId) - copy(dAtA[i:], m.UserAddId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserAddId))) - i-- - dAtA[i] = 0x12 - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -1893,12 +1651,12 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.InviteId) > 0 { i -= len(m.InviteId) copy(dAtA[i:], m.InviteId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.InviteId))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) i-- dAtA[i] = 0x2a } if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x20 } @@ -1906,7 +1664,7 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x1a } @@ -1914,14 +1672,14 @@ func (m *ACLUserInvite) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptPublicKey) > 0 { i -= len(m.EncryptPublicKey) copy(dAtA[i:], m.EncryptPublicKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptPublicKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptPublicKey))) i-- dAtA[i] = 0x12 } if len(m.AcceptPublicKey) > 0 { i -= len(m.AcceptPublicKey) copy(dAtA[i:], m.AcceptPublicKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AcceptPublicKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptPublicKey))) i-- dAtA[i] = 0xa } @@ -1952,36 +1710,36 @@ func (m *ACLUserJoin) MarshalToSizedBuffer(dAtA []byte) (int, error) { for iNdEx := len(m.EncryptedReadKeys) - 1; iNdEx >= 0; iNdEx-- { i -= len(m.EncryptedReadKeys[iNdEx]) copy(dAtA[i:], m.EncryptedReadKeys[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKeys[iNdEx]))) i-- dAtA[i] = 0x2a } } - if len(m.UserInviteId) > 0 { - i -= len(m.UserInviteId) - copy(dAtA[i:], m.UserInviteId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.UserInviteId))) + if len(m.InviteId) > 0 { + i -= len(m.InviteId) + copy(dAtA[i:], m.InviteId) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.InviteId))) i-- dAtA[i] = 0x22 } if len(m.AcceptSignature) > 0 { i -= len(m.AcceptSignature) copy(dAtA[i:], m.AcceptSignature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AcceptSignature))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.AcceptSignature))) i-- dAtA[i] = 0x1a } if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2016,7 +1774,7 @@ func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { return 0, err } i -= size - i = encodeVarintAclchanges(dAtA, i, uint64(size)) + i = encodeVarintAclrecord(dAtA, i, uint64(size)) } i-- dAtA[i] = 0x1a @@ -2025,7 +1783,7 @@ func (m *ACLUserRemove) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2055,21 +1813,21 @@ func (m *ACLReadKeyReplace) MarshalToSizedBuffer(dAtA []byte) (int, error) { if len(m.EncryptedReadKey) > 0 { i -= len(m.EncryptedReadKey) copy(dAtA[i:], m.EncryptedReadKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptedReadKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptedReadKey))) i-- dAtA[i] = 0x1a } if len(m.EncryptionKey) > 0 { i -= len(m.EncryptionKey) copy(dAtA[i:], m.EncryptionKey) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.EncryptionKey))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.EncryptionKey))) i-- dAtA[i] = 0x12 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } @@ -2097,323 +1855,22 @@ func (m *ACLUserPermissionChange) MarshalToSizedBuffer(dAtA []byte) (int, error) var l int _ = l if m.Permissions != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Permissions)) + i = encodeVarintAclrecord(dAtA, i, uint64(m.Permissions)) i-- dAtA[i] = 0x10 } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) + i = encodeVarintAclrecord(dAtA, i, uint64(len(m.Identity))) i-- dAtA[i] = 0xa } return len(dAtA) - i, nil } -func (m *ACLRecord) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ACLRecord) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLRecord) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x28 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x20 - } - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x1a - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x12 - } - if len(m.PrevId) > 0 { - i -= len(m.PrevId) - copy(dAtA[i:], m.PrevId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.PrevId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *ACLHeader) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *ACLHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *ACLHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x12 - } - if len(m.FirstId) > 0 { - i -= len(m.FirstId) - copy(dAtA[i:], m.FirstId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.FirstId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RawTreeChange) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RawTreeChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RawTreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Signature) > 0 { - i -= len(m.Signature) - copy(dAtA[i:], m.Signature) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Signature))) - i-- - dAtA[i] = 0x12 - } - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *RawTreeChangeWithId) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *RawTreeChangeWithId) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *RawTreeChangeWithId) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Id) > 0 { - i -= len(m.Id) - copy(dAtA[i:], m.Id) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Id))) - i-- - dAtA[i] = 0x12 - } - if len(m.RawChange) > 0 { - i -= len(m.RawChange) - copy(dAtA[i:], m.RawChange) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.RawChange))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *TreeChange) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TreeChange) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.IsSnapshot { - i-- - if m.IsSnapshot { - dAtA[i] = 1 - } else { - dAtA[i] = 0 - } - i-- - dAtA[i] = 0x40 - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x3a - } - if m.Timestamp != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.Timestamp)) - i-- - dAtA[i] = 0x30 - } - if m.CurrentReadKeyHash != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.CurrentReadKeyHash)) - i-- - dAtA[i] = 0x28 - } - if len(m.ChangesData) > 0 { - i -= len(m.ChangesData) - copy(dAtA[i:], m.ChangesData) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.ChangesData))) - i-- - dAtA[i] = 0x22 - } - if len(m.SnapshotBaseId) > 0 { - i -= len(m.SnapshotBaseId) - copy(dAtA[i:], m.SnapshotBaseId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.SnapshotBaseId))) - i-- - dAtA[i] = 0x1a - } - if len(m.AclHeadId) > 0 { - i -= len(m.AclHeadId) - copy(dAtA[i:], m.AclHeadId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclHeadId))) - i-- - dAtA[i] = 0x12 - } - if len(m.TreeHeadIds) > 0 { - for iNdEx := len(m.TreeHeadIds) - 1; iNdEx >= 0; iNdEx-- { - i -= len(m.TreeHeadIds[iNdEx]) - copy(dAtA[i:], m.TreeHeadIds[iNdEx]) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.TreeHeadIds[iNdEx]))) - i-- - dAtA[i] = 0xa - } - } - return len(dAtA) - i, nil -} - -func (m *TreeHeader) Marshal() (dAtA []byte, err error) { - size := m.Size() - dAtA = make([]byte, size) - n, err := m.MarshalToSizedBuffer(dAtA[:size]) - if err != nil { - return nil, err - } - return dAtA[:n], nil -} - -func (m *TreeHeader) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *TreeHeader) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Data) > 0 { - i -= len(m.Data) - copy(dAtA[i:], m.Data) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Data))) - i-- - dAtA[i] = 0x2a - } - if len(m.Identity) > 0 { - i -= len(m.Identity) - copy(dAtA[i:], m.Identity) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.Identity))) - i-- - dAtA[i] = 0x22 - } - if m.TreeHeaderType != 0 { - i = encodeVarintAclchanges(dAtA, i, uint64(m.TreeHeaderType)) - i-- - dAtA[i] = 0x18 - } - if len(m.AclId) > 0 { - i -= len(m.AclId) - copy(dAtA[i:], m.AclId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.AclId))) - i-- - dAtA[i] = 0x12 - } - if len(m.FirstId) > 0 { - i -= len(m.FirstId) - copy(dAtA[i:], m.FirstId) - i = encodeVarintAclchanges(dAtA, i, uint64(len(m.FirstId))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintAclchanges(dAtA []byte, offset int, v uint64) int { - offset -= sovAclchanges(v) +func encodeVarintAclrecord(dAtA []byte, offset int, v uint64) int { + offset -= sovAclrecord(v) base := offset for v >= 1<<7 { dAtA[offset] = uint8(v&0x7f | 0x80) @@ -2431,15 +1888,84 @@ func (m *RawACLRecord) Size() (n int) { _ = l l = len(m.Payload) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.Signature) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} + +func (m *RawACLRecordWithId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.Id) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) + } + return n +} + +func (m *ACLRecord) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.PrevId) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.Data) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovAclrecord(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovAclrecord(uint64(m.Timestamp)) + } + return n +} + +func (m *ACLRoot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.EncryptionKey) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.EncryptedReadKey) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) + } + l = len(m.DerivationScheme) + if l > 0 { + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2464,7 +1990,7 @@ func (m *ACLContentValue_UserAdd) Size() (n int) { _ = l if m.UserAdd != nil { l = m.UserAdd.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2476,7 +2002,7 @@ func (m *ACLContentValue_UserRemove) Size() (n int) { _ = l if m.UserRemove != nil { l = m.UserRemove.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2488,7 +2014,7 @@ func (m *ACLContentValue_UserPermissionChange) Size() (n int) { _ = l if m.UserPermissionChange != nil { l = m.UserPermissionChange.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2500,7 +2026,7 @@ func (m *ACLContentValue_UserInvite) Size() (n int) { _ = l if m.UserInvite != nil { l = m.UserInvite.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2512,19 +2038,7 @@ func (m *ACLContentValue_UserJoin) Size() (n int) { _ = l if m.UserJoin != nil { l = m.UserJoin.Size() - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} -func (m *ACLContentValue_UserConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.UserConfirm != nil { - l = m.UserConfirm.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2537,7 +2051,7 @@ func (m *ACLData) Size() (n int) { if len(m.AclContent) > 0 { for _, e := range m.AclContent { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2552,14 +2066,14 @@ func (m *ACLState) Size() (n int) { if len(m.ReadKeyHashes) > 0 { l = 0 for _, e := range m.ReadKeyHashes { - l += sovAclchanges(uint64(e)) + l += sovAclrecord(uint64(e)) } - n += 1 + sovAclchanges(uint64(l)) + l + n += 1 + sovAclrecord(uint64(l)) + l } if len(m.UserStates) > 0 { for _, e := range m.UserStates { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if len(m.Invites) > 0 { @@ -2569,10 +2083,10 @@ func (m *ACLState) Size() (n int) { l = 0 if v != nil { l = v.Size() - l += 1 + sovAclchanges(uint64(l)) + l += 1 + sovAclrecord(uint64(l)) } - mapEntrySize := 1 + len(k) + sovAclchanges(uint64(len(k))) + l - n += mapEntrySize + 1 + sovAclchanges(uint64(mapEntrySize)) + mapEntrySize := 1 + len(k) + sovAclrecord(uint64(len(k))) + l + n += mapEntrySize + 1 + sovAclrecord(uint64(mapEntrySize)) } } return n @@ -2586,20 +2100,20 @@ func (m *ACLUserState) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } if m.IsConfirmed { n += 2 @@ -2615,37 +2129,20 @@ func (m *ACLUserAdd) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) - } - return n -} - -func (m *ACLUserConfirm) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.UserAddId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } return n } @@ -2658,24 +2155,24 @@ func (m *ACLUserInvite) Size() (n int) { _ = l l = len(m.AcceptPublicKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptPublicKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } l = len(m.InviteId) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2688,24 +2185,24 @@ func (m *ACLUserJoin) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.AcceptSignature) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } - l = len(m.UserInviteId) + l = len(m.InviteId) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.EncryptedReadKeys) > 0 { for _, b := range m.EncryptedReadKeys { l = len(b) - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2719,12 +2216,12 @@ func (m *ACLUserRemove) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if len(m.ReadKeyReplaces) > 0 { for _, e := range m.ReadKeyReplaces { l = e.Size() - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } } return n @@ -2738,15 +2235,15 @@ func (m *ACLReadKeyReplace) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptionKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } l = len(m.EncryptedReadKey) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } return n } @@ -2759,165 +2256,19 @@ func (m *ACLUserPermissionChange) Size() (n int) { _ = l l = len(m.Identity) if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) + n += 1 + l + sovAclrecord(uint64(l)) } if m.Permissions != 0 { - n += 1 + sovAclchanges(uint64(m.Permissions)) + n += 1 + sovAclrecord(uint64(m.Permissions)) } return n } -func (m *ACLRecord) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.PrevId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - return n -} - -func (m *ACLHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FirstId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *RawTreeChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Signature) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *RawTreeChangeWithId) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.RawChange) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Id) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func (m *TreeChange) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if len(m.TreeHeadIds) > 0 { - for _, s := range m.TreeHeadIds { - l = len(s) - n += 1 + l + sovAclchanges(uint64(l)) - } - } - l = len(m.AclHeadId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.SnapshotBaseId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.ChangesData) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.CurrentReadKeyHash != 0 { - n += 1 + sovAclchanges(uint64(m.CurrentReadKeyHash)) - } - if m.Timestamp != 0 { - n += 1 + sovAclchanges(uint64(m.Timestamp)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.IsSnapshot { - n += 2 - } - return n -} - -func (m *TreeHeader) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.FirstId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.AclId) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - if m.TreeHeaderType != 0 { - n += 1 + sovAclchanges(uint64(m.TreeHeaderType)) - } - l = len(m.Identity) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - l = len(m.Data) - if l > 0 { - n += 1 + l + sovAclchanges(uint64(l)) - } - return n -} - -func sovAclchanges(x uint64) (n int) { +func sovAclrecord(x uint64) (n int) { return (math_bits.Len64(x|1) + 6) / 7 } -func sozAclchanges(x uint64) (n int) { - return sovAclchanges(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +func sozAclrecord(x uint64) (n int) { + return sovAclrecord(uint64((x << 1) ^ uint64((int64(x) >> 63)))) } func (m *RawACLRecord) Unmarshal(dAtA []byte) error { l := len(dAtA) @@ -2927,7 +2278,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2955,7 +2306,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -2968,11 +2319,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -2989,7 +2340,7 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -3002,11 +2353,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -3016,14 +2367,98 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { m.Signature = []byte{} } iNdEx = postIndex - case 3: + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawACLRecordWithId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RawACLRecordWithId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawACLRecordWithId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } + iNdEx = postIndex + case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -3037,11 +2472,11 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -3050,1909 +2485,12 @@ func (m *RawACLRecord) Unmarshal(dAtA []byte) error { iNdEx = postIndex default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLContentValue) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLContentValue: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLContentValue: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAdd", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserAdd{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserAdd{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserRemove", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserRemove{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserRemove{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserPermissionChange", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserPermissionChange{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserPermissionChange{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserInvite", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserInvite{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserInvite{v} - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserJoin", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserJoin{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserJoin{v} - iNdEx = postIndex - case 6: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserConfirm", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &ACLUserConfirm{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Value = &ACLContentValue_UserConfirm{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLData) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLData: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLData: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclContent", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclContent = append(m.AclContent, &ACLContentValue{}) - if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType == 0 { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReadKeyHashes = append(m.ReadKeyHashes, v) - } else if wireType == 2 { - var packedLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - packedLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if packedLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + packedLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - var elementCount int - var count int - for _, integer := range dAtA[iNdEx:postIndex] { - if integer < 128 { - count++ - } - } - elementCount = count - if elementCount != 0 && len(m.ReadKeyHashes) == 0 { - m.ReadKeyHashes = make([]uint64, 0, elementCount) - } - for iNdEx < postIndex { - var v uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.ReadKeyHashes = append(m.ReadKeyHashes, v) - } - } else { - return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyHashes", wireType) - } - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserStates", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserStates = append(m.UserStates, &ACLUserState{}) - if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Invites", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - if m.Invites == nil { - m.Invites = make(map[string]*ACLUserInvite) - } - var mapkey string - var mapvalue *ACLUserInvite - for iNdEx < postIndex { - entryPreIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - if fieldNum == 1 { - var stringLenmapkey uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapkey |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapkey := int(stringLenmapkey) - if intStringLenmapkey < 0 { - return ErrInvalidLengthAclchanges - } - postStringIndexmapkey := iNdEx + intStringLenmapkey - if postStringIndexmapkey < 0 { - return ErrInvalidLengthAclchanges - } - if postStringIndexmapkey > l { - return io.ErrUnexpectedEOF - } - mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) - iNdEx = postStringIndexmapkey - } else if fieldNum == 2 { - var mapmsglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - mapmsglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if mapmsglen < 0 { - return ErrInvalidLengthAclchanges - } - postmsgIndex := iNdEx + mapmsglen - if postmsgIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postmsgIndex > l { - return io.ErrUnexpectedEOF - } - mapvalue = &ACLUserInvite{} - if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { - return err - } - iNdEx = postmsgIndex - } else { - iNdEx = entryPreIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > postIndex { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - m.Invites[mapkey] = mapvalue - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserState) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserState: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserState: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsConfirmed", wireType) - } - var v int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - v |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - m.IsConfirmed = bool(v != 0) - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserAdd: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserAdd: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserConfirm) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserConfirm: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserConfirm: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserAddId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserAddId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserInvite: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserInvite: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcceptPublicKey = append(m.AcceptPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.AcceptPublicKey == nil { - m.AcceptPublicKey = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptPublicKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptPublicKey = append(m.EncryptPublicKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptPublicKey == nil { - m.EncryptPublicKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.InviteId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserJoin: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserJoin: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AcceptSignature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AcceptSignature = append(m.AcceptSignature[:0], dAtA[iNdEx:postIndex]...) - if m.AcceptSignature == nil { - m.AcceptSignature = []byte{} - } - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field UserInviteId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.UserInviteId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 5: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) - copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserRemove: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserRemove: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyReplaces", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLReadKeyReplace{}) - if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLReadKeyReplace: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptionKey == nil { - m.EncryptionKey = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) - if m.EncryptedReadKey == nil { - m.EncryptedReadKey = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: ACLUserPermissionChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: ACLUserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) - if m.Identity == nil { - m.Identity = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) - } - m.Permissions = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Permissions |= ACLUserPermissions(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -4974,7 +2512,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5002,7 +2540,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5016,11 +2554,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5034,7 +2572,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5047,11 +2585,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5068,7 +2606,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5081,11 +2619,11 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5102,7 +2640,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { m.CurrentReadKeyHash = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5121,7 +2659,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { m.Timestamp = 0 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5135,12 +2673,12 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5154,7 +2692,7 @@ func (m *ACLRecord) Unmarshal(dAtA []byte) error { } return nil } -func (m *ACLHeader) Unmarshal(dAtA []byte) error { +func (m *ACLRoot) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5162,7 +2700,7 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5177,52 +2715,20 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: ACLHeader: wiretype end group for non-group") + return fmt.Errorf("proto: ACLRoot: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: ACLHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLRoot: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FirstId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FirstId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5235,11 +2741,11 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5249,64 +2755,14 @@ func (m *ACLHeader) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RawTreeChange) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RawTreeChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawTreeChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5319,292 +2775,28 @@ func (m *RawTreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} } iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) - if m.Signature == nil { - m.Signature = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *RawTreeChangeWithId) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: RawTreeChangeWithId: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: RawTreeChangeWithId: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field RawChange", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.RawChange = append(m.RawChange[:0], dAtA[iNdEx:postIndex]...) - if m.RawChange == nil { - m.RawChange = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Id = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *TreeChange) Unmarshal(dAtA []byte) error { - l := len(dAtA) - iNdEx := 0 - for iNdEx < l { - preIndex := iNdEx - var wire uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - wire |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - fieldNum := int32(wire >> 3) - wireType := int(wire & 0x7) - if wireType == 4 { - return fmt.Errorf("proto: TreeChange: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: TreeChange: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeadIds", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.TreeHeadIds = append(m.TreeHeadIds, string(dAtA[iNdEx:postIndex])) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclHeadId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex case 3: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field SnapshotBaseId", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) } var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5618,25 +2810,25 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } intStringLen := int(stringLen) if intStringLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + intStringLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.SnapshotBaseId = string(dAtA[iNdEx:postIndex]) + m.SpaceId = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex case 4: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ChangesData", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5649,66 +2841,708 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.ChangesData = append(m.ChangesData[:0], dAtA[iNdEx:postIndex]...) - if m.ChangesData == nil { - m.ChangesData = []byte{} + m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptedReadKey == nil { + m.EncryptedReadKey = []byte{} } iNdEx = postIndex case 5: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field DerivationScheme", wireType) } - m.CurrentReadKeyHash = 0 + var stringLen uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + stringLen |= uint64(b&0x7F) << shift if b < 0x80 { break } } - case 6: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAclrecord } - m.Timestamp = 0 + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.DerivationScheme = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLContentValue) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLContentValue: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLContentValue: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserAdd", wireType) + } + var msglen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF } b := dAtA[iNdEx] iNdEx++ - m.Timestamp |= int64(b&0x7F) << shift + msglen |= int(b&0x7F) << shift if b < 0x80 { break } } - case 7: + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserAdd{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserAdd{v} + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserRemove", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserRemove{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserRemove{v} + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserPermissionChange", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserPermissionChange{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserPermissionChange{v} + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserInvite", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserInvite{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserInvite{v} + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserJoin", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &ACLUserJoin{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &ACLContentValue_UserJoin{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLData) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLData: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLData: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclContent", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclContent = append(m.AclContent, &ACLContentValue{}) + if err := m.AclContent[len(m.AclContent)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType == 0 { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadKeyHashes = append(m.ReadKeyHashes, v) + } else if wireType == 2 { + var packedLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + packedLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if packedLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + packedLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + var elementCount int + var count int + for _, integer := range dAtA[iNdEx:postIndex] { + if integer < 128 { + count++ + } + } + elementCount = count + if elementCount != 0 && len(m.ReadKeyHashes) == 0 { + m.ReadKeyHashes = make([]uint64, 0, elementCount) + } + for iNdEx < postIndex { + var v uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.ReadKeyHashes = append(m.ReadKeyHashes, v) + } + } else { + return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyHashes", wireType) + } + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field UserStates", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.UserStates = append(m.UserStates, &ACLUserState{}) + if err := m.UserStates[len(m.UserStates)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Invites", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Invites == nil { + m.Invites = make(map[string]*ACLUserInvite) + } + var mapkey string + var mapvalue *ACLUserInvite + for iNdEx < postIndex { + entryPreIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + if fieldNum == 1 { + var stringLenmapkey uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLenmapkey |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLenmapkey := int(stringLenmapkey) + if intStringLenmapkey < 0 { + return ErrInvalidLengthAclrecord + } + postStringIndexmapkey := iNdEx + intStringLenmapkey + if postStringIndexmapkey < 0 { + return ErrInvalidLengthAclrecord + } + if postStringIndexmapkey > l { + return io.ErrUnexpectedEOF + } + mapkey = string(dAtA[iNdEx:postStringIndexmapkey]) + iNdEx = postStringIndexmapkey + } else if fieldNum == 2 { + var mapmsglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + mapmsglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if mapmsglen < 0 { + return ErrInvalidLengthAclrecord + } + postmsgIndex := iNdEx + mapmsglen + if postmsgIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postmsgIndex > l { + return io.ErrUnexpectedEOF + } + mapvalue = &ACLUserInvite{} + if err := mapvalue.Unmarshal(dAtA[iNdEx:postmsgIndex]); err != nil { + return err + } + iNdEx = postmsgIndex + } else { + iNdEx = entryPreIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > postIndex { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + m.Invites[mapkey] = mapvalue + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserState) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLUserState: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserState: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5721,11 +3555,11 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5735,14 +3569,99 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - case 8: + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field IsSnapshot", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsConfirmed", wireType) } var v int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5754,15 +3673,15 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { break } } - m.IsSnapshot = bool(v != 0) + m.IsConfirmed = bool(v != 0) default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5776,7 +3695,7 @@ func (m *TreeChange) Unmarshal(dAtA []byte) error { } return nil } -func (m *TreeHeader) Unmarshal(dAtA []byte) error { +func (m *ACLUserAdd) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 for iNdEx < l { @@ -5784,7 +3703,7 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5799,103 +3718,20 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { fieldNum := int32(wire >> 3) wireType := int(wire & 0x7) if wireType == 4 { - return fmt.Errorf("proto: TreeHeader: wiretype end group for non-group") + return fmt.Errorf("proto: ACLUserAdd: wiretype end group for non-group") } if fieldNum <= 0 { - return fmt.Errorf("proto: TreeHeader: illegal tag %d (wire type %d)", fieldNum, wire) + return fmt.Errorf("proto: ACLUserAdd: illegal tag %d (wire type %d)", fieldNum, wire) } switch fieldNum { case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field FirstId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.FirstId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field AclId", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLen |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLen := int(stringLen) - if intStringLen < 0 { - return ErrInvalidLengthAclchanges - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthAclchanges - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.AclId = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field TreeHeaderType", wireType) - } - m.TreeHeaderType = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.TreeHeaderType |= TreeHeaderType(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: if wireType != 2 { return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5908,11 +3744,11 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF @@ -5922,14 +3758,14 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { m.Identity = []byte{} } iNdEx = postIndex - case 5: + case 2: if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Data", wireType) + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) } var byteLen int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return ErrIntOverflowAclchanges + return ErrIntOverflowAclrecord } if iNdEx >= l { return io.ErrUnexpectedEOF @@ -5942,28 +3778,79 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } } if byteLen < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } postIndex := iNdEx + byteLen if postIndex < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if postIndex > l { return io.ErrUnexpectedEOF } - m.Data = append(m.Data[:0], dAtA[iNdEx:postIndex]...) - if m.Data == nil { - m.Data = []byte{} + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} } iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } default: iNdEx = preIndex - skippy, err := skipAclchanges(dAtA[iNdEx:]) + skippy, err := skipAclrecord(dAtA[iNdEx:]) if err != nil { return err } if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthAclchanges + return ErrInvalidLengthAclrecord } if (iNdEx + skippy) > l { return io.ErrUnexpectedEOF @@ -5977,7 +3864,797 @@ func (m *TreeHeader) Unmarshal(dAtA []byte) error { } return nil } -func skipAclchanges(dAtA []byte) (n int, err error) { +func (m *ACLUserInvite) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLUserInvite: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserInvite: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptPublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptPublicKey = append(m.AcceptPublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptPublicKey == nil { + m.AcceptPublicKey = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptPublicKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptPublicKey = append(m.EncryptPublicKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptPublicKey == nil { + m.EncryptPublicKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InviteId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserJoin) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLUserJoin: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserJoin: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AcceptSignature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AcceptSignature = append(m.AcceptSignature[:0], dAtA[iNdEx:postIndex]...) + if m.AcceptSignature == nil { + m.AcceptSignature = []byte{} + } + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field InviteId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.InviteId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKeys", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKeys = append(m.EncryptedReadKeys, make([]byte, postIndex-iNdEx)) + copy(m.EncryptedReadKeys[len(m.EncryptedReadKeys)-1], dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserRemove) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLUserRemove: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserRemove: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ReadKeyReplaces", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ReadKeyReplaces = append(m.ReadKeyReplaces, &ACLReadKeyReplace{}) + if err := m.ReadKeyReplaces[len(m.ReadKeyReplaces)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLReadKeyReplace) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLReadKeyReplace: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLReadKeyReplace: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptionKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptionKey = append(m.EncryptionKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptionKey == nil { + m.EncryptionKey = []byte{} + } + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field EncryptedReadKey", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.EncryptedReadKey = append(m.EncryptedReadKey[:0], dAtA[iNdEx:postIndex]...) + if m.EncryptedReadKey == nil { + m.EncryptedReadKey = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *ACLUserPermissionChange) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: ACLUserPermissionChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: ACLUserPermissionChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthAclrecord + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthAclrecord + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Permissions", wireType) + } + m.Permissions = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowAclrecord + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Permissions |= ACLUserPermissions(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipAclrecord(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthAclrecord + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipAclrecord(dAtA []byte) (n int, err error) { l := len(dAtA) iNdEx := 0 depth := 0 @@ -5985,7 +4662,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { var wire uint64 for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6002,7 +4679,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { case 0: for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6018,7 +4695,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { var length int for shift := uint(0); ; shift += 7 { if shift >= 64 { - return 0, ErrIntOverflowAclchanges + return 0, ErrIntOverflowAclrecord } if iNdEx >= l { return 0, io.ErrUnexpectedEOF @@ -6031,14 +4708,14 @@ func skipAclchanges(dAtA []byte) (n int, err error) { } } if length < 0 { - return 0, ErrInvalidLengthAclchanges + return 0, ErrInvalidLengthAclrecord } iNdEx += length case 3: depth++ case 4: if depth == 0 { - return 0, ErrUnexpectedEndOfGroupAclchanges + return 0, ErrUnexpectedEndOfGroupAclrecord } depth-- case 5: @@ -6047,7 +4724,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { return 0, fmt.Errorf("proto: illegal wireType %d", wireType) } if iNdEx < 0 { - return 0, ErrInvalidLengthAclchanges + return 0, ErrInvalidLengthAclrecord } if depth == 0 { return iNdEx, nil @@ -6057,7 +4734,7 @@ func skipAclchanges(dAtA []byte) (n int, err error) { } var ( - ErrInvalidLengthAclchanges = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowAclchanges = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupAclchanges = fmt.Errorf("proto: unexpected end of group") + ErrInvalidLengthAclrecord = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowAclrecord = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupAclrecord = fmt.Errorf("proto: unexpected end of group") ) diff --git a/pkg/acl/aclrecordproto/protos/aclrecord.proto b/pkg/acl/aclrecordproto/protos/aclrecord.proto new file mode 100644 index 00000000..01b5aa6f --- /dev/null +++ b/pkg/acl/aclrecordproto/protos/aclrecord.proto @@ -0,0 +1,102 @@ +syntax = "proto3"; +package aclrecord; +option go_package = "pkg/acl/aclrecordproto"; + +message RawACLRecord { + bytes payload = 1; + bytes signature = 2; +} + +message RawACLRecordWithId { + bytes payload = 1; + string id = 2; +} + +message ACLRecord { + string prevId = 1; + bytes identity = 2; + bytes data = 3; + uint64 currentReadKeyHash = 4; + int64 timestamp = 5; +} + +message ACLRoot { + bytes identity = 1; + bytes encryptionKey = 2; + string spaceId = 3; + bytes encryptedReadKey = 4; + string derivationScheme = 5; +} + +message ACLContentValue { + oneof value { + ACLUserAdd userAdd = 1; + ACLUserRemove userRemove = 2; + ACLUserPermissionChange userPermissionChange = 3; + ACLUserInvite userInvite = 4; + ACLUserJoin userJoin = 5; + } +} + +message ACLData { + repeated ACLContentValue aclContent = 1; +} + +message ACLState { + repeated uint64 readKeyHashes = 1; + repeated ACLUserState userStates = 2; + map invites = 3; +} + +message ACLUserState { + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; + bool isConfirmed = 5; +} + +message ACLUserAdd { + bytes identity = 1; + bytes encryptionKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; +} + +message ACLUserInvite { + bytes acceptPublicKey = 1; + bytes encryptPublicKey = 2; + repeated bytes encryptedReadKeys = 3; + ACLUserPermissions permissions = 4; + string inviteId = 5; +} + +message ACLUserJoin { + bytes identity = 1; + bytes encryptionKey = 2; + bytes acceptSignature = 3; + string inviteId = 4; + repeated bytes encryptedReadKeys = 5; +} + +message ACLUserRemove { + bytes identity = 1; + repeated ACLReadKeyReplace readKeyReplaces = 3; +} + +message ACLReadKeyReplace { + bytes identity = 1; + bytes encryptionKey = 2; + bytes encryptedReadKey = 3; +} + +message ACLUserPermissionChange { + bytes identity = 1; + ACLUserPermissions permissions = 2; +} + +enum ACLUserPermissions { + Admin = 0; + Writer = 1; + Reader = 2; +} diff --git a/pkg/acl/list/aclstate.go b/pkg/acl/list/aclstate.go index 91b3bb47..27416972 100644 --- a/pkg/acl/list/aclstate.go +++ b/pkg/acl/list/aclstate.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" @@ -30,14 +30,14 @@ var ErrInvalidSignature = errors.New("signature is invalid") type UserPermissionPair struct { Identity string - Permission aclpb.ACLUserPermissions + Permission aclrecordproto.ACLUserPermissions } type ACLState struct { currentReadKeyHash uint64 userReadKeys map[uint64]*symmetric.Key - userStates map[string]*aclpb.ACLUserState - userInvites map[string]*aclpb.ACLUserInvite + userStates map[string]*aclrecordproto.ACLUserState + userInvites map[string]*aclrecordproto.ACLUserInvite signingPubKeyDecoder keys.Decoder encryptionKey encryptionkey.PrivKey @@ -56,8 +56,8 @@ func newACLStateWithIdentity( identity: identity, encryptionKey: encryptionKey, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLUserState), - userInvites: make(map[string]*aclpb.ACLUserInvite), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), signingPubKeyDecoder: decoder, permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), @@ -68,8 +68,8 @@ func newACLState(decoder keys.Decoder) *ACLState { return &ACLState{ signingPubKeyDecoder: decoder, userReadKeys: make(map[uint64]*symmetric.Key), - userStates: make(map[string]*aclpb.ACLUserState), - userInvites: make(map[string]*aclpb.ACLUserInvite), + userStates: make(map[string]*aclrecordproto.ACLUserState), + userInvites: make(map[string]*aclrecordproto.ACLUserInvite), permissionsAtRecord: make(map[string][]UserPermissionPair), keychain: common.NewKeychain(), } @@ -106,8 +106,8 @@ func (st *ACLState) PermissionsAtRecord(id string, identity string) (UserPermiss return UserPermissionPair{}, ErrNoSuchUser } -func (st *ACLState) applyRecord(record *aclpb.ACLRecord) (err error) { - aclData := &aclpb.ACLData{} +func (st *ACLState) applyRecord(record *aclrecordproto.ACLRecord) (err error) { + aclData := &aclrecordproto.ACLData{} err = proto.Unmarshal(record.Data, aclData) if err != nil { @@ -126,11 +126,11 @@ func (st *ACLState) applyRecord(record *aclpb.ACLRecord) (err error) { func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { var ( change = recordWrapper.Content - aclData = &aclpb.ACLData{} + aclData = &aclrecordproto.ACLData{} ) if recordWrapper.Model != nil { - aclData = recordWrapper.Model.(*aclpb.ACLData) + aclData = recordWrapper.Model.(*aclrecordproto.ACLData) } else { err = proto.Unmarshal(change.Data, aclData) if err != nil { @@ -158,7 +158,7 @@ func (st *ACLState) applyChangeAndUpdate(recordWrapper *ACLRecord) (err error) { return nil } -func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, identity []byte) (err error) { +func (st *ACLState) applyChangeData(changeData *aclrecordproto.ACLData, hash uint64, identity []byte) (err error) { defer func() { if err != nil { return @@ -176,7 +176,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden return } - if !st.hasPermission(identity, aclpb.ACLUserPermissions_Admin) { + if !st.hasPermission(identity, aclrecordproto.ACLUserPermissions_Admin) { err = fmt.Errorf("user %s must have admin permissions", identity) return } @@ -192,7 +192,7 @@ func (st *ACLState) applyChangeData(changeData *aclpb.ACLData, hash uint64, iden return nil } -func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { +func (st *ACLState) applyChangeContent(ch *aclrecordproto.ACLContentValue) error { switch { case ch.GetUserPermissionChange() != nil: return st.applyUserPermissionChange(ch.GetUserPermissionChange()) @@ -211,7 +211,7 @@ func (st *ACLState) applyChangeContent(ch *aclpb.ACLContentValue) error { } } -func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) error { +func (st *ACLState) applyUserPermissionChange(ch *aclrecordproto.ACLUserPermissionChange) error { chIdentity := string(ch.Identity) state, exists := st.userStates[chIdentity] if !exists { @@ -222,12 +222,12 @@ func (st *ACLState) applyUserPermissionChange(ch *aclpb.ACLUserPermissionChange) return nil } -func (st *ACLState) applyUserInvite(ch *aclpb.ACLUserInvite) error { +func (st *ACLState) applyUserInvite(ch *aclrecordproto.ACLUserInvite) error { st.userInvites[ch.InviteId] = ch return nil } -func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { +func (st *ACLState) applyUserJoin(ch *aclrecordproto.ACLUserJoin) error { invite, exists := st.userInvites[ch.UserInviteId] if !exists { return fmt.Errorf("no such invite with id %s", ch.UserInviteId) @@ -266,7 +266,7 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { } // adding user to the list - userState := &aclpb.ACLUserState{ + userState := &aclrecordproto.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, EncryptedReadKeys: ch.EncryptedReadKeys, @@ -277,13 +277,13 @@ func (st *ACLState) applyUserJoin(ch *aclpb.ACLUserJoin) error { return nil } -func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { +func (st *ACLState) applyUserAdd(ch *aclrecordproto.ACLUserAdd) error { chIdentity := string(ch.Identity) if _, exists := st.userStates[chIdentity]; exists { return ErrUserAlreadyExists } - st.userStates[chIdentity] = &aclpb.ACLUserState{ + st.userStates[chIdentity] = &aclrecordproto.ACLUserState{ Identity: ch.Identity, EncryptionKey: ch.EncryptionKey, Permissions: ch.Permissions, @@ -304,7 +304,7 @@ func (st *ACLState) applyUserAdd(ch *aclpb.ACLUserAdd) error { return nil } -func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { +func (st *ACLState) applyUserRemove(ch *aclrecordproto.ACLUserRemove) error { chIdentity := string(ch.Identity) if chIdentity == st.identity { return ErrDocumentForbidden @@ -338,7 +338,7 @@ func (st *ACLState) applyUserRemove(ch *aclpb.ACLUserRemove) error { return nil } -func (st *ACLState) applyUserConfirm(ch *aclpb.ACLUserConfirm) error { +func (st *ACLState) applyUserConfirm(ch *aclrecordproto.ACLUserConfirm) error { chIdentity := string(ch.Identity) state, exists := st.userStates[chIdentity] if !exists { @@ -365,7 +365,7 @@ func (st *ACLState) decryptReadKeyAndHash(msg []byte) (*symmetric.Key, uint64, e return key, hasher.Sum64(), nil } -func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermissions) bool { +func (st *ACLState) hasPermission(identity []byte, permission aclrecordproto.ACLUserPermissions) bool { state, exists := st.userStates[string(identity)] if !exists { return false @@ -374,17 +374,17 @@ func (st *ACLState) hasPermission(identity []byte, permission aclpb.ACLUserPermi return state.Permissions == permission } -func (st *ACLState) isUserJoin(data *aclpb.ACLData) bool { +func (st *ACLState) isUserJoin(data *aclrecordproto.ACLData) bool { // if we have a UserJoin, then it should always be the first one applied return data.GetAclContent() != nil && data.GetAclContent()[0].GetUserJoin() != nil } -func (st *ACLState) isUserAdd(data *aclpb.ACLData, identity []byte) bool { +func (st *ACLState) isUserAdd(data *aclrecordproto.ACLData, identity []byte) bool { // if we have a UserAdd, then it should always be the first one applied userAdd := data.GetAclContent()[0].GetUserAdd() return data.GetAclContent() != nil && userAdd != nil && bytes.Compare(userAdd.GetIdentity(), identity) == 0 } -func (st *ACLState) GetUserStates() map[string]*aclpb.ACLUserState { +func (st *ACLState) GetUserStates() map[string]*aclrecordproto.ACLUserState { return st.userStates } diff --git a/pkg/acl/list/changebuilder.go b/pkg/acl/list/changebuilder.go index c6413cb0..f56e5259 100644 --- a/pkg/acl/list/changebuilder.go +++ b/pkg/acl/list/changebuilder.go @@ -2,7 +2,7 @@ package list import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/encryptionkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" diff --git a/pkg/acl/list/list.go b/pkg/acl/list/list.go index 3cfedd06..d20d5b69 100644 --- a/pkg/acl/list/list.go +++ b/pkg/acl/list/list.go @@ -5,7 +5,7 @@ import ( "errors" "fmt" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" @@ -60,7 +60,7 @@ func BuildACLList(decoder keys.Decoder, storage storage.ListStorage) (ACLList, e } func buildWithACLStateBuilder(builder *aclStateBuilder, storage storage.ListStorage) (list ACLList, err error) { - header, err := storage.Header() + header, err := storage.Root() if err != nil { return } diff --git a/pkg/acl/list/list_test.go b/pkg/acl/list/list_test.go index fd249cfb..d36cd373 100644 --- a/pkg/acl/list/list_test.go +++ b/pkg/acl/list/list_test.go @@ -1,7 +1,7 @@ package list import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" diff --git a/pkg/acl/list/record.go b/pkg/acl/list/record.go index 1cf10e59..04f4abbf 100644 --- a/pkg/acl/list/record.go +++ b/pkg/acl/list/record.go @@ -1,19 +1,19 @@ package list import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/gogo/protobuf/proto" ) type ACLRecord struct { Id string - Content *aclpb.ACLRecord + Content *aclrecordproto.ACLRecord Identity string Model interface{} Sign []byte } -func NewRecord(id string, aclRecord *aclpb.ACLRecord) *ACLRecord { +func NewRecord(id string, aclRecord *aclrecordproto.ACLRecord) *ACLRecord { return &ACLRecord{ Id: id, Content: aclRecord, @@ -21,17 +21,45 @@ func NewRecord(id string, aclRecord *aclpb.ACLRecord) *ACLRecord { } } -func NewFromRawRecord(rawRec *aclpb.RawACLRecord) (*ACLRecord, error) { - aclRec := &aclpb.ACLRecord{} - err := proto.Unmarshal(rawRec.Payload, aclRec) +func NewFromRawRecord(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { + rawRec := &aclrecordproto.RawACLRecord{} + err = proto.Unmarshal(rawRecWithId.Payload, rawRec) if err != nil { - return nil, err + return + } + + protoAclRec := &aclrecordproto.ACLRecord{} + err = proto.Unmarshal(rawRec.Payload, protoAclRec) + if err != nil { + return } return &ACLRecord{ - Id: rawRec.Id, - Content: aclRec, + Id: rawRecWithId.Id, + Content: protoAclRec, Sign: rawRec.Signature, - Identity: string(aclRec.Identity), + Identity: string(protoAclRec.Identity), }, nil } + +func NewFromRawRoot(rawRecWithId *aclrecordproto.RawACLRecordWithId) (aclRec *ACLRecord, err error) { + rawRec := &aclrecordproto.RawACLRecord{} + err = proto.Unmarshal(rawRecWithId.Payload, rawRec) + if err != nil { + return + } + + protoAclRec := &aclrecordproto.ACLRecord{} + err = proto.Unmarshal(rawRec.Payload, protoAclRec) + if err != nil { + return + } + + return &ACLRecord{ + Id: rawRecWithId.Id, + Content: protoAclRec, + Sign: rawRec.Signature, + Identity: string(protoAclRec.Identity), + }, nil +} + diff --git a/pkg/acl/storage/inmemory.go b/pkg/acl/storage/inmemory.go index 7f6af367..1e200e68 100644 --- a/pkg/acl/storage/inmemory.go +++ b/pkg/acl/storage/inmemory.go @@ -3,44 +3,41 @@ package storage import ( "context" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "sync" ) type inMemoryACLListStorage struct { - header *aclpb.ACLHeader - records []*aclpb.RawACLRecord - - id string + records []*aclrecordproto.RawACLRecordWithId + id string sync.RWMutex } func NewInMemoryACLListStorage( id string, - header *aclpb.ACLHeader, - records []*aclpb.RawACLRecord) (ListStorage, error) { + records []*aclrecordproto.RawACLRecordWithId) (ListStorage, error) { return &inMemoryACLListStorage{ id: id, - header: header, records: records, RWMutex: sync.RWMutex{}, }, nil } -func (i *inMemoryACLListStorage) Header() (*aclpb.ACLHeader, error) { +func (i *inMemoryACLListStorage) Root() (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() - return i.header, nil + return i.records[0], nil } -func (i *inMemoryACLListStorage) Head() (*aclpb.RawACLRecord, error) { +func (i *inMemoryACLListStorage) Head() (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() return i.records[len(i.records)-1], nil } -func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) { +func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) { i.RLock() defer i.RUnlock() for _, rec := range i.records { @@ -51,7 +48,7 @@ func (i *inMemoryACLListStorage) GetRawRecord(ctx context.Context, id string) (* return nil, fmt.Errorf("no such record") } -func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error { +func (i *inMemoryACLListStorage) AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error { panic("implement me") } @@ -63,26 +60,27 @@ func (i *inMemoryACLListStorage) ID() (string, error) { type inMemoryTreeStorage struct { id string - header *aclpb.TreeHeader + root *treechangeproto.RawTreeChangeWithId heads []string - changes map[string]*aclpb.RawTreeChangeWithId + changes map[string]*treechangeproto.RawTreeChangeWithId sync.RWMutex } func NewInMemoryTreeStorage( treeId string, - header *aclpb.TreeHeader, + root *treechangeproto.RawTreeChangeWithId, heads []string, - changes []*aclpb.RawTreeChangeWithId) (TreeStorage, error) { - allChanges := make(map[string]*aclpb.RawTreeChangeWithId) + changes []*treechangeproto.RawTreeChangeWithId) (TreeStorage, error) { + allChanges := make(map[string]*treechangeproto.RawTreeChangeWithId) for _, ch := range changes { allChanges[ch.Id] = ch } + allChanges[treeId] = root return &inMemoryTreeStorage{ id: treeId, - header: header, + root: root, heads: heads, changes: allChanges, RWMutex: sync.RWMutex{}, @@ -95,10 +93,10 @@ func (t *inMemoryTreeStorage) ID() (string, error) { return t.id, nil } -func (t *inMemoryTreeStorage) Header() (*aclpb.TreeHeader, error) { +func (t *inMemoryTreeStorage) Root() (*treechangeproto.RawTreeChangeWithId, error) { t.RLock() defer t.RUnlock() - return t.header, nil + return t.root, nil } func (t *inMemoryTreeStorage) Heads() ([]string, error) { @@ -118,7 +116,7 @@ func (t *inMemoryTreeStorage) SetHeads(heads []string) error { return nil } -func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawTreeChangeWithId) error { +func (t *inMemoryTreeStorage) AddRawChange(change *treechangeproto.RawTreeChangeWithId) error { t.Lock() defer t.Unlock() // TODO: better to do deep copy @@ -126,7 +124,7 @@ func (t *inMemoryTreeStorage) AddRawChange(change *aclpb.RawTreeChangeWithId) er return nil } -func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*aclpb.RawTreeChangeWithId, error) { +func (t *inMemoryTreeStorage) GetRawChange(ctx context.Context, changeId string) (*treechangeproto.RawTreeChangeWithId, error) { t.RLock() defer t.RUnlock() if res, exists := t.changes[changeId]; exists { @@ -163,7 +161,7 @@ func (i *inMemoryStorageProvider) Storage(id string) (Storage, error) { func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) { i.Lock() defer i.Unlock() - res, err := NewInMemoryTreeStorage(payload.TreeId, payload.Header, payload.Heads, payload.Changes) + res, err := NewInMemoryTreeStorage(payload.TreeId, payload.RootRawChange, payload.Heads, payload.Changes) if err != nil { return nil, err } @@ -175,7 +173,7 @@ func (i *inMemoryStorageProvider) CreateTreeStorage(payload TreeStorageCreatePay func (i *inMemoryStorageProvider) CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) { i.Lock() defer i.Unlock() - res, err := NewInMemoryACLListStorage(payload.ListId, payload.Header, payload.Records) + res, err := NewInMemoryACLListStorage(payload.ListId, payload.Records) if err != nil { return nil, err } diff --git a/pkg/acl/storage/liststorage.go b/pkg/acl/storage/liststorage.go index ccb5b5da..c4fe7d6e 100644 --- a/pkg/acl/storage/liststorage.go +++ b/pkg/acl/storage/liststorage.go @@ -2,14 +2,14 @@ package storage import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" ) type ListStorage interface { Storage - Header() (*aclpb.ACLHeader, error) - Head() (*aclpb.RawACLRecord, error) + Root() (*aclrecordproto.RawACLRecordWithId, error) + Head() (*aclrecordproto.RawACLRecordWithId, error) - GetRawRecord(ctx context.Context, id string) (*aclpb.RawACLRecord, error) - AddRawRecord(ctx context.Context, rec *aclpb.RawACLRecord) error + GetRawRecord(ctx context.Context, id string) (*aclrecordproto.RawACLRecordWithId, error) + AddRawRecord(ctx context.Context, rec *aclrecordproto.RawACLRecordWithId) error } diff --git a/pkg/acl/storage/provider.go b/pkg/acl/storage/provider.go index 984b21c4..3c2c7d91 100644 --- a/pkg/acl/storage/provider.go +++ b/pkg/acl/storage/provider.go @@ -2,27 +2,26 @@ package storage import ( "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) var ErrUnknownTreeId = errors.New("tree does not exist") type TreeStorageCreatePayload struct { - TreeId string - Header *aclpb.TreeHeader - Changes []*aclpb.RawTreeChangeWithId - Heads []string + TreeId string + RootRawChange *treechangeproto.RawTreeChangeWithId + Changes []*treechangeproto.RawTreeChangeWithId + Heads []string } type ACLListStorageCreatePayload struct { ListId string - Header *aclpb.ACLHeader - Records []*aclpb.RawACLRecord + Records []*aclrecordproto.RawACLRecordWithId } type Provider interface { Storage(id string) (Storage, error) - AddStorage(id string, st Storage) error CreateTreeStorage(payload TreeStorageCreatePayload) (TreeStorage, error) CreateACLListStorage(payload ACLListStorageCreatePayload) (ListStorage, error) } diff --git a/pkg/acl/storage/treestorage.go b/pkg/acl/storage/treestorage.go index 0e7d09a1..a9c98f1d 100644 --- a/pkg/acl/storage/treestorage.go +++ b/pkg/acl/storage/treestorage.go @@ -2,17 +2,17 @@ package storage import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) type TreeStorage interface { Storage - Header() (*aclpb.TreeHeader, error) + Root() (*treechangeproto.RawTreeChangeWithId, error) Heads() ([]string, error) SetHeads(heads []string) error - AddRawChange(change *aclpb.RawTreeChangeWithId) error - GetRawChange(ctx context.Context, recordID string) (*aclpb.RawTreeChangeWithId, error) + AddRawChange(change *treechangeproto.RawTreeChangeWithId) error + GetRawChange(ctx context.Context, id string) (*treechangeproto.RawTreeChangeWithId, error) } type TreeStorageCreatorFunc = func(payload TreeStorageCreatePayload) (TreeStorage, error) diff --git a/pkg/acl/tree/change.go b/pkg/acl/tree/change.go index cefc9327..43e9f654 100644 --- a/pkg/acl/tree/change.go +++ b/pkg/acl/tree/change.go @@ -2,11 +2,7 @@ package tree import ( "errors" - "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" - "github.com/gogo/protobuf/proto" - - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" ) var ( @@ -14,68 +10,52 @@ var ( ErrIncorrectCID = errors.New("change has incorrect CID") ) -type ChangeContent struct { - ChangesData proto.Marshaler - ACLData *aclpb.ACLData - Id string // TODO: this is just for testing, because id should be created automatically from content -} - // Change is an abstract type for all types of changes type Change struct { - Next []*Change - PreviousIds []string - Id string - SnapshotId string - IsSnapshot bool - DecryptedChange []byte // TODO: check if we need it - ParsedModel interface{} // TODO: check if we need it + Next []*Change + PreviousIds []string + AclHeadId string + Id string + SnapshotId string + IsSnapshot bool + Timestamp int64 + ReadKeyHash uint64 + Identity string + Data []byte + Model interface{} // iterator helpers visited bool branchesFinished bool - Content *aclpb.TreeChange - Identity string - Sign []byte + Signature []byte } -func (ch *Change) ProtoChange() proto.Marshaler { - return ch.Content -} - -func (ch *Change) DecryptContents(key *symmetric.Key) error { - // if the document is already decrypted - if ch.Content.CurrentReadKeyHash == 0 { - return nil - } - decrypted, err := key.Decrypt(ch.Content.ChangesData) - if err != nil { - return fmt.Errorf("failed to decrypt changes data: %w", err) - } - - ch.DecryptedChange = decrypted - return nil -} - -func NewChange(id string, ch *aclpb.TreeChange, signature []byte) *Change { +func NewChange(id string, ch *treechangeproto.TreeChange, signature []byte) *Change { return &Change{ Next: nil, PreviousIds: ch.TreeHeadIds, + AclHeadId: ch.AclHeadId, + Timestamp: ch.Timestamp, + ReadKeyHash: ch.CurrentReadKeyHash, Id: id, - Content: ch, + Data: ch.ChangesData, SnapshotId: ch.SnapshotBaseId, IsSnapshot: ch.IsSnapshot, Identity: string(ch.Identity), - Sign: signature, + Signature: signature, } } -func (ch *Change) DecryptedChangeContent() []byte { - return ch.DecryptedChange -} - -func (ch *Change) Signature() []byte { - return ch.Sign +func NewChangeFromRoot(id string, ch *treechangeproto.RootChange, signature []byte) *Change { + return &Change{ + Next: nil, + AclHeadId: ch.AclHeadId, + Id: id, + IsSnapshot: true, + Identity: string(ch.Identity), + Signature: signature, + } } func (ch *Change) CID() string { diff --git a/pkg/acl/tree/changebuilder.go b/pkg/acl/tree/changebuilder.go index 7b478fd8..1a2e207b 100644 --- a/pkg/acl/tree/changebuilder.go +++ b/pkg/acl/tree/changebuilder.go @@ -2,8 +2,8 @@ package tree import ( "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" @@ -14,32 +14,44 @@ import ( var ErrEmptyChange = errors.New("change payload should not be empty") type BuilderContent struct { - treeHeadIds []string - aclHeadId string - snapshotBaseId string - currentReadKeyHash uint64 - identity []byte - isSnapshot bool - signingKey signingkey.PrivKey - readKey *symmetric.Key - content []byte + TreeHeadIds []string + AclHeadId string + SnapshotBaseId string + CurrentReadKeyHash uint64 + Identity []byte + IsSnapshot bool + SigningKey signingkey.PrivKey + ReadKey *symmetric.Key + Content []byte +} + +type InitialContent struct { + AclHeadId string + Identity []byte + SigningKey signingkey.PrivKey + SpaceId string + Seed []byte + ChangeType string } type ChangeBuilder interface { - ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) - BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) - BuildRaw(ch *Change) (*aclpb.RawTreeChangeWithId, error) + ConvertFromRaw(rawIdChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) + BuildContent(payload BuilderContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) + BuildInitialContent(payload InitialContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) + BuildRaw(ch *Change) (*treechangeproto.RawTreeChangeWithId, error) + SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) } type changeBuilder struct { - keys *common.Keychain + rootChange *treechangeproto.RawTreeChangeWithId + keys *common.Keychain } -func newChangeBuilder(keys *common.Keychain) ChangeBuilder { - return &changeBuilder{keys: keys} +func newChangeBuilder(keys *common.Keychain, rootChange *treechangeproto.RawTreeChangeWithId) ChangeBuilder { + return &changeBuilder{keys: keys, rootChange: rootChange} } -func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { +func (c *changeBuilder) ConvertFromRaw(rawIdChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) { if rawIdChange.GetRawChange() == nil { err = ErrEmptyChange return @@ -53,7 +65,7 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } } - raw := &aclpb.RawTreeChange{} // TODO: sync pool + raw := &treechangeproto.RawTreeChange{} // TODO: sync pool err = proto.Unmarshal(rawIdChange.GetRawChange(), raw) if err != nil { return @@ -78,28 +90,69 @@ func (c *changeBuilder) ConvertFromRaw(rawIdChange *aclpb.RawTreeChangeWithId, v } } - unmarshalled := &aclpb.TreeChange{} - err = proto.Unmarshal(raw.Payload, unmarshalled) + return c.unmarshallRawChange(raw, rawIdChange.Id) +} + +func (c *changeBuilder) SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) { + c.rootChange = rawIdChange +} + +func (c *changeBuilder) BuildInitialContent(payload InitialContent) (ch *Change, rawIdChange *treechangeproto.RawTreeChangeWithId, err error) { + change := &treechangeproto.RootChange{ + AclHeadId: payload.AclHeadId, + Timestamp: int64(time.Now().Nanosecond()), + Identity: payload.Identity, + ChangeType: payload.ChangeType, + SpaceId: payload.SpaceId, + Seed: payload.Seed, + } + + marshalledChange, err := proto.Marshal(change) if err != nil { return } - ch = NewChange(rawIdChange.Id, unmarshalled, raw.Signature) + signature, err := payload.SigningKey.Sign(marshalledChange) + if err != nil { + return + } + + raw := &treechangeproto.RawTreeChange{ + Payload: marshalledChange, + Signature: signature, + } + + marshalledRawChange, err := proto.Marshal(raw) + if err != nil { + return + } + + id, err := cid.NewCIDFromBytes(marshalledRawChange) + if err != nil { + return + } + + ch = NewChangeFromRoot(id, change, signature) + + rawIdChange = &treechangeproto.RawTreeChangeWithId{ + RawChange: marshalledRawChange, + Id: id, + } return } -func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdChange *aclpb.RawTreeChangeWithId, err error) { - change := &aclpb.TreeChange{ - TreeHeadIds: payload.treeHeadIds, - AclHeadId: payload.aclHeadId, - SnapshotBaseId: payload.snapshotBaseId, - CurrentReadKeyHash: payload.currentReadKeyHash, +func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdChange *treechangeproto.RawTreeChangeWithId, err error) { + change := &treechangeproto.TreeChange{ + TreeHeadIds: payload.TreeHeadIds, + AclHeadId: payload.AclHeadId, + SnapshotBaseId: payload.SnapshotBaseId, + CurrentReadKeyHash: payload.CurrentReadKeyHash, Timestamp: int64(time.Now().Nanosecond()), - Identity: payload.identity, - IsSnapshot: payload.isSnapshot, + Identity: payload.Identity, + IsSnapshot: payload.IsSnapshot, } - encrypted, err := payload.readKey.Encrypt(payload.content) + encrypted, err := payload.ReadKey.Encrypt(payload.Content) if err != nil { return } @@ -110,12 +163,12 @@ func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdC return } - signature, err := payload.signingKey.Sign(marshalledChange) + signature, err := payload.SigningKey.Sign(marshalledChange) if err != nil { return } - raw := &aclpb.RawTreeChange{ + raw := &treechangeproto.RawTreeChange{ Payload: marshalledChange, Signature: signature, } @@ -131,33 +184,67 @@ func (c *changeBuilder) BuildContent(payload BuilderContent) (ch *Change, rawIdC } ch = NewChange(id, change, signature) - ch.ParsedModel = payload.content + ch.Model = payload.Content - rawIdChange = &aclpb.RawTreeChangeWithId{ + rawIdChange = &treechangeproto.RawTreeChangeWithId{ RawChange: marshalledRawChange, Id: id, } return } -func (c *changeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { +func (c *changeBuilder) BuildRaw(ch *Change) (raw *treechangeproto.RawTreeChangeWithId, err error) { + if ch.Id == c.rootChange.Id { + return c.rootChange, nil + } + treeChange := &treechangeproto.TreeChange{ + TreeHeadIds: ch.PreviousIds, + AclHeadId: ch.AclHeadId, + SnapshotBaseId: ch.SnapshotId, + ChangesData: ch.Data, + CurrentReadKeyHash: ch.ReadKeyHash, + Timestamp: ch.Timestamp, + Identity: []byte(ch.Identity), + IsSnapshot: ch.IsSnapshot, + } var marshalled []byte - marshalled, err = ch.Content.Marshal() + marshalled, err = treeChange.Marshal() if err != nil { return } - marshalledRawChange, err := proto.Marshal(&aclpb.RawTreeChange{ + marshalledRawChange, err := proto.Marshal(&treechangeproto.RawTreeChange{ Payload: marshalled, - Signature: ch.Sign, + Signature: ch.Signature, }) if err != nil { return } - raw = &aclpb.RawTreeChangeWithId{ + raw = &treechangeproto.RawTreeChangeWithId{ RawChange: marshalledRawChange, Id: ch.Id, } return } + +func (c *changeBuilder) unmarshallRawChange(raw *treechangeproto.RawTreeChange, id string) (ch *Change, err error) { + if c.rootChange.Id == id { + unmarshalled := &treechangeproto.RootChange{} + err = proto.Unmarshal(raw.Payload, unmarshalled) + if err != nil { + return + } + ch = NewChangeFromRoot(id, unmarshalled, raw.Signature) + return + } + + unmarshalled := &treechangeproto.TreeChange{} + err = proto.Unmarshal(raw.Payload, unmarshalled) + if err != nil { + return + } + + ch = NewChange(id, unmarshalled, raw.Signature) + return +} diff --git a/pkg/acl/tree/changevalidator.go b/pkg/acl/tree/changevalidator.go index bbc337cf..220eccb3 100644 --- a/pkg/acl/tree/changevalidator.go +++ b/pkg/acl/tree/changevalidator.go @@ -2,7 +2,7 @@ package tree import ( "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" ) @@ -43,12 +43,12 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c state = aclList.ACLState() ) // checking if the user could write - perm, err = state.PermissionsAtRecord(c.Content.AclHeadId, c.Identity) + perm, err = state.PermissionsAtRecord(c.AclHeadId, c.Identity) if err != nil { return } - if perm.Permission != aclpb.ACLUserPermissions_Writer && perm.Permission != aclpb.ACLUserPermissions_Admin { + if perm.Permission != aclrecordproto.ACLUserPermissions_Writer && perm.Permission != aclrecordproto.ACLUserPermissions_Admin { err = list.ErrInsufficientPermissions return } @@ -56,16 +56,16 @@ func (v *objectTreeValidator) validateChange(tree *Tree, aclList list.ACLList, c // checking if the change refers to later acl heads than its previous ids for _, id := range c.PreviousIds { prevChange := tree.attached[id] - if prevChange.Content.AclHeadId == c.Content.AclHeadId { + if prevChange.AclHeadId == c.AclHeadId { continue } var after bool - after, err = aclList.IsAfter(c.Content.AclHeadId, prevChange.Content.AclHeadId) + after, err = aclList.IsAfter(c.AclHeadId, prevChange.AclHeadId) if err != nil { return } if !after { - err = fmt.Errorf("current acl head id (%s) should be after each of the previous ones (%s)", c.Content.AclHeadId, prevChange.Content.AclHeadId) + err = fmt.Errorf("current acl head id (%s) should be after each of the previous ones (%s)", c.AclHeadId, prevChange.AclHeadId) return } } diff --git a/pkg/acl/tree/objecttree.go b/pkg/acl/tree/objecttree.go index 7c1df882..115ce87e 100644 --- a/pkg/acl/tree/objecttree.go +++ b/pkg/acl/tree/objecttree.go @@ -3,10 +3,10 @@ package tree import ( "context" "errors" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/common" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "sync" ) @@ -27,7 +27,7 @@ type AddResultSummary int type AddResult struct { OldHeads []string Heads []string - Added []*aclpb.RawTreeChangeWithId + Added []*treechangeproto.RawTreeChangeWithId Mode Mode } @@ -39,7 +39,7 @@ type ObjectTree interface { RWLocker ID() string - Header() *aclpb.TreeHeader + Header() *treechangeproto.RootChange Heads() []string Root() *Change HasChange(string) bool @@ -49,12 +49,12 @@ type ObjectTree interface { IterateFrom(id string, convert ChangeConvertFunc, iterate ChangeIterateFunc) error SnapshotPath() []string - ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*aclpb.RawTreeChangeWithId, error) + ChangesAfterCommonSnapshot(snapshotPath, heads []string) ([]*treechangeproto.RawTreeChangeWithId, error) Storage() storage.TreeStorage AddContent(ctx context.Context, content SignableChangeContent) (AddResult, error) - AddRawChanges(ctx context.Context, changes ...*aclpb.RawTreeChangeWithId) (AddResult, error) + AddRawChanges(ctx context.Context, changes ...*treechangeproto.RawTreeChangeWithId) (AddResult, error) Close() error } @@ -67,14 +67,14 @@ type objectTree struct { treeBuilder *treeBuilder aclList list.ACLList - id string - header *aclpb.TreeHeader - tree *Tree + id string + root *treechangeproto.RootChange + tree *Tree keys map[uint64]*symmetric.Key // buffers - difSnapshotBuf []*aclpb.RawTreeChangeWithId + difSnapshotBuf []*treechangeproto.RawTreeChangeWithId tmpChangesBuf []*Change newSnapshotsBuf []*Change notSeenIdxBuf []int @@ -94,11 +94,12 @@ type objectTreeDeps struct { } func defaultObjectTreeDeps( + rootChange *treechangeproto.RawTreeChangeWithId, treeStorage storage.TreeStorage, aclList list.ACLList) objectTreeDeps { keychain := common.NewKeychain() - changeBuilder := newChangeBuilder(keychain) + changeBuilder := newChangeBuilder(keychain, rootChange) treeBuilder := newTreeBuilder(treeStorage, changeBuilder) return objectTreeDeps{ changeBuilder: changeBuilder, @@ -131,8 +132,8 @@ func (ot *objectTree) ID() string { return ot.id } -func (ot *objectTree) Header() *aclpb.TreeHeader { - return ot.header +func (ot *objectTree) Header() *treechangeproto.RootChange { + return ot.root } func (ot *objectTree) Storage() storage.TreeStorage { @@ -172,7 +173,7 @@ func (ot *objectTree) AddContent(ctx context.Context, content SignableChangeCont res = AddResult{ OldHeads: oldHeads, Heads: []string{objChange.Id}, - Added: []*aclpb.RawTreeChangeWithId{rawChange}, + Added: []*treechangeproto.RawTreeChangeWithId{rawChange}, Mode: Append, } return @@ -188,20 +189,20 @@ func (ot *objectTree) prepareBuilderContent(content SignableChangeContent) (cnt return } cnt = BuilderContent{ - treeHeadIds: ot.tree.Heads(), - aclHeadId: ot.aclList.Head().Id, - snapshotBaseId: ot.tree.RootId(), - currentReadKeyHash: state.CurrentReadKeyHash(), - identity: content.Identity, - isSnapshot: content.IsSnapshot, - signingKey: content.Key, - readKey: readKey, - content: content.Data, + TreeHeadIds: ot.tree.Heads(), + AclHeadId: ot.aclList.Head().Id, + SnapshotBaseId: ot.tree.RootId(), + CurrentReadKeyHash: state.CurrentReadKeyHash(), + Identity: content.Identity, + IsSnapshot: content.IsSnapshot, + SigningKey: content.Key, + ReadKey: readKey, + Content: content.Data, } return } -func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { +func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*treechangeproto.RawTreeChangeWithId) (addResult AddResult, err error) { addResult, err = ot.addRawChanges(ctx, rawChanges...) if err != nil { return @@ -223,7 +224,7 @@ func (ot *objectTree) AddRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra return } -func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.RawTreeChangeWithId) (addResult AddResult, err error) { +func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*treechangeproto.RawTreeChangeWithId) (addResult AddResult, err error) { // resetting buffers ot.tmpChangesBuf = ot.tmpChangesBuf[:0] ot.notSeenIdxBuf = ot.notSeenIdxBuf[:0] @@ -275,7 +276,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra // returns changes that we added to the tree as attached this round // they can include not only the changes that were added now, // but also the changes that were previously in the tree - getAddedChanges := func(toConvert []*Change) (added []*aclpb.RawTreeChangeWithId, err error) { + getAddedChanges := func(toConvert []*Change) (added []*treechangeproto.RawTreeChangeWithId, err error) { alreadyConverted := make(map[*Change]struct{}) // first we see if we have already unmarshalled those changes @@ -300,7 +301,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra for _, ch := range toConvert { // if we got some changes that we need to convert to raw if _, exists := alreadyConverted[ch]; !exists { - var raw *aclpb.RawTreeChangeWithId + var raw *treechangeproto.RawTreeChangeWithId raw, err = ot.changeBuilder.BuildRaw(ch) if err != nil { return @@ -342,7 +343,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra ot.rebuildFromStorage(nil) return } - var added []*aclpb.RawTreeChangeWithId + var added []*treechangeproto.RawTreeChangeWithId added, err = getAddedChanges(nil) // we shouldn't get any error in this case if err != nil { @@ -378,7 +379,7 @@ func (ot *objectTree) addRawChanges(ctx context.Context, rawChanges ...*aclpb.Ra err = ErrHasInvalidChanges return } - var added []*aclpb.RawTreeChangeWithId + var added []*treechangeproto.RawTreeChangeWithId added, err = getAddedChanges(treeChangesAdded) if err != nil { // that means that some unattached changes were somehow corrupted in memory @@ -409,17 +410,21 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate ot.tree.Iterate(ot.tree.RootId(), func(c *Change) (isContinue bool) { var model any - if c.ParsedModel != nil { + if c.Model != nil { return iterate(c) } - readKey, exists := ot.keys[c.Content.CurrentReadKeyHash] + // if this is a root change + if c.Id == ot.id { + return iterate(c) + } + readKey, exists := ot.keys[c.ReadKeyHash] if !exists { err = list.ErrNoReadKey return false } var decrypted []byte - decrypted, err = readKey.Decrypt(c.Content.GetChangesData()) + decrypted, err = readKey.Decrypt(c.Data) if err != nil { return false } @@ -429,7 +434,7 @@ func (ot *objectTree) IterateFrom(id string, convert ChangeConvertFunc, iterate return false } - c.ParsedModel = model + c.Model = model return iterate(c) }) return @@ -474,7 +479,7 @@ func (ot *objectTree) SnapshotPath() []string { return path } -func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) ([]*treechangeproto.RawTreeChangeWithId, error) { var ( needFullDocument = len(theirPath) == 0 ourPath = ot.SnapshotPath() @@ -498,11 +503,11 @@ func (ot *objectTree) ChangesAfterCommonSnapshot(theirPath, theirHeads []string) } } -func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { +func (ot *objectTree) getChangesFromTree(theirHeads []string) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromTree(ot.tree, theirHeads) } -func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { +func (ot *objectTree) getChangesFromDB(commonSnapshot string, theirHeads []string) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { return ot.rawChangeLoader.LoadFromStorage(commonSnapshot, ot.tree.headIds, theirHeads) } diff --git a/pkg/acl/tree/objecttree_test.go b/pkg/acl/tree/objecttree_test.go index 6e43d8d3..832c15fa 100644 --- a/pkg/acl/tree/objecttree_test.go +++ b/pkg/acl/tree/objecttree_test.go @@ -2,10 +2,12 @@ package tree import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "crypto/rand" + "encoding/hex" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/acllistbuilder" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" @@ -14,8 +16,26 @@ import ( type mockChangeCreator struct{} -func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *aclpb.RawTreeChangeWithId { - aclChange := &aclpb.TreeChange{ +func (c *mockChangeCreator) createRoot(id, aclId string) *treechangeproto.RawTreeChangeWithId { + aclChange := &treechangeproto.RootChange{ + AclHeadId: aclId, + } + res, _ := aclChange.Marshal() + + raw := &treechangeproto.RawTreeChange{ + Payload: res, + Signature: nil, + } + rawMarshalled, _ := raw.Marshal() + + return &treechangeproto.RawTreeChangeWithId{ + RawChange: rawMarshalled, + Id: id, + } +} + +func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot bool, prevIds ...string) *treechangeproto.RawTreeChangeWithId { + aclChange := &treechangeproto.TreeChange{ TreeHeadIds: prevIds, AclHeadId: aclId, SnapshotBaseId: snapshotId, @@ -24,26 +44,21 @@ func (c *mockChangeCreator) createRaw(id, aclId, snapshotId string, isSnapshot b } res, _ := aclChange.Marshal() - raw := &aclpb.RawTreeChange{ + raw := &treechangeproto.RawTreeChange{ Payload: res, Signature: nil, } rawMarshalled, _ := raw.Marshal() - return &aclpb.RawTreeChangeWithId{ + return &treechangeproto.RawTreeChangeWithId{ RawChange: rawMarshalled, Id: id, } } -func (c *mockChangeCreator) createNewTreeStorage(treeId, aclListId, aclHeadId, firstChangeId string) storage.TreeStorage { - firstChange := c.createRaw(firstChangeId, aclHeadId, "", true) - header := &aclpb.TreeHeader{ - FirstId: firstChangeId, - AclId: aclListId, - TreeHeaderType: aclpb.TreeHeaderType_Object, - } - treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, header, []string{firstChangeId}, []*aclpb.RawTreeChangeWithId{firstChange}) +func (c *mockChangeCreator) createNewTreeStorage(treeId, aclHeadId string) storage.TreeStorage { + root := c.createRoot(treeId, aclHeadId) + treeStorage, _ := storage.NewInMemoryTreeStorage(treeId, root, []string{root.Id}, []*treechangeproto.RawTreeChangeWithId{root}) return treeStorage } @@ -51,15 +66,23 @@ type mockChangeBuilder struct { originalBuilder ChangeBuilder } -func (c *mockChangeBuilder) ConvertFromRaw(rawChange *aclpb.RawTreeChangeWithId, verify bool) (ch *Change, err error) { - return c.originalBuilder.ConvertFromRaw(rawChange, false) -} - -func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *aclpb.RawTreeChangeWithId, err error) { +func (c *mockChangeBuilder) BuildInitialContent(payload InitialContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) { panic("implement me") } -func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *aclpb.RawTreeChangeWithId, err error) { +func (c *mockChangeBuilder) SetRootRawChange(rawIdChange *treechangeproto.RawTreeChangeWithId) { + c.originalBuilder.SetRootRawChange(rawIdChange) +} + +func (c *mockChangeBuilder) ConvertFromRaw(rawChange *treechangeproto.RawTreeChangeWithId, verify bool) (ch *Change, err error) { + return c.originalBuilder.ConvertFromRaw(rawChange, false) +} + +func (c *mockChangeBuilder) BuildContent(payload BuilderContent) (ch *Change, raw *treechangeproto.RawTreeChangeWithId, err error) { + panic("implement me") +} + +func (c *mockChangeBuilder) BuildRaw(ch *Change) (raw *treechangeproto.RawTreeChangeWithId, err error) { return c.originalBuilder.BuildRaw(ch) } @@ -93,15 +116,15 @@ func prepareACLList(t *testing.T) list.ACLList { func prepareTreeContext(t *testing.T, aclList list.ACLList) testTreeContext { changeCreator := &mockChangeCreator{} - treeStorage := changeCreator.createNewTreeStorage("treeId", aclList.ID(), aclList.Head().Id, "0") + treeStorage := changeCreator.createNewTreeStorage("0", aclList.Head().Id) + root, _ := treeStorage.Root() changeBuilder := &mockChangeBuilder{ - originalBuilder: newChangeBuilder(nil), + originalBuilder: newChangeBuilder(nil, root), } deps := objectTreeDeps{ changeBuilder: changeBuilder, treeBuilder: newTreeBuilder(treeStorage, changeBuilder), treeStorage: treeStorage, - updateListener: nil, rawChangeLoader: newRawChangeLoader(treeStorage, changeBuilder), validator: &mockChangeValidator{}, aclList: aclList, @@ -128,6 +151,18 @@ func prepareTreeContext(t *testing.T, aclList list.ACLList) testTreeContext { } } +func TestSameSignature(t *testing.T) { + privKey, _, err := signingkey.GenerateEd25519Key(rand.Reader) + require.NoError(t, err) + bytes := []byte("asefhiosahjfoiesjgioesajgihs") + for i := 0; i < 5; i++ { + signed, err := privKey.Sign(bytes) + require.NoError(t, err) + t.Log(hex.EncodeToString(signed)) + } + // kitten step voyage hand cover funny timber auction differ mushroom update pulp +} + func TestObjectTree(t *testing.T) { aclList := prepareACLList(t) @@ -137,7 +172,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } @@ -178,7 +213,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("0", aclList.Head().Id, "", true, ""), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -198,7 +233,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), } res, err := objTree.AddRawChanges(context.Background(), rawChanges...) @@ -220,7 +255,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -264,7 +299,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -283,7 +318,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -357,7 +392,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -433,7 +468,7 @@ func TestObjectTree(t *testing.T) { changeCreator := ctx.changeCreator objTree := ctx.objTree - rawChanges := []*aclpb.RawTreeChangeWithId{ + rawChanges := []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("1", aclList.Head().Id, "0", false, "0"), changeCreator.createRaw("2", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("3", aclList.Head().Id, "0", true, "2"), @@ -442,7 +477,7 @@ func TestObjectTree(t *testing.T) { require.NoError(t, err, "adding changes should be without error") require.Equal(t, "3", objTree.Root().Id) - rawChanges = []*aclpb.RawTreeChangeWithId{ + rawChanges = []*treechangeproto.RawTreeChangeWithId{ changeCreator.createRaw("4", aclList.Head().Id, "0", false, "2"), changeCreator.createRaw("5", aclList.Head().Id, "0", false, "1"), changeCreator.createRaw("6", aclList.Head().Id, "0", false, "3", "4", "5"), diff --git a/pkg/acl/tree/objecttreefactory.go b/pkg/acl/tree/objecttreefactory.go index 44dc1fb5..f6ab5f77 100644 --- a/pkg/acl/tree/objecttreefactory.go +++ b/pkg/acl/tree/objecttreefactory.go @@ -1,11 +1,10 @@ package tree import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" - "github.com/anytypeio/go-anytype-infrastructure-experiments/util/cid" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" + "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/asymmetric/signingkey" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/keys/symmetric" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" "github.com/gogo/protobuf/proto" @@ -13,14 +12,19 @@ import ( ) type ObjectTreeCreatePayload struct { - AccountData *account.AccountData - HeaderData []byte - ChangeData []byte - TreeType aclpb.TreeHeaderType + SignKey signingkey.PrivKey + ChangeType string + Seed []byte + SpaceId string + Identity []byte } func BuildObjectTree(treeStorage storage.TreeStorage, aclList list.ACLList) (ObjectTree, error) { - deps := defaultObjectTreeDeps(treeStorage, aclList) + rootChange, err := treeStorage.Root() + if err != nil { + return nil, err + } + deps := defaultObjectTreeDeps(rootChange, treeStorage, aclList) return buildObjectTree(deps) } @@ -30,54 +34,35 @@ func CreateObjectTree( createStorage storage.TreeStorageCreatorFunc) (objTree ObjectTree, err error) { aclList.RLock() var ( - deps = defaultObjectTreeDeps(nil, aclList) - state = aclList.ACLState() - aclId = aclList.ID() - aclHeadId = aclList.Head().Id - readKeyHash = state.CurrentReadKeyHash() + deps = defaultObjectTreeDeps(nil, nil, aclList) + aclHeadId = aclList.Head().Id ) - readKey, err := state.CurrentReadKey() aclList.RUnlock() if err != nil { return } - - // create first change - cnt := BuilderContent{ - treeHeadIds: nil, - aclHeadId: aclHeadId, - snapshotBaseId: "", - currentReadKeyHash: readKeyHash, - isSnapshot: true, - readKey: readKey, - identity: payload.AccountData.Identity, - signingKey: payload.AccountData.SignKey, - content: payload.ChangeData, + cnt := InitialContent{ + AclHeadId: aclHeadId, + Identity: payload.Identity, + SigningKey: payload.SignKey, + SpaceId: payload.SpaceId, + Seed: payload.Seed, + ChangeType: payload.ChangeType, } - _, raw, err := deps.changeBuilder.BuildContent(cnt) - if err != nil { - return - } - - // create header - header, id, err := createTreeHeaderAndId( - raw, - payload.TreeType, - aclId, - payload.AccountData.Identity, - payload.HeaderData) + _, raw, err := deps.changeBuilder.BuildInitialContent(cnt) if err != nil { return } + deps.changeBuilder.SetRootRawChange(raw) // create storage st, err := createStorage(storage.TreeStorageCreatePayload{ - TreeId: id, - Header: header, - Changes: []*aclpb.RawTreeChangeWithId{raw}, - Heads: []string{raw.Id}, + TreeId: raw.Id, + RootRawChange: raw, + Changes: []*treechangeproto.RawTreeChangeWithId{raw}, + Heads: []string{raw.Id}, }) if err != nil { return @@ -98,7 +83,7 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { tree: nil, keys: make(map[uint64]*symmetric.Key), tmpChangesBuf: make([]*Change, 0, 10), - difSnapshotBuf: make([]*aclpb.RawTreeChangeWithId, 0, 10), + difSnapshotBuf: make([]*treechangeproto.RawTreeChangeWithId, 0, 10), notSeenIdxBuf: make([]int, 0, 10), newSnapshotsBuf: make([]*Change, 0, 10), } @@ -128,32 +113,23 @@ func buildObjectTree(deps objectTreeDeps) (ObjectTree, error) { if err != nil { return nil, err } - objTree.header, err = objTree.treeStorage.Header() + + rawRootWithId, err := objTree.treeStorage.Root() + if err != nil { + return nil, err + } + + rawRoot := &treechangeproto.RawTreeChange{} + err = proto.Unmarshal(rawRootWithId.RawChange, rawRoot) + if err != nil { + return nil, err + } + + objTree.root = &treechangeproto.RootChange{} + err = proto.Unmarshal(rawRoot.Payload, objTree.root) if err != nil { return nil, err } return objTree, nil } - -func createTreeHeaderAndId( - raw *aclpb.RawTreeChangeWithId, - treeType aclpb.TreeHeaderType, - aclId string, - identity []byte, - headerData []byte) (header *aclpb.TreeHeader, treeId string, err error) { - header = &aclpb.TreeHeader{ - FirstId: raw.Id, - TreeHeaderType: treeType, - AclId: aclId, - Identity: identity, - Data: headerData, - } - marshalledHeader, err := proto.Marshal(header) - if err != nil { - return - } - - treeId, err = cid.NewCIDFromBytes(marshalledHeader) - return -} diff --git a/pkg/acl/tree/rawloader.go b/pkg/acl/tree/rawloader.go index c068cdba..6f6c8539 100644 --- a/pkg/acl/tree/rawloader.go +++ b/pkg/acl/tree/rawloader.go @@ -2,8 +2,8 @@ package tree import ( "context" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/treechangeproto" "time" ) @@ -18,7 +18,7 @@ type rawChangeLoader struct { type rawCacheEntry struct { change *Change - rawChange *aclpb.RawTreeChangeWithId + rawChange *treechangeproto.RawTreeChangeWithId position int } @@ -29,15 +29,15 @@ func newRawChangeLoader(treeStorage storage.TreeStorage, changeBuilder ChangeBui } } -func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*treechangeproto.RawTreeChangeWithId, error) { var stack []*Change for _, h := range t.headIds { stack = append(stack, t.attached[h]) } - convert := func(chs []*Change) (rawChanges []*aclpb.RawTreeChangeWithId, err error) { + convert := func(chs []*Change) (rawChanges []*treechangeproto.RawTreeChangeWithId, err error) { for _, ch := range chs { - var raw *aclpb.RawTreeChangeWithId + var raw *treechangeproto.RawTreeChangeWithId raw, err = r.changeBuilder.BuildRaw(ch) if err != nil { return @@ -95,7 +95,7 @@ func (r *rawChangeLoader) LoadFromTree(t *Tree, breakpoints []string) ([]*aclpb. return convert(results) } -func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*aclpb.RawTreeChangeWithId, error) { +func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoints []string) ([]*treechangeproto.RawTreeChangeWithId, error) { // resetting cache r.cache = make(map[string]rawCacheEntry) defer func() { @@ -162,7 +162,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi // preparing first pass r.idStack = append(r.idStack, heads...) - var buffer []*aclpb.RawTreeChangeWithId + var buffer []*treechangeproto.RawTreeChangeWithId rootVisited := dfs(commonSnapshot, heads, 0, func(counter int, mapExists bool) bool { @@ -203,7 +203,7 @@ func (r *rawChangeLoader) LoadFromStorage(commonSnapshot string, heads, breakpoi }) // discarding visited - buffer = discardFromSlice(buffer, func(change *aclpb.RawTreeChangeWithId) bool { + buffer = discardFromSlice(buffer, func(change *treechangeproto.RawTreeChangeWithId) bool { return change == nil }) diff --git a/pkg/acl/tree/treegraph_nix.go b/pkg/acl/tree/treegraph_nix.go index c506c9b3..ae4f5281 100644 --- a/pkg/acl/tree/treegraph_nix.go +++ b/pkg/acl/tree/treegraph_nix.go @@ -59,7 +59,7 @@ func (t *Tree) Graph(parser DescriptionParser) (data string, err error) { label := fmt.Sprintf("Id: %s\nOrd: %s\nTime: %s\nChanges: %s\n", shortId, ord, - time.Unix(c.Content.Timestamp, 0).Format("02.01.06 15:04:05"), + time.Unix(c.Timestamp, 0).Format("02.01.06 15:04:05"), strings.Join(chSymbs, ","), ) n.SetLabel(label) diff --git a/pkg/acl/treechangeproto/protos/treechange.proto b/pkg/acl/treechangeproto/protos/treechange.proto new file mode 100644 index 00000000..8f733a5d --- /dev/null +++ b/pkg/acl/treechangeproto/protos/treechange.proto @@ -0,0 +1,55 @@ +syntax = "proto3"; +package treechange; +option go_package = "pkg/acl/treechangeproto"; + +// RootChange is a root of a tree +message RootChange { + // AclHeadId is a cid of latest acl record at the time of tree creation + string aclHeadId = 1; + // SpaceId is an id of space where the document is placed + string spaceId = 2; + // ChangeType is a type of tree which this RootChange is a root of + string changeType = 3; + // Timestamp is this change creation timestamp + int64 timestamp = 4; + // Seed is a random bytes to make root change unique + bytes seed = 5; + // Identity is a public key of the tree's creator + bytes identity = 6; +} + +// TreeChange is a change of a tree +message TreeChange { + // TreeHeadIds are previous ids for this TreeChange + repeated string treeHeadIds = 1; + // AclHeadId is a cid of latest acl record at the time of this change + string aclHeadId = 2; + // SnapshotBaseId is a snapshot (root) of the tree where this change is added + string snapshotBaseId = 3; + // ChangesData is an arbitrary payload to be read by the client + bytes changesData = 4; + // CurrentReadKeyHash is the hash of the read key which is used to encrypt this change + uint64 currentReadKeyHash = 5; + // Timestamp is this change creation timestamp + int64 timestamp = 6; + // Identity is a public key with which the raw payload of this change is signed + bytes identity = 7; + // IsSnapshot indicates whether this change contains a snapshot of state + bool isSnapshot = 8; +} + +// RawTreeChange is a marshalled TreeChange (or RootChange) payload and a signature of this payload +message RawTreeChange { + // Payload is a byte payload containing TreeChange + bytes payload = 1; + // Signature is a signature made by identity indicated in the TreeChange payload + bytes signature = 2; +} + +// RawTreeChangeWithId is a marshalled RawTreeChange with CID +message RawTreeChangeWithId { + // RawChange is a byte payload of RawTreeChange + bytes rawChange = 1; + // Id is a cid made from rawChange payload + string id = 2; +} diff --git a/pkg/acl/treechangeproto/treechange.pb.go b/pkg/acl/treechangeproto/treechange.pb.go new file mode 100644 index 00000000..fd4deb8a --- /dev/null +++ b/pkg/acl/treechangeproto/treechange.pb.go @@ -0,0 +1,1537 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: pkg/acl/treechangeproto/protos/treechange.proto + +package treechangeproto + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +// RootChange is a root of a tree +type RootChange struct { + // AclHeadId is a cid of latest acl record at the time of tree creation + AclHeadId string `protobuf:"bytes,1,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + // SpaceId is an id of space where the document is placed + SpaceId string `protobuf:"bytes,2,opt,name=spaceId,proto3" json:"spaceId,omitempty"` + // ChangeType is a type of tree which this RootChange is a root of + ChangeType string `protobuf:"bytes,3,opt,name=changeType,proto3" json:"changeType,omitempty"` + // Timestamp is this change creation timestamp + Timestamp int64 `protobuf:"varint,4,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // Seed is a random bytes to make root change unique + Seed []byte `protobuf:"bytes,5,opt,name=seed,proto3" json:"seed,omitempty"` + // Identity is a public key of the tree's creator + Identity []byte `protobuf:"bytes,6,opt,name=identity,proto3" json:"identity,omitempty"` +} + +func (m *RootChange) Reset() { *m = RootChange{} } +func (m *RootChange) String() string { return proto.CompactTextString(m) } +func (*RootChange) ProtoMessage() {} +func (*RootChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{0} +} +func (m *RootChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RootChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RootChange.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RootChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RootChange.Merge(m, src) +} +func (m *RootChange) XXX_Size() int { + return m.Size() +} +func (m *RootChange) XXX_DiscardUnknown() { + xxx_messageInfo_RootChange.DiscardUnknown(m) +} + +var xxx_messageInfo_RootChange proto.InternalMessageInfo + +func (m *RootChange) GetAclHeadId() string { + if m != nil { + return m.AclHeadId + } + return "" +} + +func (m *RootChange) GetSpaceId() string { + if m != nil { + return m.SpaceId + } + return "" +} + +func (m *RootChange) GetChangeType() string { + if m != nil { + return m.ChangeType + } + return "" +} + +func (m *RootChange) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *RootChange) GetSeed() []byte { + if m != nil { + return m.Seed + } + return nil +} + +func (m *RootChange) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +// TreeChange is a change of a tree +type TreeChange struct { + // TreeHeadIds are previous ids for this TreeChange + TreeHeadIds []string `protobuf:"bytes,1,rep,name=treeHeadIds,proto3" json:"treeHeadIds,omitempty"` + // AclHeadId is a cid of latest acl record at the time of this change + AclHeadId string `protobuf:"bytes,2,opt,name=aclHeadId,proto3" json:"aclHeadId,omitempty"` + // SnapshotBaseId is a snapshot (root) of the tree where this change is added + SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` + // ChangesData is an arbitrary payload to be read by the client + ChangesData []byte `protobuf:"bytes,4,opt,name=changesData,proto3" json:"changesData,omitempty"` + // CurrentReadKeyHash is the hash of the read key which is used to encrypt this change + CurrentReadKeyHash uint64 `protobuf:"varint,5,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + // Timestamp is this change creation timestamp + Timestamp int64 `protobuf:"varint,6,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + // Identity is a public key with which the raw payload of this change is signed + Identity []byte `protobuf:"bytes,7,opt,name=identity,proto3" json:"identity,omitempty"` + // IsSnapshot indicates whether this change contains a snapshot of state + IsSnapshot bool `protobuf:"varint,8,opt,name=isSnapshot,proto3" json:"isSnapshot,omitempty"` +} + +func (m *TreeChange) Reset() { *m = TreeChange{} } +func (m *TreeChange) String() string { return proto.CompactTextString(m) } +func (*TreeChange) ProtoMessage() {} +func (*TreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{1} +} +func (m *TreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *TreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_TreeChange.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *TreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_TreeChange.Merge(m, src) +} +func (m *TreeChange) XXX_Size() int { + return m.Size() +} +func (m *TreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_TreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_TreeChange proto.InternalMessageInfo + +func (m *TreeChange) GetTreeHeadIds() []string { + if m != nil { + return m.TreeHeadIds + } + return nil +} + +func (m *TreeChange) GetAclHeadId() string { + if m != nil { + return m.AclHeadId + } + return "" +} + +func (m *TreeChange) GetSnapshotBaseId() string { + if m != nil { + return m.SnapshotBaseId + } + return "" +} + +func (m *TreeChange) GetChangesData() []byte { + if m != nil { + return m.ChangesData + } + return nil +} + +func (m *TreeChange) GetCurrentReadKeyHash() uint64 { + if m != nil { + return m.CurrentReadKeyHash + } + return 0 +} + +func (m *TreeChange) GetTimestamp() int64 { + if m != nil { + return m.Timestamp + } + return 0 +} + +func (m *TreeChange) GetIdentity() []byte { + if m != nil { + return m.Identity + } + return nil +} + +func (m *TreeChange) GetIsSnapshot() bool { + if m != nil { + return m.IsSnapshot + } + return false +} + +// RawTreeChange is a marshalled TreeChange (or RootChange) payload and a signature of this payload +type RawTreeChange struct { + // Payload is a byte payload containing TreeChange + Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` + // Signature is a signature made by identity indicated in the TreeChange payload + Signature []byte `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` +} + +func (m *RawTreeChange) Reset() { *m = RawTreeChange{} } +func (m *RawTreeChange) String() string { return proto.CompactTextString(m) } +func (*RawTreeChange) ProtoMessage() {} +func (*RawTreeChange) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{2} +} +func (m *RawTreeChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChange.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RawTreeChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChange.Merge(m, src) +} +func (m *RawTreeChange) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChange) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChange.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChange proto.InternalMessageInfo + +func (m *RawTreeChange) GetPayload() []byte { + if m != nil { + return m.Payload + } + return nil +} + +func (m *RawTreeChange) GetSignature() []byte { + if m != nil { + return m.Signature + } + return nil +} + +// RawTreeChangeWithId is a marshalled RawTreeChange with CID +type RawTreeChangeWithId struct { + // RawChange is a byte payload of RawTreeChange + RawChange []byte `protobuf:"bytes,1,opt,name=rawChange,proto3" json:"rawChange,omitempty"` + // Id is a cid made from rawChange payload + Id string `protobuf:"bytes,2,opt,name=id,proto3" json:"id,omitempty"` +} + +func (m *RawTreeChangeWithId) Reset() { *m = RawTreeChangeWithId{} } +func (m *RawTreeChangeWithId) String() string { return proto.CompactTextString(m) } +func (*RawTreeChangeWithId) ProtoMessage() {} +func (*RawTreeChangeWithId) Descriptor() ([]byte, []int) { + return fileDescriptor_f177d8514fae978f, []int{3} +} +func (m *RawTreeChangeWithId) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *RawTreeChangeWithId) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_RawTreeChangeWithId.Marshal(b, m, deterministic) + } else { + b = b[:cap(b)] + n, err := m.MarshalToSizedBuffer(b) + if err != nil { + return nil, err + } + return b[:n], nil + } +} +func (m *RawTreeChangeWithId) XXX_Merge(src proto.Message) { + xxx_messageInfo_RawTreeChangeWithId.Merge(m, src) +} +func (m *RawTreeChangeWithId) XXX_Size() int { + return m.Size() +} +func (m *RawTreeChangeWithId) XXX_DiscardUnknown() { + xxx_messageInfo_RawTreeChangeWithId.DiscardUnknown(m) +} + +var xxx_messageInfo_RawTreeChangeWithId proto.InternalMessageInfo + +func (m *RawTreeChangeWithId) GetRawChange() []byte { + if m != nil { + return m.RawChange + } + return nil +} + +func (m *RawTreeChangeWithId) GetId() string { + if m != nil { + return m.Id + } + return "" +} + +func init() { + proto.RegisterType((*RootChange)(nil), "treechange.RootChange") + proto.RegisterType((*TreeChange)(nil), "treechange.TreeChange") + proto.RegisterType((*RawTreeChange)(nil), "treechange.RawTreeChange") + proto.RegisterType((*RawTreeChangeWithId)(nil), "treechange.RawTreeChangeWithId") +} + +func init() { + proto.RegisterFile("pkg/acl/treechangeproto/protos/treechange.proto", fileDescriptor_f177d8514fae978f) +} + +var fileDescriptor_f177d8514fae978f = []byte{ + // 393 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x74, 0x92, 0xcf, 0x0e, 0x93, 0x40, + 0x10, 0x87, 0xbb, 0xb4, 0xf6, 0xcf, 0x88, 0x3d, 0xac, 0x07, 0x37, 0xc6, 0x10, 0xc2, 0xc1, 0x70, + 0x2a, 0x31, 0xbe, 0x41, 0x6b, 0x62, 0x1b, 0x6f, 0x6b, 0x13, 0x13, 0x6f, 0x23, 0x4c, 0xca, 0xc6, + 0x16, 0x08, 0xbb, 0x4d, 0xc3, 0x5b, 0xf8, 0x08, 0x3e, 0x83, 0x4f, 0xe1, 0xb1, 0x47, 0x8f, 0xa6, + 0x7d, 0x11, 0xc3, 0xd2, 0x0a, 0x34, 0x7a, 0x01, 0xe6, 0x9b, 0x30, 0xcc, 0xef, 0x63, 0x21, 0x2a, + 0xbe, 0xee, 0x22, 0x8c, 0xf7, 0x91, 0x29, 0x89, 0xe2, 0x14, 0xb3, 0x1d, 0x15, 0x65, 0x6e, 0xf2, + 0xc8, 0x5e, 0x75, 0x07, 0x2f, 0x2c, 0xe1, 0xd0, 0x92, 0xe0, 0x07, 0x03, 0x90, 0x79, 0x6e, 0x56, + 0xb6, 0xe4, 0xaf, 0x60, 0x86, 0xf1, 0x7e, 0x4d, 0x98, 0x6c, 0x12, 0xc1, 0x7c, 0x16, 0xce, 0x64, + 0x0b, 0xb8, 0x80, 0x89, 0x2e, 0x30, 0xa6, 0x4d, 0x22, 0x1c, 0xdb, 0xbb, 0x97, 0xdc, 0x03, 0x68, + 0x06, 0x6e, 0xab, 0x82, 0xc4, 0xd0, 0x36, 0x3b, 0xa4, 0x9e, 0x6b, 0xd4, 0x81, 0xb4, 0xc1, 0x43, + 0x21, 0x46, 0x3e, 0x0b, 0x87, 0xb2, 0x05, 0x9c, 0xc3, 0x48, 0x13, 0x25, 0xe2, 0x89, 0xcf, 0x42, + 0x57, 0xda, 0x67, 0xfe, 0x12, 0xa6, 0x2a, 0xa1, 0xcc, 0x28, 0x53, 0x89, 0xb1, 0xe5, 0x7f, 0xeb, + 0xe0, 0xbb, 0x03, 0xb0, 0x2d, 0x89, 0x6e, 0x4b, 0xfb, 0xf0, 0xb4, 0x4e, 0xd4, 0x2c, 0xa9, 0x05, + 0xf3, 0x87, 0xe1, 0x4c, 0x76, 0x51, 0x3f, 0x96, 0xf3, 0x18, 0xeb, 0x35, 0xcc, 0x75, 0x86, 0x85, + 0x4e, 0x73, 0xb3, 0x44, 0x5d, 0xa7, 0x6b, 0x02, 0x3c, 0xd0, 0xfa, 0x3b, 0x4d, 0x24, 0xfd, 0x0e, + 0x0d, 0xda, 0x18, 0xae, 0xec, 0x22, 0xbe, 0x00, 0x1e, 0x1f, 0xcb, 0x92, 0x32, 0x23, 0x09, 0x93, + 0x0f, 0x54, 0xad, 0x51, 0xa7, 0x36, 0xd6, 0x48, 0xfe, 0xa3, 0xd3, 0xd7, 0x32, 0x7e, 0xd4, 0xd2, + 0x55, 0x30, 0xe9, 0x2b, 0xa8, 0x85, 0x2b, 0xfd, 0xf1, 0xb6, 0x9f, 0x98, 0xfa, 0x2c, 0x9c, 0xca, + 0x0e, 0x09, 0xde, 0xc3, 0x33, 0x89, 0xa7, 0x8e, 0x24, 0x01, 0x93, 0x02, 0xab, 0x7d, 0x8e, 0xcd, + 0x7f, 0x75, 0xe5, 0xbd, 0xac, 0x97, 0xd0, 0x6a, 0x97, 0xa1, 0x39, 0x96, 0x64, 0xe5, 0xb8, 0xb2, + 0x05, 0xc1, 0x0a, 0x9e, 0xf7, 0x06, 0x7d, 0x52, 0x26, 0xdd, 0xd8, 0x97, 0x4a, 0x3c, 0x35, 0xe8, + 0x36, 0xb0, 0x05, 0x7c, 0x0e, 0x8e, 0xba, 0x8b, 0x76, 0x54, 0xb2, 0x7c, 0xf3, 0xf3, 0xe2, 0xb1, + 0xf3, 0xc5, 0x63, 0xbf, 0x2f, 0x1e, 0xfb, 0x76, 0xf5, 0x06, 0xe7, 0xab, 0x37, 0xf8, 0x75, 0xf5, + 0x06, 0x9f, 0x5f, 0xfc, 0xe7, 0xf0, 0x7e, 0x19, 0xdb, 0xdb, 0xdb, 0x3f, 0x01, 0x00, 0x00, 0xff, + 0xff, 0xa5, 0x78, 0xc6, 0x1e, 0xde, 0x02, 0x00, 0x00, +} + +func (m *RootChange) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RootChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RootChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x32 + } + if len(m.Seed) > 0 { + i -= len(m.Seed) + copy(dAtA[i:], m.Seed) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Seed))) + i-- + dAtA[i] = 0x2a + } + if m.Timestamp != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x20 + } + if len(m.ChangeType) > 0 { + i -= len(m.ChangeType) + copy(dAtA[i:], m.ChangeType) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.ChangeType))) + i-- + dAtA[i] = 0x1a + } + if len(m.SpaceId) > 0 { + i -= len(m.SpaceId) + copy(dAtA[i:], m.SpaceId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.SpaceId))) + i-- + dAtA[i] = 0x12 + } + if len(m.AclHeadId) > 0 { + i -= len(m.AclHeadId) + copy(dAtA[i:], m.AclHeadId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.AclHeadId))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *TreeChange) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *TreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *TreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.IsSnapshot { + i-- + if m.IsSnapshot { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x40 + } + if len(m.Identity) > 0 { + i -= len(m.Identity) + copy(dAtA[i:], m.Identity) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Identity))) + i-- + dAtA[i] = 0x3a + } + if m.Timestamp != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.Timestamp)) + i-- + dAtA[i] = 0x30 + } + if m.CurrentReadKeyHash != 0 { + i = encodeVarintTreechange(dAtA, i, uint64(m.CurrentReadKeyHash)) + i-- + dAtA[i] = 0x28 + } + if len(m.ChangesData) > 0 { + i -= len(m.ChangesData) + copy(dAtA[i:], m.ChangesData) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.ChangesData))) + i-- + dAtA[i] = 0x22 + } + if len(m.SnapshotBaseId) > 0 { + i -= len(m.SnapshotBaseId) + copy(dAtA[i:], m.SnapshotBaseId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.SnapshotBaseId))) + i-- + dAtA[i] = 0x1a + } + if len(m.AclHeadId) > 0 { + i -= len(m.AclHeadId) + copy(dAtA[i:], m.AclHeadId) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.AclHeadId))) + i-- + dAtA[i] = 0x12 + } + if len(m.TreeHeadIds) > 0 { + for iNdEx := len(m.TreeHeadIds) - 1; iNdEx >= 0; iNdEx-- { + i -= len(m.TreeHeadIds[iNdEx]) + copy(dAtA[i:], m.TreeHeadIds[iNdEx]) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.TreeHeadIds[iNdEx]))) + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChange) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RawTreeChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Signature) > 0 { + i -= len(m.Signature) + copy(dAtA[i:], m.Signature) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Signature))) + i-- + dAtA[i] = 0x12 + } + if len(m.Payload) > 0 { + i -= len(m.Payload) + copy(dAtA[i:], m.Payload) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Payload))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *RawTreeChangeWithId) Marshal() (dAtA []byte, err error) { + size := m.Size() + dAtA = make([]byte, size) + n, err := m.MarshalToSizedBuffer(dAtA[:size]) + if err != nil { + return nil, err + } + return dAtA[:n], nil +} + +func (m *RawTreeChangeWithId) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *RawTreeChangeWithId) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Id) > 0 { + i -= len(m.Id) + copy(dAtA[i:], m.Id) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.Id))) + i-- + dAtA[i] = 0x12 + } + if len(m.RawChange) > 0 { + i -= len(m.RawChange) + copy(dAtA[i:], m.RawChange) + i = encodeVarintTreechange(dAtA, i, uint64(len(m.RawChange))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func encodeVarintTreechange(dAtA []byte, offset int, v uint64) int { + offset -= sovTreechange(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *RootChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.AclHeadId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.SpaceId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.ChangeType) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.Timestamp != 0 { + n += 1 + sovTreechange(uint64(m.Timestamp)) + } + l = len(m.Seed) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func (m *TreeChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.TreeHeadIds) > 0 { + for _, s := range m.TreeHeadIds { + l = len(s) + n += 1 + l + sovTreechange(uint64(l)) + } + } + l = len(m.AclHeadId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.SnapshotBaseId) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.ChangesData) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.CurrentReadKeyHash != 0 { + n += 1 + sovTreechange(uint64(m.CurrentReadKeyHash)) + } + if m.Timestamp != 0 { + n += 1 + sovTreechange(uint64(m.Timestamp)) + } + l = len(m.Identity) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + if m.IsSnapshot { + n += 2 + } + return n +} + +func (m *RawTreeChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Payload) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Signature) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func (m *RawTreeChangeWithId) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.RawChange) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + l = len(m.Id) + if l > 0 { + n += 1 + l + sovTreechange(uint64(l)) + } + return n +} + +func sovTreechange(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozTreechange(x uint64) (n int) { + return sovTreechange(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *RootChange) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RootChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RootChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclHeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SpaceId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SpaceId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangeType", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangeType = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 5: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Seed", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Seed = append(m.Seed[:0], dAtA[iNdEx:postIndex]...) + if m.Seed == nil { + m.Seed = []byte{} + } + iNdEx = postIndex + case 6: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *TreeChange) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: TreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TreeChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TreeHeadIds", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.TreeHeadIds = append(m.TreeHeadIds, string(dAtA[iNdEx:postIndex])) + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field AclHeadId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.AclHeadId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 3: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field SnapshotBaseId", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.SnapshotBaseId = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + case 4: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field ChangesData", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.ChangesData = append(m.ChangesData[:0], dAtA[iNdEx:postIndex]...) + if m.ChangesData == nil { + m.ChangesData = []byte{} + } + iNdEx = postIndex + case 5: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field CurrentReadKeyHash", wireType) + } + m.CurrentReadKeyHash = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.CurrentReadKeyHash |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 6: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Timestamp", wireType) + } + m.Timestamp = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Timestamp |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + case 7: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Identity", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Identity = append(m.Identity[:0], dAtA[iNdEx:postIndex]...) + if m.Identity == nil { + m.Identity = []byte{} + } + iNdEx = postIndex + case 8: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field IsSnapshot", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.IsSnapshot = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChange) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RawTreeChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) + if m.Payload == nil { + m.Payload = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Signature", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Signature = append(m.Signature[:0], dAtA[iNdEx:postIndex]...) + if m.Signature == nil { + m.Signature = []byte{} + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *RawTreeChangeWithId) Unmarshal(dAtA []byte) error { + l := len(dAtA) + iNdEx := 0 + for iNdEx < l { + preIndex := iNdEx + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: RawTreeChangeWithId: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: RawTreeChangeWithId: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field RawChange", wireType) + } + var byteLen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.RawChange = append(m.RawChange[:0], dAtA[iNdEx:postIndex]...) + if m.RawChange == nil { + m.RawChange = []byte{} + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Id", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowTreechange + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + stringLen |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + intStringLen := int(stringLen) + if intStringLen < 0 { + return ErrInvalidLengthTreechange + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthTreechange + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Id = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipTreechange(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthTreechange + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipTreechange(dAtA []byte) (n int, err error) { + l := len(dAtA) + iNdEx := 0 + depth := 0 + for iNdEx < l { + var wire uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= (uint64(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + wireType := int(wire & 0x7) + switch wireType { + case 0: + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + iNdEx++ + if dAtA[iNdEx-1] < 0x80 { + break + } + } + case 1: + iNdEx += 8 + case 2: + var length int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return 0, ErrIntOverflowTreechange + } + if iNdEx >= l { + return 0, io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + length |= (int(b) & 0x7F) << shift + if b < 0x80 { + break + } + } + if length < 0 { + return 0, ErrInvalidLengthTreechange + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupTreechange + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthTreechange + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthTreechange = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowTreechange = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupTreechange = fmt.Errorf("proto: unexpected end of group") +) diff --git a/service/document/service.go b/service/document/service.go index c8010e10..6d1192c2 100644 --- a/service/document/service.go +++ b/service/document/service.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" testchanges "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/testutils/testchanges/proto" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/service/storage/service.go b/service/storage/service.go index 43fb44d5..627627c0 100644 --- a/service/storage/service.go +++ b/service/storage/service.go @@ -4,7 +4,7 @@ import ( "context" "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" ) diff --git a/service/treecache/service.go b/service/treecache/service.go index 829885e3..90e91b98 100644 --- a/service/treecache/service.go +++ b/service/treecache/service.go @@ -6,7 +6,7 @@ import ( "github.com/anytypeio/go-anytype-infrastructure-experiments/app" "github.com/anytypeio/go-anytype-infrastructure-experiments/app/logger" "github.com/anytypeio/go-anytype-infrastructure-experiments/common/account" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclrecordproto/aclpb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/list" aclstorage "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/storage" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/tree" diff --git a/syncproto/proto/sync.proto b/syncproto/proto/sync.proto index 80548336..d1c60d7d 100644 --- a/syncproto/proto/sync.proto +++ b/syncproto/proto/sync.proto @@ -2,7 +2,7 @@ syntax = "proto3"; package anytype; option go_package = "/syncproto"; -import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto"; +import "pkg/acl/aclrecordproto/aclpb/protos/aclrecordproto.proto"; message Message { Header header = 1;