diff --git a/Makefile b/Makefile index f0ac4769..38a94af5 100644 --- a/Makefile +++ b/Makefile @@ -16,7 +16,8 @@ protos-go: @echo 'Generating protobuf packages (Go)...' $(eval P_TIMESTAMP := Mgoogle/protobuf/timestamp.proto=github.com/gogo/protobuf/types) $(eval P_STRUCT := Mgoogle/protobuf/struct.proto=github.com/gogo/protobuf/types) - @$(eval P_PROTOS := Mdata/pb/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb) + @$(eval P_ACL_CHANGES := Mdata/pb/protos/aclchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb) + @$(eval P_PLAINTEXT_CHANGES := Mdata/pb/protos/plaintextchanges.proto=github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb) - $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT),$$(P_PROTOS)) + $(eval PKGMAP := $$(P_TIMESTAMP),$$(P_STRUCT),$$(P_ACL_CHANGES),$$(P_PLAINTEXT_CHANGES)) GOGO_NO_UNDERSCORE=1 GOGO_EXPORT_ONEOF_INTERFACE=1 protoc --gogofaster_out=$(PKGMAP):./data/pb data/pb/protos/*.*; mv data/pb/data/pb/protos/*.go data/pb; rm -rf data/pb/data diff --git a/data/aclstate.go b/data/aclstate.go index 934e29c5..4bf0b200 100644 --- a/data/aclstate.go +++ b/data/aclstate.go @@ -4,10 +4,11 @@ import ( "bytes" "errors" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" - "github.com/textileio/go-threads/crypto/symmetric" "hash/fnv" + + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" + "github.com/textileio/go-threads/crypto/symmetric" ) var ErrNoSuchUser = errors.New("no such user") diff --git a/data/aclstatebuilder.go b/data/aclstatebuilder.go index ee1e1d9f..d80d07b8 100644 --- a/data/aclstatebuilder.go +++ b/data/aclstatebuilder.go @@ -2,8 +2,9 @@ package data import ( "fmt" + + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" ) type ACLStateBuilder struct { diff --git a/data/aclstatebuilder_test.go b/data/aclstatebuilder_test.go index c8f68756..9f81cc3f 100644 --- a/data/aclstatebuilder_test.go +++ b/data/aclstatebuilder_test.go @@ -1,9 +1,9 @@ package data import ( + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadbuilder" "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" "github.com/stretchr/testify/assert" "testing" ) diff --git a/data/acltreebuilder.go b/data/acltreebuilder.go index 1583eed7..7ce2f681 100644 --- a/data/acltreebuilder.go +++ b/data/acltreebuilder.go @@ -3,8 +3,8 @@ package data import ( "context" "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" "github.com/gogo/protobuf/proto" "github.com/textileio/go-threads/core/thread" @@ -41,7 +41,7 @@ func (tb *ACLTreeBuilder) loadChange(id string) (ch *Change, err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() - record, err := tb.thread.GetRecord(ctx, id) + record, err := tb.thread.GetChange(ctx, id) if err != nil { return nil, err } diff --git a/data/change.go b/data/change.go index 1d33e57b..ede8f712 100644 --- a/data/change.go +++ b/data/change.go @@ -3,7 +3,7 @@ package data import ( "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" "github.com/gogo/protobuf/proto" "github.com/textileio/go-threads/crypto/symmetric" ) diff --git a/data/pb/aclchanges.pb.go b/data/pb/aclchanges.pb.go index ced412d1..925d68d4 100644 --- a/data/pb/aclchanges.pb.go +++ b/data/pb/aclchanges.pb.go @@ -60,11 +60,10 @@ type ACLChange struct { SnapshotBaseId string `protobuf:"bytes,3,opt,name=snapshotBaseId,proto3" json:"snapshotBaseId,omitempty"` AclData *ACLChangeACLData `protobuf:"bytes,4,opt,name=aclData,proto3" json:"aclData,omitempty"` // the data is encoded with read key and should be read in ChangesData format - ChangesData []byte `protobuf:"bytes,5,opt,name=changesData,proto3" json:"changesData,omitempty"` - CurrentReadKeyHash uint64 `protobuf:"varint,6,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` - Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` - Identity string `protobuf:"bytes,8,opt,name=identity,proto3" json:"identity,omitempty"` - LogHeads map[string]string `protobuf:"bytes,9,rep,name=logHeads,proto3" json:"logHeads,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"` + ChangesData []byte `protobuf:"bytes,5,opt,name=changesData,proto3" json:"changesData,omitempty"` + CurrentReadKeyHash uint64 `protobuf:"varint,6,opt,name=currentReadKeyHash,proto3" json:"currentReadKeyHash,omitempty"` + Timestamp int64 `protobuf:"varint,7,opt,name=timestamp,proto3" json:"timestamp,omitempty"` + Identity string `protobuf:"bytes,8,opt,name=identity,proto3" json:"identity,omitempty"` } func (m *ACLChange) Reset() { *m = ACLChange{} } @@ -156,13 +155,6 @@ func (m *ACLChange) GetIdentity() string { return "" } -func (m *ACLChange) GetLogHeads() map[string]string { - if m != nil { - return m.LogHeads - } - return nil -} - type ACLChangeACLContentValue struct { // Types that are valid to be assigned to Value: // *ACLChangeACLContentValueValueOfUserAdd @@ -178,7 +170,7 @@ func (m *ACLChangeACLContentValue) Reset() { *m = ACLChangeACLContentVal func (m *ACLChangeACLContentValue) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLContentValue) ProtoMessage() {} func (*ACLChangeACLContentValue) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 1} + return fileDescriptor_5a15109171a9dc49, []int{0, 0} } func (m *ACLChangeACLContentValue) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -309,7 +301,7 @@ func (m *ACLChangeACLData) Reset() { *m = ACLChangeACLData{} } func (m *ACLChangeACLData) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLData) ProtoMessage() {} func (*ACLChangeACLData) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 2} + return fileDescriptor_5a15109171a9dc49, []int{0, 1} } func (m *ACLChangeACLData) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -361,7 +353,7 @@ func (m *ACLChangeACLSnapshot) Reset() { *m = ACLChangeACLSnapshot{} } func (m *ACLChangeACLSnapshot) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLSnapshot) ProtoMessage() {} func (*ACLChangeACLSnapshot) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 3} + return fileDescriptor_5a15109171a9dc49, []int{0, 2} } func (m *ACLChangeACLSnapshot) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -407,7 +399,7 @@ func (m *ACLChangeACLState) Reset() { *m = ACLChangeACLState{} } func (m *ACLChangeACLState) String() string { return proto.CompactTextString(m) } func (*ACLChangeACLState) ProtoMessage() {} func (*ACLChangeACLState) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 4} + return fileDescriptor_5a15109171a9dc49, []int{0, 3} } func (m *ACLChangeACLState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -469,7 +461,7 @@ func (m *ACLChangeUserState) Reset() { *m = ACLChangeUserState{} } func (m *ACLChangeUserState) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserState) ProtoMessage() {} func (*ACLChangeUserState) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 5} + return fileDescriptor_5a15109171a9dc49, []int{0, 4} } func (m *ACLChangeUserState) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -545,7 +537,7 @@ func (m *ACLChangeUserAdd) Reset() { *m = ACLChangeUserAdd{} } func (m *ACLChangeUserAdd) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserAdd) ProtoMessage() {} func (*ACLChangeUserAdd) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 6} + return fileDescriptor_5a15109171a9dc49, []int{0, 5} } func (m *ACLChangeUserAdd) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -612,7 +604,7 @@ func (m *ACLChangeUserConfirm) Reset() { *m = ACLChangeUserConfirm{} } func (m *ACLChangeUserConfirm) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserConfirm) ProtoMessage() {} func (*ACLChangeUserConfirm) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 7} + return fileDescriptor_5a15109171a9dc49, []int{0, 6} } func (m *ACLChangeUserConfirm) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -666,7 +658,7 @@ func (m *ACLChangeUserInvite) Reset() { *m = ACLChangeUserInvite{} } func (m *ACLChangeUserInvite) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserInvite) ProtoMessage() {} func (*ACLChangeUserInvite) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 8} + return fileDescriptor_5a15109171a9dc49, []int{0, 7} } func (m *ACLChangeUserInvite) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -735,7 +727,7 @@ func (m *ACLChangeUserJoin) Reset() { *m = ACLChangeUserJoin{} } func (m *ACLChangeUserJoin) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserJoin) ProtoMessage() {} func (*ACLChangeUserJoin) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 9} + return fileDescriptor_5a15109171a9dc49, []int{0, 8} } func (m *ACLChangeUserJoin) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -808,7 +800,7 @@ func (m *ACLChangeUserRemove) Reset() { *m = ACLChangeUserRemove{} } func (m *ACLChangeUserRemove) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserRemove) ProtoMessage() {} func (*ACLChangeUserRemove) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 10} + return fileDescriptor_5a15109171a9dc49, []int{0, 9} } func (m *ACLChangeUserRemove) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -861,7 +853,7 @@ func (m *ACLChangeReadKeyReplace) Reset() { *m = ACLChangeReadKeyReplace func (m *ACLChangeReadKeyReplace) String() string { return proto.CompactTextString(m) } func (*ACLChangeReadKeyReplace) ProtoMessage() {} func (*ACLChangeReadKeyReplace) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 11} + return fileDescriptor_5a15109171a9dc49, []int{0, 10} } func (m *ACLChangeReadKeyReplace) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -920,7 +912,7 @@ func (m *ACLChangeUserPermissionChange) Reset() { *m = ACLChangeUserPerm func (m *ACLChangeUserPermissionChange) String() string { return proto.CompactTextString(m) } func (*ACLChangeUserPermissionChange) ProtoMessage() {} func (*ACLChangeUserPermissionChange) Descriptor() ([]byte, []int) { - return fileDescriptor_5a15109171a9dc49, []int{0, 12} + return fileDescriptor_5a15109171a9dc49, []int{0, 11} } func (m *ACLChangeUserPermissionChange) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -966,7 +958,6 @@ func (m *ACLChangeUserPermissionChange) GetPermissions() ACLChangeUserPermission func init() { proto.RegisterEnum("anytype.ACLChangeUserPermissions", ACLChangeUserPermissions_name, ACLChangeUserPermissions_value) proto.RegisterType((*ACLChange)(nil), "anytype.ACLChange") - proto.RegisterMapType((map[string]string)(nil), "anytype.ACLChange.LogHeadsEntry") proto.RegisterType((*ACLChangeACLContentValue)(nil), "anytype.ACLChange.ACLContentValue") proto.RegisterType((*ACLChangeACLData)(nil), "anytype.ACLChange.ACLData") proto.RegisterType((*ACLChangeACLSnapshot)(nil), "anytype.ACLChange.ACLSnapshot") @@ -985,66 +976,64 @@ func init() { func init() { proto.RegisterFile("data/pb/protos/aclchanges.proto", fileDescriptor_5a15109171a9dc49) } var fileDescriptor_5a15109171a9dc49 = []byte{ - // 938 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0xdd, 0x6e, 0xe3, 0x44, - 0x14, 0xce, 0x24, 0x6d, 0x1d, 0x1f, 0xa7, 0x6d, 0x18, 0x15, 0xc9, 0xf2, 0x16, 0x63, 0xaa, 0x15, - 0x58, 0x08, 0xa5, 0x52, 0x16, 0xf1, 0xbb, 0x12, 0x34, 0x5d, 0x20, 0xa1, 0x7b, 0xb1, 0x9a, 0x15, - 0x20, 0x90, 0xb8, 0x98, 0xda, 0x43, 0x6b, 0x91, 0xd8, 0x96, 0x67, 0x52, 0x91, 0x1b, 0xde, 0x00, - 0xc1, 0x53, 0xf0, 0x00, 0xbc, 0x00, 0xb7, 0x5c, 0xee, 0x05, 0x42, 0x5c, 0xa2, 0xf6, 0x45, 0xd0, - 0xfc, 0xd8, 0x71, 0x52, 0xa7, 0x48, 0x68, 0x25, 0xc4, 0xdd, 0xcc, 0x37, 0xdf, 0x99, 0x39, 0x3f, - 0xdf, 0x39, 0x36, 0xbc, 0x1c, 0x53, 0x41, 0x8f, 0xf3, 0xf3, 0xe3, 0xbc, 0xc8, 0x44, 0xc6, 0x8f, - 0x69, 0x34, 0x8d, 0x2e, 0x69, 0x7a, 0xc1, 0xf8, 0x40, 0x21, 0xd8, 0xa2, 0xe9, 0x42, 0x2c, 0x72, - 0x76, 0xf4, 0xf3, 0x8b, 0x60,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4, 0x21, 0xef, 0x57, 0x04, 0x96, - 0x99, 0x27, 0xff, 0xcf, 0x18, 0xbd, 0x4f, 0xc0, 0xa9, 0x35, 0xee, 0x9d, 0x41, 0x1c, 0x82, 0x6d, - 0x06, 0xe6, 0x24, 0x36, 0xf3, 0x78, 0x09, 0x78, 0x7f, 0x20, 0x80, 0xa5, 0x14, 0x70, 0x08, 0xfb, - 0x34, 0x8a, 0x58, 0x2e, 0x9e, 0xcc, 0xcf, 0xa7, 0x49, 0x74, 0x66, 0x64, 0xd5, 0x23, 0xeb, 0x30, - 0x7e, 0x1d, 0xfa, 0x26, 0xb8, 0x25, 0x55, 0xa7, 0xe7, 0x16, 0xfe, 0x9f, 0x64, 0xe8, 0x77, 0x04, - 0xdd, 0x72, 0x32, 0x3e, 0x87, 0x22, 0x57, 0x89, 0x79, 0x9a, 0x5c, 0xa4, 0x54, 0xcc, 0x0b, 0xfd, - 0x95, 0xa8, 0x12, 0x53, 0xc1, 0xf2, 0x33, 0xbe, 0x1c, 0xe1, 0xda, 0xd3, 0x49, 0xac, 0xa2, 0xb0, - 0x49, 0xc3, 0x49, 0x73, 0x72, 0xb6, 0x37, 0x24, 0xc7, 0x9b, 0xeb, 0x72, 0x99, 0x0f, 0xd8, 0x5d, - 0x71, 0x9d, 0xc1, 0xbe, 0x19, 0x5c, 0x84, 0xe5, 0x53, 0x1a, 0x55, 0x13, 0xe7, 0x95, 0x86, 0x54, - 0x92, 0x15, 0x26, 0x59, 0xb7, 0xf4, 0xbe, 0x87, 0xbd, 0x55, 0xca, 0x73, 0x48, 0xe9, 0x52, 0x41, - 0x55, 0x7c, 0x26, 0xa7, 0xb7, 0x70, 0xef, 0x3b, 0x38, 0x68, 0xfa, 0xf4, 0xde, 0xe9, 0xc5, 0x9a, - 0x8e, 0xda, 0xff, 0x4a, 0x47, 0x47, 0x27, 0xb0, 0xbf, 0x76, 0x8e, 0x6d, 0xd8, 0x3e, 0x89, 0x67, - 0x49, 0xda, 0x6f, 0x61, 0x80, 0x9d, 0x2f, 0x8a, 0x44, 0xb0, 0xa2, 0x8f, 0xe4, 0x5a, 0xba, 0xcb, - 0x8a, 0x7e, 0x1b, 0x3b, 0x60, 0xe9, 0x12, 0xc5, 0xfd, 0xce, 0xe8, 0xf0, 0xb7, 0x6b, 0x1f, 0x3d, - 0xbb, 0xf6, 0xd1, 0x5f, 0xd7, 0x3e, 0xfa, 0xe9, 0xc6, 0x6f, 0x3d, 0xbb, 0xf1, 0x5b, 0x7f, 0xde, - 0xf8, 0xad, 0xaf, 0xda, 0xf9, 0xf9, 0xf9, 0x8e, 0xfa, 0xad, 0x7d, 0xf0, 0x77, 0x00, 0x00, 0x00, - 0xff, 0xff, 0x14, 0x6d, 0x36, 0xcd, 0xf9, 0x0a, 0x00, 0x00, + // 898 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xd4, 0x56, 0x4d, 0x6f, 0xe3, 0x44, + 0x18, 0xf6, 0x24, 0x6d, 0x1d, 0xbf, 0x0e, 0x6d, 0x18, 0xf5, 0x60, 0x79, 0x8b, 0x09, 0x15, 0x82, + 0x08, 0xa1, 0x54, 0xca, 0x22, 0xbe, 0x84, 0x04, 0x4d, 0x17, 0x48, 0x28, 0x87, 0xd5, 0xac, 0x00, + 0x81, 0xc4, 0x61, 0x6a, 0x0f, 0x5b, 0x8b, 0xc4, 0xb6, 0x3c, 0x93, 0x0a, 0x5f, 0xf8, 0x07, 0x08, + 0xfe, 0x07, 0x37, 0xfe, 0x00, 0x57, 0x8e, 0x7b, 0x40, 0x88, 0x23, 0x6a, 0xff, 0x08, 0x9a, 0x0f, + 0x3b, 0x4e, 0x6a, 0x17, 0x09, 0x55, 0x42, 0xdc, 0x66, 0x9e, 0x79, 0xde, 0xf1, 0xf3, 0x7e, 0x8e, + 0xe1, 0xc5, 0x88, 0x0a, 0x7a, 0x92, 0x5d, 0x9c, 0x64, 0x79, 0x2a, 0x52, 0x7e, 0x42, 0xc3, 0x45, + 0x78, 0x49, 0x93, 0xa7, 0x8c, 0x8f, 0x15, 0x82, 0x6d, 0x9a, 0x14, 0xa2, 0xc8, 0xd8, 0xf1, 0xcf, + 0x87, 0xe0, 0x9c, 0x9e, 0x7d, 0x7a, 0xa6, 0x4e, 0xf1, 0x10, 0x5c, 0x91, 0x33, 0x36, 0x63, 0x34, + 0x9a, 0x47, 0xdc, 0x43, 0xc3, 0xee, 0xc8, 0x21, 0x75, 0x08, 0x07, 0x00, 0x34, 0x5c, 0x94, 0x84, + 0x8e, 0x22, 0xd4, 0x10, 0xfc, 0x0a, 0xec, 0xf3, 0x84, 0x66, 0xfc, 0x32, 0x15, 0x53, 0xca, 0xd9, + 0x3c, 0xf2, 0xba, 0x43, 0x34, 0x72, 0xc8, 0x16, 0x8a, 0xdf, 0x00, 0x9b, 0x86, 0x8b, 0x47, 0x54, + 0x50, 0x6f, 0x67, 0x88, 0x46, 0xee, 0xc4, 0x1f, 0x1b, 0x49, 0xe3, 0x4a, 0x8e, 0x5c, 0x49, 0x06, + 0x29, 0xa9, 0x52, 0x9f, 0xf1, 0x43, 0x59, 0xee, 0x0e, 0xd1, 0xa8, 0x4f, 0xea, 0x10, 0x1e, 0x03, + 0x0e, 0x57, 0x79, 0xce, 0x12, 0x41, 0x18, 0x8d, 0xce, 0x59, 0x31, 0xa3, 0xfc, 0xd2, 0xdb, 0x1b, + 0xa2, 0xd1, 0x0e, 0x69, 0x38, 0xc1, 0x47, 0xe0, 0x88, 0x78, 0xc9, 0xb8, 0xa0, 0xcb, 0xcc, 0xb3, + 0x87, 0x68, 0xd4, 0x25, 0x6b, 0x00, 0xfb, 0xd0, 0x8b, 0x23, 0x96, 0x88, 0x58, 0x14, 0x5e, 0x4f, + 0xf9, 0x51, 0xed, 0xfd, 0x5f, 0xba, 0x70, 0x20, 0xa5, 0xa6, 0x89, 0x60, 0x89, 0xf8, 0x9c, 0x2e, + 0x56, 0x0c, 0xbf, 0x09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x20, 0xb9, 0x96, 0x72, 0x59, 0x3e, 0xe8, 0x60, 0x17, 0x6c, 0x9d, 0xa2, + 0x68, 0xd0, 0x9d, 0x1e, 0xfd, 0x76, 0x1d, 0xa0, 0x67, 0xd7, 0x01, 0xfa, 0xeb, 0x3a, 0x40, 0x3f, + 0xdd, 0x04, 0xd6, 0xb3, 0x9b, 0xc0, 0xfa, 0xf3, 0x26, 0xb0, 0xbe, 0xea, 0x64, 0x17, 0x17, 0x7b, + 0xea, 0xdf, 0xf2, 0xe1, 0xdf, 0x01, 0x00, 0x00, 0xff, 0xff, 0xa3, 0x2f, 0x29, 0xef, 0x7e, 0x0a, + 0x00, 0x00, } func (m *ACLChange) Marshal() (dAtA []byte, err error) { @@ -1067,25 +1056,6 @@ func (m *ACLChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l - if len(m.LogHeads) > 0 { - for k := range m.LogHeads { - v := m.LogHeads[k] - baseI := i - i -= len(v) - copy(dAtA[i:], v) - i = encodeVarintAclchanges(dAtA, i, uint64(len(v))) - i-- - dAtA[i] = 0x12 - i -= len(k) - copy(dAtA[i:], k) - i = encodeVarintAclchanges(dAtA, i, uint64(len(k))) - i-- - dAtA[i] = 0xa - i = encodeVarintAclchanges(dAtA, i, uint64(baseI-i)) - i-- - dAtA[i] = 0x4a - } - } if len(m.Identity) > 0 { i -= len(m.Identity) copy(dAtA[i:], m.Identity) @@ -1907,14 +1877,6 @@ func (m *ACLChange) Size() (n int) { if l > 0 { n += 1 + l + sovAclchanges(uint64(l)) } - if len(m.LogHeads) > 0 { - for k, v := range m.LogHeads { - _ = k - _ = v - mapEntrySize := 1 + len(k) + sovAclchanges(uint64(len(k))) + 1 + len(v) + sovAclchanges(uint64(len(v))) - n += mapEntrySize + 1 + sovAclchanges(uint64(mapEntrySize)) - } - } return n } @@ -2525,133 +2487,6 @@ func (m *ACLChange) Unmarshal(dAtA []byte) error { } m.Identity = string(dAtA[iNdEx:postIndex]) iNdEx = postIndex - case 9: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field LogHeads", 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.LogHeads == nil { - m.LogHeads = make(map[string]string) - } - var mapkey string - var mapvalue string - 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 stringLenmapvalue uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowAclchanges - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - stringLenmapvalue |= uint64(b&0x7F) << shift - if b < 0x80 { - break - } - } - intStringLenmapvalue := int(stringLenmapvalue) - if intStringLenmapvalue < 0 { - return ErrInvalidLengthAclchanges - } - postStringIndexmapvalue := iNdEx + intStringLenmapvalue - if postStringIndexmapvalue < 0 { - return ErrInvalidLengthAclchanges - } - if postStringIndexmapvalue > l { - return io.ErrUnexpectedEOF - } - mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue]) - iNdEx = postStringIndexmapvalue - } 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.LogHeads[mapkey] = mapvalue - iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipAclchanges(dAtA[iNdEx:]) diff --git a/data/pb/plaintextchanges.pb.go b/data/pb/plaintextchanges.pb.go new file mode 100644 index 00000000..ac95a1b7 --- /dev/null +++ b/data/pb/plaintextchanges.pb.go @@ -0,0 +1,1088 @@ +// Code generated by protoc-gen-gogo. DO NOT EDIT. +// source: data/pb/protos/plaintextchanges.proto + +package pb + +import ( + fmt "fmt" + proto "github.com/gogo/protobuf/proto" + io "io" + math "math" + math_bits "math/bits" +) + +// Reference imports to suppress errors if they are not otherwise used. +var _ = proto.Marshal +var _ = fmt.Errorf +var _ = math.Inf + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the proto package it is being compiled against. +// A compilation error at this line likely means your copy of the +// proto package needs to be updated. +const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package + +type PlainTextChange struct { +} + +func (m *PlainTextChange) Reset() { *m = PlainTextChange{} } +func (m *PlainTextChange) String() string { return proto.CompactTextString(m) } +func (*PlainTextChange) ProtoMessage() {} +func (*PlainTextChange) Descriptor() ([]byte, []int) { + return fileDescriptor_970a1e91eeb094c9, []int{0} +} +func (m *PlainTextChange) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlainTextChange) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlainTextChange.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 *PlainTextChange) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChange.Merge(m, src) +} +func (m *PlainTextChange) XXX_Size() int { + return m.Size() +} +func (m *PlainTextChange) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChange.DiscardUnknown(m) +} + +var xxx_messageInfo_PlainTextChange proto.InternalMessageInfo + +type PlainTextChangeContent struct { + // Types that are valid to be assigned to Value: + // *PlainTextChangeContentValueOfTextAppend + Value IsPlainTextChangeContentValue `protobuf_oneof:"value"` +} + +func (m *PlainTextChangeContent) Reset() { *m = PlainTextChangeContent{} } +func (m *PlainTextChangeContent) String() string { return proto.CompactTextString(m) } +func (*PlainTextChangeContent) ProtoMessage() {} +func (*PlainTextChangeContent) Descriptor() ([]byte, []int) { + return fileDescriptor_970a1e91eeb094c9, []int{0, 0} +} +func (m *PlainTextChangeContent) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlainTextChangeContent) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlainTextChangeContent.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 *PlainTextChangeContent) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChangeContent.Merge(m, src) +} +func (m *PlainTextChangeContent) XXX_Size() int { + return m.Size() +} +func (m *PlainTextChangeContent) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChangeContent.DiscardUnknown(m) +} + +var xxx_messageInfo_PlainTextChangeContent proto.InternalMessageInfo + +type IsPlainTextChangeContentValue interface { + IsPlainTextChangeContentValue() + MarshalTo([]byte) (int, error) + Size() int +} + +type PlainTextChangeContentValueOfTextAppend struct { + TextAppend *PlainTextChangeTextAppend `protobuf:"bytes,1,opt,name=textAppend,proto3,oneof" json:"textAppend,omitempty"` +} + +func (*PlainTextChangeContentValueOfTextAppend) IsPlainTextChangeContentValue() {} + +func (m *PlainTextChangeContent) GetValue() IsPlainTextChangeContentValue { + if m != nil { + return m.Value + } + return nil +} + +func (m *PlainTextChangeContent) GetTextAppend() *PlainTextChangeTextAppend { + if x, ok := m.GetValue().(*PlainTextChangeContentValueOfTextAppend); ok { + return x.TextAppend + } + return nil +} + +// XXX_OneofWrappers is for the internal use of the proto package. +func (*PlainTextChangeContent) XXX_OneofWrappers() []interface{} { + return []interface{}{ + (*PlainTextChangeContentValueOfTextAppend)(nil), + } +} + +type PlainTextChangeTextAppend struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` +} + +func (m *PlainTextChangeTextAppend) Reset() { *m = PlainTextChangeTextAppend{} } +func (m *PlainTextChangeTextAppend) String() string { return proto.CompactTextString(m) } +func (*PlainTextChangeTextAppend) ProtoMessage() {} +func (*PlainTextChangeTextAppend) Descriptor() ([]byte, []int) { + return fileDescriptor_970a1e91eeb094c9, []int{0, 1} +} +func (m *PlainTextChangeTextAppend) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlainTextChangeTextAppend) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlainTextChangeTextAppend.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 *PlainTextChangeTextAppend) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChangeTextAppend.Merge(m, src) +} +func (m *PlainTextChangeTextAppend) XXX_Size() int { + return m.Size() +} +func (m *PlainTextChangeTextAppend) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChangeTextAppend.DiscardUnknown(m) +} + +var xxx_messageInfo_PlainTextChangeTextAppend proto.InternalMessageInfo + +func (m *PlainTextChangeTextAppend) GetText() string { + if m != nil { + return m.Text + } + return "" +} + +type PlainTextChangeSnapshot struct { + Text string `protobuf:"bytes,1,opt,name=text,proto3" json:"text,omitempty"` +} + +func (m *PlainTextChangeSnapshot) Reset() { *m = PlainTextChangeSnapshot{} } +func (m *PlainTextChangeSnapshot) String() string { return proto.CompactTextString(m) } +func (*PlainTextChangeSnapshot) ProtoMessage() {} +func (*PlainTextChangeSnapshot) Descriptor() ([]byte, []int) { + return fileDescriptor_970a1e91eeb094c9, []int{0, 2} +} +func (m *PlainTextChangeSnapshot) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlainTextChangeSnapshot) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlainTextChangeSnapshot.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 *PlainTextChangeSnapshot) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChangeSnapshot.Merge(m, src) +} +func (m *PlainTextChangeSnapshot) XXX_Size() int { + return m.Size() +} +func (m *PlainTextChangeSnapshot) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChangeSnapshot.DiscardUnknown(m) +} + +var xxx_messageInfo_PlainTextChangeSnapshot proto.InternalMessageInfo + +func (m *PlainTextChangeSnapshot) GetText() string { + if m != nil { + return m.Text + } + return "" +} + +type PlainTextChangeData struct { + Content []*PlainTextChangeContent `protobuf:"bytes,1,rep,name=content,proto3" json:"content,omitempty"` + Snapshot *PlainTextChangeSnapshot `protobuf:"bytes,2,opt,name=snapshot,proto3" json:"snapshot,omitempty"` +} + +func (m *PlainTextChangeData) Reset() { *m = PlainTextChangeData{} } +func (m *PlainTextChangeData) String() string { return proto.CompactTextString(m) } +func (*PlainTextChangeData) ProtoMessage() {} +func (*PlainTextChangeData) Descriptor() ([]byte, []int) { + return fileDescriptor_970a1e91eeb094c9, []int{0, 3} +} +func (m *PlainTextChangeData) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *PlainTextChangeData) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_PlainTextChangeData.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 *PlainTextChangeData) XXX_Merge(src proto.Message) { + xxx_messageInfo_PlainTextChangeData.Merge(m, src) +} +func (m *PlainTextChangeData) XXX_Size() int { + return m.Size() +} +func (m *PlainTextChangeData) XXX_DiscardUnknown() { + xxx_messageInfo_PlainTextChangeData.DiscardUnknown(m) +} + +var xxx_messageInfo_PlainTextChangeData proto.InternalMessageInfo + +func (m *PlainTextChangeData) GetContent() []*PlainTextChangeContent { + if m != nil { + return m.Content + } + return nil +} + +func (m *PlainTextChangeData) GetSnapshot() *PlainTextChangeSnapshot { + if m != nil { + return m.Snapshot + } + return nil +} + +func init() { + proto.RegisterType((*PlainTextChange)(nil), "anytype.PlainTextChange") + proto.RegisterType((*PlainTextChangeContent)(nil), "anytype.PlainTextChange.Content") + proto.RegisterType((*PlainTextChangeTextAppend)(nil), "anytype.PlainTextChange.TextAppend") + proto.RegisterType((*PlainTextChangeSnapshot)(nil), "anytype.PlainTextChange.Snapshot") + proto.RegisterType((*PlainTextChangeData)(nil), "anytype.PlainTextChange.Data") +} + +func init() { + proto.RegisterFile("data/pb/protos/plaintextchanges.proto", fileDescriptor_970a1e91eeb094c9) +} + +var fileDescriptor_970a1e91eeb094c9 = []byte{ + // 259 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x4d, 0x49, 0x2c, 0x49, + 0xd4, 0x2f, 0x48, 0xd2, 0x2f, 0x28, 0xca, 0x2f, 0xc9, 0x2f, 0xd6, 0x2f, 0xc8, 0x49, 0xcc, 0xcc, + 0x2b, 0x49, 0xad, 0x28, 0x49, 0xce, 0x48, 0xcc, 0x4b, 0x4f, 0x2d, 0xd6, 0x03, 0x8b, 0x0b, 0xb1, + 0x27, 0xe6, 0x55, 0x96, 0x54, 0x16, 0xa4, 0x2a, 0x6d, 0x62, 0xe2, 0xe2, 0x0f, 0x00, 0xa9, 0x09, + 0x49, 0xad, 0x28, 0x71, 0x06, 0xab, 0x91, 0x8a, 0xe4, 0x62, 0x77, 0xce, 0xcf, 0x2b, 0x49, 0xcd, + 0x2b, 0x11, 0x72, 0xe5, 0xe2, 0x02, 0x69, 0x76, 0x2c, 0x28, 0x48, 0xcd, 0x4b, 0x91, 0x60, 0x54, + 0x60, 0xd4, 0xe0, 0x36, 0x52, 0xd6, 0x83, 0x6a, 0xd6, 0x43, 0xd3, 0xa8, 0x17, 0x02, 0x57, 0xea, + 0xc1, 0x10, 0x84, 0xa4, 0xd1, 0x89, 0x9d, 0x8b, 0xb5, 0x2c, 0x31, 0xa7, 0x34, 0x55, 0x4a, 0x81, + 0x8b, 0x0b, 0xa1, 0x48, 0x48, 0x88, 0x8b, 0x05, 0xa4, 0x08, 0x6c, 0x2e, 0x67, 0x10, 0x98, 0x2d, + 0x25, 0xc7, 0xc5, 0x11, 0x9c, 0x97, 0x58, 0x50, 0x9c, 0x91, 0x5f, 0x82, 0x55, 0xbe, 0x91, 0x91, + 0x8b, 0xc5, 0x25, 0xb1, 0x24, 0x51, 0xc8, 0x8a, 0x8b, 0x3d, 0x19, 0xe2, 0x4a, 0x09, 0x46, 0x05, + 0x66, 0x0d, 0x6e, 0x23, 0x05, 0x9c, 0xee, 0x82, 0xfa, 0x26, 0x08, 0xa6, 0x41, 0xc8, 0x96, 0x8b, + 0xa3, 0x18, 0x6a, 0x89, 0x04, 0x13, 0xd8, 0x53, 0x8a, 0x38, 0x35, 0xc3, 0x5c, 0x13, 0x04, 0xd7, + 0xe2, 0x24, 0x73, 0xe2, 0x91, 0x1c, 0xe3, 0x85, 0x47, 0x72, 0x8c, 0x0f, 0x1e, 0xc9, 0x31, 0x4e, + 0x78, 0x2c, 0xc7, 0x70, 0xe1, 0xb1, 0x1c, 0xc3, 0x8d, 0xc7, 0x72, 0x0c, 0x51, 0x4c, 0x05, 0x49, + 0x49, 0x6c, 0xe0, 0x20, 0x36, 0x06, 0x04, 0x00, 0x00, 0xff, 0xff, 0xd3, 0x1e, 0xb0, 0x6a, 0x8b, + 0x01, 0x00, 0x00, +} + +func (m *PlainTextChange) 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 *PlainTextChange) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChange) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + return len(dAtA) - i, nil +} + +func (m *PlainTextChangeContent) 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 *PlainTextChangeContent) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChangeContent) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Value != nil { + { + size := m.Value.Size() + i -= size + if _, err := m.Value.MarshalTo(dAtA[i:]); err != nil { + return 0, err + } + } + } + return len(dAtA) - i, nil +} + +func (m *PlainTextChangeContentValueOfTextAppend) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChangeContentValueOfTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + if m.TextAppend != nil { + { + size, err := m.TextAppend.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPlaintextchanges(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} +func (m *PlainTextChangeTextAppend) 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 *PlainTextChangeTextAppend) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChangeTextAppend) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Text) > 0 { + i -= len(m.Text) + copy(dAtA[i:], m.Text) + i = encodeVarintPlaintextchanges(dAtA, i, uint64(len(m.Text))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PlainTextChangeSnapshot) 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 *PlainTextChangeSnapshot) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChangeSnapshot) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Text) > 0 { + i -= len(m.Text) + copy(dAtA[i:], m.Text) + i = encodeVarintPlaintextchanges(dAtA, i, uint64(len(m.Text))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + +func (m *PlainTextChangeData) 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 *PlainTextChangeData) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *PlainTextChangeData) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Snapshot != nil { + { + size, err := m.Snapshot.MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPlaintextchanges(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0x12 + } + if len(m.Content) > 0 { + for iNdEx := len(m.Content) - 1; iNdEx >= 0; iNdEx-- { + { + size, err := m.Content[iNdEx].MarshalToSizedBuffer(dAtA[:i]) + if err != nil { + return 0, err + } + i -= size + i = encodeVarintPlaintextchanges(dAtA, i, uint64(size)) + } + i-- + dAtA[i] = 0xa + } + } + return len(dAtA) - i, nil +} + +func encodeVarintPlaintextchanges(dAtA []byte, offset int, v uint64) int { + offset -= sovPlaintextchanges(v) + base := offset + for v >= 1<<7 { + dAtA[offset] = uint8(v&0x7f | 0x80) + v >>= 7 + offset++ + } + dAtA[offset] = uint8(v) + return base +} +func (m *PlainTextChange) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + return n +} + +func (m *PlainTextChangeContent) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Value != nil { + n += m.Value.Size() + } + return n +} + +func (m *PlainTextChangeContentValueOfTextAppend) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.TextAppend != nil { + l = m.TextAppend.Size() + n += 1 + l + sovPlaintextchanges(uint64(l)) + } + return n +} +func (m *PlainTextChangeTextAppend) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Text) + if l > 0 { + n += 1 + l + sovPlaintextchanges(uint64(l)) + } + return n +} + +func (m *PlainTextChangeSnapshot) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Text) + if l > 0 { + n += 1 + l + sovPlaintextchanges(uint64(l)) + } + return n +} + +func (m *PlainTextChangeData) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if len(m.Content) > 0 { + for _, e := range m.Content { + l = e.Size() + n += 1 + l + sovPlaintextchanges(uint64(l)) + } + } + if m.Snapshot != nil { + l = m.Snapshot.Size() + n += 1 + l + sovPlaintextchanges(uint64(l)) + } + return n +} + +func sovPlaintextchanges(x uint64) (n int) { + return (math_bits.Len64(x|1) + 6) / 7 +} +func sozPlaintextchanges(x uint64) (n int) { + return sovPlaintextchanges(uint64((x << 1) ^ uint64((int64(x) >> 63)))) +} +func (m *PlainTextChange) 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 ErrIntOverflowPlaintextchanges + } + 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: PlainTextChange: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: PlainTextChange: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + default: + iNdEx = preIndex + skippy, err := skipPlaintextchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlaintextchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PlainTextChangeContent) 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 ErrIntOverflowPlaintextchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + wire |= uint64(b&0x7F) << shift + if b < 0x80 { + break + } + } + fieldNum := int32(wire >> 3) + wireType := int(wire & 0x7) + if wireType == 4 { + return fmt.Errorf("proto: Content: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Content: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field TextAppend", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlaintextchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPlaintextchanges + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPlaintextchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + v := &PlainTextChangeTextAppend{} + if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + m.Value = &PlainTextChangeContentValueOfTextAppend{v} + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlaintextchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlaintextchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PlainTextChangeTextAppend) 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 ErrIntOverflowPlaintextchanges + } + 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: TextAppend: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: TextAppend: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlaintextchanges + } + 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 ErrInvalidLengthPlaintextchanges + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPlaintextchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Text = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlaintextchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlaintextchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PlainTextChangeSnapshot) 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 ErrIntOverflowPlaintextchanges + } + 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: Snapshot: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Snapshot: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Text", wireType) + } + var stringLen uint64 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlaintextchanges + } + 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 ErrInvalidLengthPlaintextchanges + } + postIndex := iNdEx + intStringLen + if postIndex < 0 { + return ErrInvalidLengthPlaintextchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Text = string(dAtA[iNdEx:postIndex]) + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlaintextchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlaintextchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *PlainTextChangeData) 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 ErrIntOverflowPlaintextchanges + } + 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: Data: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: Data: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Content", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlaintextchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPlaintextchanges + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPlaintextchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Content = append(m.Content, &PlainTextChangeContent{}) + if err := m.Content[len(m.Content)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + case 2: + if wireType != 2 { + return fmt.Errorf("proto: wrong wireType = %d for field Snapshot", wireType) + } + var msglen int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowPlaintextchanges + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + msglen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if msglen < 0 { + return ErrInvalidLengthPlaintextchanges + } + postIndex := iNdEx + msglen + if postIndex < 0 { + return ErrInvalidLengthPlaintextchanges + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + if m.Snapshot == nil { + m.Snapshot = &PlainTextChangeSnapshot{} + } + if err := m.Snapshot.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { + return err + } + iNdEx = postIndex + default: + iNdEx = preIndex + skippy, err := skipPlaintextchanges(dAtA[iNdEx:]) + if err != nil { + return err + } + if (skippy < 0) || (iNdEx+skippy) < 0 { + return ErrInvalidLengthPlaintextchanges + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func skipPlaintextchanges(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, ErrIntOverflowPlaintextchanges + } + 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, ErrIntOverflowPlaintextchanges + } + 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, ErrIntOverflowPlaintextchanges + } + 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, ErrInvalidLengthPlaintextchanges + } + iNdEx += length + case 3: + depth++ + case 4: + if depth == 0 { + return 0, ErrUnexpectedEndOfGroupPlaintextchanges + } + depth-- + case 5: + iNdEx += 4 + default: + return 0, fmt.Errorf("proto: illegal wireType %d", wireType) + } + if iNdEx < 0 { + return 0, ErrInvalidLengthPlaintextchanges + } + if depth == 0 { + return iNdEx, nil + } + } + return 0, io.ErrUnexpectedEOF +} + +var ( + ErrInvalidLengthPlaintextchanges = fmt.Errorf("proto: negative length found during unmarshaling") + ErrIntOverflowPlaintextchanges = fmt.Errorf("proto: integer overflow") + ErrUnexpectedEndOfGroupPlaintextchanges = fmt.Errorf("proto: unexpected end of group") +) diff --git a/data/pb/protos/aclchanges.proto b/data/pb/protos/aclchanges.proto index 35883b88..5b101b04 100644 --- a/data/pb/protos/aclchanges.proto +++ b/data/pb/protos/aclchanges.proto @@ -13,7 +13,6 @@ message ACLChange { uint64 currentReadKeyHash = 6; int64 timestamp = 7; string identity = 8; - map logHeads = 9; message ACLContentValue { oneof value { diff --git a/data/pb/protos/plaintextchanges.proto b/data/pb/protos/plaintextchanges.proto new file mode 100644 index 00000000..4b5e9d37 --- /dev/null +++ b/data/pb/protos/plaintextchanges.proto @@ -0,0 +1,24 @@ +syntax = "proto3"; +package anytype; +option go_package = "pb"; + +message PlainTextChange { + message Content { + oneof value { + TextAppend textAppend = 1; + } + } + + message TextAppend { + string text = 1; + } + + message Snapshot { + string text = 1; + } + + message Data { + repeated Content content = 1; + Snapshot snapshot = 2; + } +} diff --git a/data/threadbuilder/invalidsnapshotexample.yml b/data/threadbuilder/invalidsnapshotexample.yml index 366a9ced..3a317ac0 100644 --- a/data/threadbuilder/invalidsnapshotexample.yml +++ b/data/threadbuilder/invalidsnapshotexample.yml @@ -1,87 +1,86 @@ thread: author: A -logs: - - id: A.1 +changes: + - id: A.1.1 identity: A - records: - - id: A.1.1 - aclSnapshot: - userStates: - - identity: A - encryptionKey: key.Enc.A - encryptedReadKeys: [key.Read.1] - permission: admin - - identity: B - encryptionKey: key.Enc.B - encryptedReadKeys: [key.Read.1] - permission: admin - snapshot: - blocks: - - id: root - aclChanges: - - userAdd: - identity: A - permission: admin - encryptionKey: key.Enc.A - encryptedReadKeys: [key.Read.1] - - userAdd: - identity: B - permission: admin - encryptionKey: key.Enc.B - encryptedReadKeys: [key.Read.1] - readKey: key.Read.1 - - id: A.1.2 - aclSnapshot: - userStates: - - identity: A - encryptionKey: key.Enc.A - encryptedReadKeys: [key.Read.1] - permission: admin - - identity: B - encryptionKey: key.Enc.B - encryptedReadKeys: [key.Read.1] - permission: admin - - identity: D - encryptionKey: key.Enc.D - encryptedReadKeys: [ key.Read.1 ] - permission: admin - snapshot: - blocks: - - id: root - aclChanges: - - userAdd: - identity: D - permission: admin - encryptionKey: key.Enc.D - encryptedReadKeys: [key.Read.1] - readKey: key.Read.1 - - id: A.1.3 - aclChanges: - - userAdd: - identity: E - permission: admin - encryptionKey: key.Enc.E - encryptedReadKeys: [key.Read.1] - readKey: key.Read.1 - - id: B.1 + aclSnapshot: + userStates: + - identity: A + encryptionKey: key.Enc.A + encryptedReadKeys: [key.Read.1] + permission: admin + - identity: B + encryptionKey: key.Enc.B + encryptedReadKeys: [key.Read.1] + permission: admin + snapshot: + blocks: + - id: root + aclChanges: + - userAdd: + identity: A + permission: admin + encryptionKey: key.Enc.A + encryptedReadKeys: [key.Read.1] + - userAdd: + identity: B + permission: admin + encryptionKey: key.Enc.B + encryptedReadKeys: [key.Read.1] + readKey: key.Read.1 + - id: A.1.2 + identity: A + aclSnapshot: + userStates: + - identity: A + encryptionKey: key.Enc.A + encryptedReadKeys: [key.Read.1] + permission: admin + - identity: B + encryptionKey: key.Enc.B + encryptedReadKeys: [key.Read.1] + permission: admin + - identity: D + encryptionKey: key.Enc.D + encryptedReadKeys: [ key.Read.1 ] + permission: admin + snapshot: + blocks: + - id: root + aclChanges: + - userAdd: + identity: D + permission: admin + encryptionKey: key.Enc.D + encryptedReadKeys: [key.Read.1] + readKey: key.Read.1 + - id: A.1.3 + identity: A + aclChanges: + - userAdd: + identity: E + permission: admin + encryptionKey: key.Enc.E + encryptedReadKeys: [key.Read.1] + readKey: key.Read.1 + - id: B.1.1 identity: B - records: - - id: B.1.1 - aclChanges: - - userAdd: - identity: C - permission: admin - encryptionKey: key.Enc.C - encryptedReadKeys: [ key.Read.1 ] - readKey: key.Read.1 - - id: B.1.2 - aclChanges: - - userAdd: - identity: F - permission: admin - encryptionKey: key.Enc.F - encryptedReadKeys: [ key.Read.1 ] - readKey: key.Read.1 + aclChanges: + - userAdd: + identity: C + permission: admin + encryptionKey: key.Enc.C + encryptedReadKeys: [ key.Read.1 ] + readKey: key.Read.1 + - id: B.1.2 + identity: B + aclChanges: + - userAdd: + identity: F + permission: admin + encryptionKey: key.Enc.F + encryptedReadKeys: [ key.Read.1 ] + readKey: key.Read.1 keys: Enc: - A @@ -120,3 +119,6 @@ graph: baseSnapshot: A.1.2 aclHeads: [A.1.2] treeHeads: [A.1.2] +heads: + - A.1.3 + - B.1.2 diff --git a/data/threadbuilder/keychain.go b/data/threadbuilder/keychain.go index f048d1d6..69051c79 100644 --- a/data/threadbuilder/keychain.go +++ b/data/threadbuilder/keychain.go @@ -1,10 +1,11 @@ package threadbuilder import ( - "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/textileio/go-threads/crypto/symmetric" "hash/fnv" "strings" + + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" + "github.com/textileio/go-threads/crypto/symmetric" ) type SymKey struct { diff --git a/data/threadbuilder/threadbuilder.go b/data/threadbuilder/threadbuilder.go index f391e8ad..45437383 100644 --- a/data/threadbuilder/threadbuilder.go +++ b/data/threadbuilder/threadbuilder.go @@ -3,43 +3,36 @@ package threadbuilder import ( "context" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/lib/core/smartblock" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/lib/pb/model" - "github.com/gogo/protobuf/proto" "io/ioutil" - "sort" + + "github.com/gogo/protobuf/proto" + "gopkg.in/yaml.v3" + + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" ) -type threadRecord struct { +const plainTextDocType uint16 = 1 + +type threadChange struct { *pb.ACLChange id string - logId string readKey *SymKey signKey threadmodels.SigningPrivKey - prevRecord *threadRecord - changesData *pb.ACLChangeChangeData -} - -type threadLog struct { - id string - owner string - records []*threadRecord + changesData *pb.PlainTextChangeData } type ThreadBuilder struct { threadId string - logs map[string]*threadLog - allRecords map[string]*threadRecord + allChanges map[string]*threadChange + heads []string keychain *Keychain } func NewThreadBuilder(keychain *Keychain) *ThreadBuilder { return &ThreadBuilder{ - logs: make(map[string]*threadLog), - allRecords: make(map[string]*threadRecord), + allChanges: make(map[string]*threadChange), keychain: keychain, } } @@ -70,27 +63,13 @@ func (t *ThreadBuilder) GetKeychain() *Keychain { return t.keychain } -func (t *ThreadBuilder) GetLogs() ([]threadmodels.ThreadLog, error) { - var logs []threadmodels.ThreadLog - for _, l := range t.logs { - logs = append(logs, threadmodels.ThreadLog{ - ID: l.id, - Head: l.records[len(l.records)-1].id, - Counter: int64(len(l.records)), - }) - } - sort.Slice(logs, func(i, j int) bool { - return logs[i].ID < logs[j].ID - }) - return logs, nil -} +// writer can create docs -> id can create writer permissions +// by id we can check who created +// at the same time this guy can add some random folks which are not in space +// but we should compare this against space in the future -func (t *ThreadBuilder) GetRecord(ctx context.Context, recordID string) (*threadmodels.ThreadRecord, error) { - rec := t.allRecords[recordID] - prevId := "" - if rec.prevRecord != nil { - prevId = rec.prevRecord.id - } +func (t *ThreadBuilder) GetChange(ctx context.Context, recordID string) (*threadmodels.RawChange, error) { + rec := t.allChanges[recordID] var encrypted []byte if rec.changesData != nil { @@ -117,19 +96,15 @@ func (t *ThreadBuilder) GetRecord(ctx context.Context, recordID string) (*thread panic("should be able to sign final acl message!") } - transformedRec := &threadmodels.ThreadRecord{ - PrevId: prevId, - Id: rec.id, - LogId: rec.logId, - Signed: &threadmodels.SignedPayload{ - Payload: aclMarshaled, - Signature: signature, - }, + transformedRec := &threadmodels.RawChange{ + Payload: aclMarshaled, + Signature: signature, + Id: recordID, } return transformedRec, nil } -func (t *ThreadBuilder) PushRecord(payload proto.Marshaler) (id string, err error) { +func (t *ThreadBuilder) PushChange(payload proto.Marshaler) (id string, err error) { panic("implement me") } @@ -139,63 +114,49 @@ func (t *ThreadBuilder) Parse(thread *YMLThread) { // the same thing is happening for the encryption keys t.keychain.ParseKeys(&thread.Keys) t.threadId = t.parseThreadId(thread.Description) - for _, l := range thread.Logs { - newLog := &threadLog{ - id: l.Id, - owner: t.keychain.GetIdentity(l.Identity), + for _, ch := range thread.Changes { + newChange := &threadChange{ + id: ch.Id, } - var records []*threadRecord - for _, r := range l.Records { - newRecord := &threadRecord{ - id: r.Id, - logId: newLog.id, + k := t.keychain.GetKey(ch.ReadKey).(*SymKey) + newChange.readKey = k + newChange.signKey = t.keychain.SigningKeys[ch.Identity] + aclChange := &pb.ACLChange{} + aclChange.Identity = newChange.Identity + if len(ch.AclChanges) > 0 || ch.AclSnapshot != nil { + aclChange.AclData = &pb.ACLChangeACLData{} + if ch.AclSnapshot != nil { + aclChange.AclData.AclSnapshot = t.parseACLSnapshot(ch.AclSnapshot) } - if len(records) > 0 { - newRecord.prevRecord = records[len(records)-1] + if ch.AclChanges != nil { + var aclChangeContents []*pb.ACLChangeACLContentValue + for _, ch := range ch.AclChanges { + aclChangeContent := t.parseACLChange(ch) + aclChangeContents = append(aclChangeContents, aclChangeContent) + } + aclChange.AclData.AclContent = aclChangeContents } - k := t.keychain.GetKey(r.ReadKey).(*SymKey) - newRecord.readKey = k - newRecord.signKey = t.keychain.SigningKeys[l.Identity] - - aclChange := &pb.ACLChange{} - aclChange.Identity = newLog.owner - if len(r.AclChanges) > 0 || r.AclSnapshot != nil { - aclChange.AclData = &pb.ACLChangeACLData{} - if r.AclSnapshot != nil { - aclChange.AclData.AclSnapshot = t.parseACLSnapshot(r.AclSnapshot) - } - if r.AclChanges != nil { - var aclChangeContents []*pb.ACLChangeACLContentValue - for _, ch := range r.AclChanges { - aclChangeContent := t.parseACLChange(ch) - aclChangeContents = append(aclChangeContents, aclChangeContent) - } - aclChange.AclData.AclContent = aclChangeContents - } - } - if len(r.Changes) > 0 || r.Snapshot != nil { - newRecord.changesData = &pb.ACLChangeChangeData{} - if r.Snapshot != nil { - newRecord.changesData.Snapshot = t.parseChangeSnapshot(r.Snapshot) - } - if len(r.Changes) > 0 { - var changeContents []*pb.ChangeContent - for _, ch := range r.Changes { - aclChangeContent := t.parseDocumentChange(ch) - changeContents = append(changeContents, aclChangeContent) - } - newRecord.changesData.Content = changeContents - } - } - aclChange.CurrentReadKeyHash = k.Hash - newRecord.ACLChange = aclChange - t.allRecords[newRecord.id] = newRecord - records = append(records, newRecord) } - newLog.records = records - t.logs[newLog.id] = newLog + if len(ch.Changes) > 0 || ch.Snapshot != nil { + newChange.changesData = &pb.PlainTextChangeData{} + if ch.Snapshot != nil { + newChange.changesData.Snapshot = t.parseChangeSnapshot(ch.Snapshot) + } + if len(ch.Changes) > 0 { + var changeContents []*pb.PlainTextChangeContent + for _, ch := range ch.Changes { + aclChangeContent := t.parseDocumentChange(ch) + changeContents = append(changeContents, aclChangeContent) + } + newChange.changesData.Content = changeContents + } + } + aclChange.CurrentReadKeyHash = k.Hash + newChange.ACLChange = aclChange + t.allChanges[newChange.id] = newChange } t.parseGraph(thread) + t.parseHeads(thread) } func (t *ThreadBuilder) parseThreadId(description *ThreadDescription) string { @@ -203,7 +164,7 @@ func (t *ThreadBuilder) parseThreadId(description *ThreadDescription) string { panic("no author in thread") } key := t.keychain.SigningKeys[description.Author] - id, err := threadmodels.CreateACLThreadID(key.GetPublic(), smartblock.SmartBlockTypeWorkspace) + id, err := threadmodels.CreateACLThreadID(key.GetPublic(), plainTextDocType) if err != nil { panic(err) } @@ -211,16 +172,9 @@ func (t *ThreadBuilder) parseThreadId(description *ThreadDescription) string { return id.String() } -func (t *ThreadBuilder) parseChangeSnapshot(s *ChangeSnapshot) *pb.ChangeSnapshot { - data := &model.SmartBlockSnapshotBase{} - var blocks []*model.Block - for _, b := range s.Blocks { - modelBlock := &model.Block{Id: b.Id, ChildrenIds: b.ChildrenIds} - blocks = append(blocks, modelBlock) - } - data.Blocks = blocks - return &pb.ChangeSnapshot{ - Data: data, +func (t *ThreadBuilder) parseChangeSnapshot(s *PlainTextSnapshot) *pb.PlainTextChangeSnapshot { + return &pb.PlainTextChangeSnapshot{ + Text: s.Text, } } @@ -244,18 +198,16 @@ func (t *ThreadBuilder) parseACLSnapshot(s *ACLSnapshot) *pb.ACLChangeACLSnapsho } } -func (t *ThreadBuilder) parseDocumentChange(ch *DocumentChange) (convCh *pb.ChangeContent) { +func (t *ThreadBuilder) parseDocumentChange(ch *PlainTextChange) (convCh *pb.PlainTextChangeContent) { switch { - case ch.BlockAdd != nil: - blockAdd := ch.BlockAdd - - convCh = &pb.ChangeContent{ - Value: &pb.ChangeContentValueOfBlockCreate{ - BlockCreate: &pb.ChangeBlockCreate{ - TargetId: blockAdd.TargetId, - Position: model.Block_Inner, - Blocks: []*model.Block{&model.Block{Id: blockAdd.Id}}, - }}} + case ch.TextAppend != nil: + convCh = &pb.PlainTextChangeContent{ + Value: &pb.PlainTextChangeContentValueOfTextAppend{ + TextAppend: &pb.PlainTextChangeTextAppend{ + Text: ch.TextAppend.Text, + }, + }, + } } if convCh == nil { panic("cannot have empty document change") @@ -410,25 +362,24 @@ func (t *ThreadBuilder) convertPermission(perm string) pb.ACLChangeUserPermissio } } -func (t *ThreadBuilder) traverseFromHeads(f func(t *threadRecord) error) error { - allLogs, err := t.GetLogs() - if err != nil { - return err - } +func (t *ThreadBuilder) traverseFromHeads(f func(t *threadChange) error) error { + uniqMap := map[string]struct{}{} + stack := t.heads + for len(stack) > 0 { + id := stack[len(stack)-1] + stack = stack[:len(stack)-1] + if _, exists := uniqMap[id]; exists { + continue + } - for _, log := range allLogs { - head := t.allRecords[log.Head] - err = f(head) - if err != nil { + ch := t.allChanges[id] + uniqMap[id] = struct{}{} + if err := f(ch); err != nil { return err } - for head.prevRecord != nil { - head = head.prevRecord - err = f(head) - if err != nil { - return err - } + for _, prev := range ch.ACLChange.TreeHeadIds { + stack = append(stack, prev) } } return nil @@ -436,9 +387,13 @@ func (t *ThreadBuilder) traverseFromHeads(f func(t *threadRecord) error) error { func (t *ThreadBuilder) parseGraph(thread *YMLThread) { for _, node := range thread.Graph { - rec := t.allRecords[node.Id] + rec := t.allChanges[node.Id] rec.AclHeadIds = node.ACLHeads rec.TreeHeadIds = node.TreeHeads rec.SnapshotBaseId = node.BaseSnapshot } } + +func (t *ThreadBuilder) parseHeads(thread *YMLThread) { + t.heads = thread.Heads +} diff --git a/data/threadbuilder/threadbuildergraph_nix.go b/data/threadbuilder/threadbuildergraph_nix.go index 75c7e06d..1ea60a5a 100644 --- a/data/threadbuilder/threadbuildergraph_nix.go +++ b/data/threadbuilder/threadbuildergraph_nix.go @@ -30,7 +30,7 @@ func (t *ThreadBuilder) Graph() (string, error) { graph.SetDir(true) var nodes = make(map[string]struct{}) - var addNodes = func(r *threadRecord) error { + var addNodes = func(r *threadChange) error { // TODO: revisit function after checking style := "solid" @@ -105,7 +105,7 @@ func (t *ThreadBuilder) Graph() (string, error) { return nil } - var addLinks = func(t *threadRecord) error { + var addLinks = func(t *threadChange) error { for _, prevId := range t.AclHeadIds { err := createEdge(t.id, prevId, EdgeParameters{ style: "dashed", diff --git a/data/threadbuilder/ymlentities.go b/data/threadbuilder/ymlentities.go index 771bbf27..3ef03f05 100644 --- a/data/threadbuilder/ymlentities.go +++ b/data/threadbuilder/ymlentities.go @@ -20,11 +20,8 @@ type ACLSnapshot struct { } `yaml:"userStates"` } -type ChangeSnapshot struct { - Blocks []struct { - Id string `yaml:"id"` - ChildrenIds []string `yaml:"childrenIds"` - } `yaml:"blocks"` +type PlainTextSnapshot struct { + Text string `yaml:"text"` } type ACLChange struct { @@ -67,29 +64,25 @@ type ACLChange struct { } } -type DocumentChange struct { - BlockAdd *struct { - Id string `yaml:"id"` - TargetId string `yaml:"targetId"` +type PlainTextChange struct { + TextAppend *struct { + Text string `yaml:"text"` } `yaml:"blockAdd"` } type YMLThread struct { Description *ThreadDescription `yaml:"thread"` - Logs []struct { + Changes []struct { Id string `yaml:"id"` Identity string `yaml:"identity"` - Records []struct { - Id string `yaml:"id"` - AclSnapshot *ACLSnapshot `yaml:"aclSnapshot"` - Snapshot *ChangeSnapshot `yaml:"snapshot"` - AclChanges []*ACLChange `yaml:"aclChanges"` - Changes []*DocumentChange `yaml:"changes"` + AclSnapshot *ACLSnapshot `yaml:"aclSnapshot"` + Snapshot *PlainTextSnapshot `yaml:"snapshot"` + AclChanges []*ACLChange `yaml:"aclChanges"` + Changes []*PlainTextChange `yaml:"changes"` - ReadKey string `yaml:"readKey"` - } `yaml:"records"` - } `yaml:"logs"` + ReadKey string `yaml:"readKey"` + } `yaml:"changes"` Keys Keys `yaml:"keys"` @@ -100,4 +93,6 @@ type YMLThread struct { ACLHeads []string `yaml:"aclHeads"` TreeHeads []string `yaml:"treeHeads"` } `yaml:"graph"` + + Heads []string `yaml:"heads"` } diff --git a/data/threadmodels/models.go b/data/threadmodels/models.go index a9ef39cc..a0d3f8d7 100644 --- a/data/threadmodels/models.go +++ b/data/threadmodels/models.go @@ -2,33 +2,17 @@ package threadmodels import ( "context" - "github.com/gogo/protobuf/proto" ) type Thread interface { ID() string - GetLogs() ([]ThreadLog, error) - GetRecord(ctx context.Context, recordID string) (*ThreadRecord, error) - PushRecord(payload proto.Marshaler) (id string, err error) - - // SubscribeForRecords() + GetChange(ctx context.Context, recordID string) (*RawChange, error) + PushChange(payload proto.Marshaler) (id string, err error) } -type SignedPayload struct { +type RawChange struct { Payload []byte Signature []byte -} - -type ThreadRecord struct { - PrevId string - Id string - LogId string - Signed *SignedPayload -} - -type ThreadLog struct { - ID string - Head string - Counter int64 + Id string } diff --git a/data/threadmodels/threadid.go b/data/threadmodels/threadid.go index 4d2f0392..c2bfe178 100644 --- a/data/threadmodels/threadid.go +++ b/data/threadmodels/threadid.go @@ -4,12 +4,12 @@ import ( "crypto/rand" "encoding/binary" "fmt" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/lib/core/smartblock" - "github.com/textileio/go-threads/core/thread" "hash/fnv" + + "github.com/textileio/go-threads/core/thread" ) -func CreateACLThreadID(k SigningPubKey, blockType smartblock.SmartBlockType) (thread.ID, error) { +func CreateACLThreadID(k SigningPubKey, docType uint16) (thread.ID, error) { rndlen := 32 buf := make([]byte, 8+rndlen) @@ -31,7 +31,7 @@ func CreateACLThreadID(k SigningPubKey, blockType smartblock.SmartBlockType) (th // putting hash of the pubkey in the beginning binary.LittleEndian.PutUint64(buf[:8], res) - return threadIDFromBytes(blockType, buf) + return threadIDFromBytes(docType, buf) } func VerifyACLThreadID(k SigningPubKey, threadId thread.ID) (bool, error) { @@ -52,7 +52,7 @@ func VerifyACLThreadID(k SigningPubKey, threadId thread.ID) (bool, error) { } func threadIDFromBytes( - blockType smartblock.SmartBlockType, + docType uint16, b []byte) (thread.ID, error) { blen := len(b) @@ -60,7 +60,7 @@ func threadIDFromBytes( buf := make([]byte, 2*binary.MaxVarintLen64+blen) n := binary.PutUvarint(buf, thread.V1) n += binary.PutUvarint(buf[n:], uint64(thread.AccessControlled)) - n += binary.PutUvarint(buf[n:], uint64(blockType)) + n += binary.PutUvarint(buf[n:], uint64(docType)) cn := copy(buf[n:], b) if cn != blen { diff --git a/data/treebuilder.go b/data/treebuilder.go index 0a226d70..b7d17577 100644 --- a/data/treebuilder.go +++ b/data/treebuilder.go @@ -4,8 +4,8 @@ import ( "context" "errors" "fmt" + "github.com/anytypeio/go-anytype-infrastructure-experiments/data/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/data/threadmodels" - "github.com/anytypeio/go-anytype-infrastructure-experiments/pb" "github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/lib/logging" "github.com/anytypeio/go-anytype-infrastructure-experiments/util/slice" "github.com/gogo/protobuf/proto" @@ -48,7 +48,7 @@ func (tb *TreeBuilder) loadChange(id string) (ch *Change, err error) { ctx, cancel := context.WithTimeout(context.Background(), time.Second*30) defer cancel() - record, err := tb.thread.GetRecord(ctx, id) + record, err := tb.thread.GetChange(ctx, id) if err != nil { return nil, err } diff --git a/go.mod b/go.mod index dd9e3e9e..45eaba98 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,8 @@ go 1.18 require ( github.com/textileio/go-threads v1.0.2-0.20210304072541-d0f91da84404 + gopkg.in/yaml.v2 v2.4.0 // indirect + gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c ) replace github.com/textileio/go-threads => github.com/anytypeio/go-threads v1.1.0-rc1.0.20220223104843-a67245cee80e