Fix request handler heads update logic
This commit is contained in:
parent
5b821c0d2a
commit
0474bd37a1
@ -24,11 +24,6 @@ type AddResult struct {
|
||||
Summary AddResultSummary
|
||||
}
|
||||
|
||||
type HeadWithPathToRoot struct {
|
||||
Id string
|
||||
Path []string
|
||||
}
|
||||
|
||||
type TreeUpdateListener interface {
|
||||
Update(tree ACLTree)
|
||||
Rebuild(tree ACLTree)
|
||||
@ -49,7 +44,7 @@ type ACLTree interface {
|
||||
Iterate(func(change *Change) bool)
|
||||
IterateFrom(string, func(change *Change) bool)
|
||||
HasChange(string) bool
|
||||
HeadsPathToRoot() []HeadWithPathToRoot
|
||||
SnapshotPath() []string
|
||||
|
||||
Close() error
|
||||
}
|
||||
@ -391,17 +386,13 @@ func (a *aclTree) Close() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *aclTree) HeadsPathToRoot() []HeadWithPathToRoot {
|
||||
func (a *aclTree) SnapshotPath() []string {
|
||||
a.RLock()
|
||||
defer a.RUnlock()
|
||||
var headsWithPath []HeadWithPathToRoot
|
||||
for _, h := range a.fullTree.Heads() {
|
||||
headWithPath := HeadWithPathToRoot{
|
||||
Id: h,
|
||||
}
|
||||
|
||||
var path []string
|
||||
// TODO: think that the user may have not all of the snapshots locally
|
||||
currentSnapshotId := a.fullTree.attached[h].SnapshotId
|
||||
currentSnapshotId := a.fullTree.RootId()
|
||||
for currentSnapshotId != "" {
|
||||
sn, err := a.treeBuilder.loadChange(currentSnapshotId)
|
||||
if err != nil {
|
||||
@ -410,8 +401,5 @@ func (a *aclTree) HeadsPathToRoot() []HeadWithPathToRoot {
|
||||
path = append(path, currentSnapshotId)
|
||||
currentSnapshotId = sn.SnapshotId
|
||||
}
|
||||
headWithPath.Path = path
|
||||
headsWithPath = append(headsWithPath, headWithPath)
|
||||
}
|
||||
return headsWithPath
|
||||
return path
|
||||
}
|
||||
|
||||
@ -2,7 +2,6 @@ package sync
|
||||
|
||||
import (
|
||||
"context"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/sync/syncpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/service/treecache"
|
||||
@ -16,30 +15,34 @@ type requestHander struct {
|
||||
|
||||
func (r *requestHander) HandleHeadUpdate(ctx context.Context, senderId string, update *syncpb.SyncHeadUpdate) (err error) {
|
||||
var fullRequest *syncpb.SyncFullRequest
|
||||
var addedChanges []*aclpb.RawChange
|
||||
var headsWithPath []acltree.HeadWithPathToRoot
|
||||
var snapshotPath []string
|
||||
var result acltree.AddResult
|
||||
defer func() {
|
||||
if err != nil || fullRequest != nil {
|
||||
return
|
||||
}
|
||||
newUpdate := syncpb.NewHeadsUpdate(update.TreeId, headsWithPath, addedChanges)
|
||||
newUpdate := &syncpb.SyncHeadUpdate{
|
||||
Heads: result.Heads,
|
||||
Changes: result.Added,
|
||||
SnapshotPath: snapshotPath,
|
||||
TreeId: update.TreeId,
|
||||
}
|
||||
err = r.client.NotifyHeadsChanged(newUpdate)
|
||||
}()
|
||||
err = r.treeCache.Do(ctx, update.TreeId, func(tree acltree.ACLTree) error {
|
||||
// TODO: check if we already have those changes
|
||||
res, err := tree.AddRawChanges(ctx, update.Changes...)
|
||||
result, err = tree.AddRawChanges(ctx, update.Changes...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
addedChanges = res.Added
|
||||
shouldFullSync := !r.compareHeads(update.Heads, tree.Heads())
|
||||
shouldFullSync := !slice.UnsortedEquals(update.Heads, tree.Heads())
|
||||
snapshotPath = tree.SnapshotPath()
|
||||
if shouldFullSync {
|
||||
fullRequest, err = r.prepareFullSyncRequest(tree)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
headsWithPath = tree.HeadsPathToRoot()
|
||||
return nil
|
||||
})
|
||||
if err != nil {
|
||||
@ -55,15 +58,7 @@ func (r *requestHander) HandleFullSync(ctx context.Context, senderId string, req
|
||||
return nil
|
||||
}
|
||||
|
||||
func (r *requestHander) compareHeads(syncHeads []*syncpb.SyncHead, heads []string) bool {
|
||||
for _, head := range syncHeads {
|
||||
if slice.FindPos(heads, head.Id) == -1 {
|
||||
return false
|
||||
}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
func (r *requestHander) prepareFullSyncRequest(tree acltree.ACLTree) (*syncpb.SyncFullRequest, error) {
|
||||
|
||||
return nil, nil
|
||||
}
|
||||
|
||||
@ -1,22 +0,0 @@
|
||||
package syncpb
|
||||
|
||||
import (
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/aclchanges/aclpb"
|
||||
"github.com/anytypeio/go-anytype-infrastructure-experiments/pkg/acl/acltree"
|
||||
)
|
||||
|
||||
func NewHeadsUpdate(treeId string, headsWithPath []acltree.HeadWithPathToRoot, changes []*aclpb.RawChange) *SyncHeadUpdate {
|
||||
var heads []*SyncHead
|
||||
for _, headWithPath := range headsWithPath {
|
||||
syncHead := &SyncHead{
|
||||
Id: headWithPath.Id,
|
||||
SnapshotPath: headWithPath.Path,
|
||||
}
|
||||
heads = append(heads, syncHead)
|
||||
}
|
||||
return &SyncHeadUpdate{
|
||||
Heads: heads,
|
||||
Changes: changes,
|
||||
TreeId: treeId,
|
||||
}
|
||||
}
|
||||
@ -6,28 +6,26 @@ import "pkg/acl/aclchanges/aclpb/protos/aclchanges.proto";
|
||||
|
||||
message Sync {
|
||||
message HeadUpdate {
|
||||
repeated Head heads = 1;
|
||||
repeated string heads = 1;
|
||||
repeated acl.RawChange changes = 2;
|
||||
string treeId = 3;
|
||||
}
|
||||
|
||||
message Head {
|
||||
string id = 1;
|
||||
repeated string snapshotPath = 2;
|
||||
repeated string snapshotPath = 4;
|
||||
}
|
||||
|
||||
message Full {
|
||||
// here with send the request with all changes we have (we already know sender's snapshot path)
|
||||
message Request {
|
||||
repeated Head heads = 1;
|
||||
repeated string heads = 1;
|
||||
repeated acl.RawChange changes = 2;
|
||||
string treeId = 3;
|
||||
repeated string snapshotPath = 4;
|
||||
}
|
||||
|
||||
message Response {
|
||||
repeated Head heads = 1;
|
||||
repeated string heads = 1;
|
||||
repeated acl.RawChange changes = 2;
|
||||
string treeId = 3;
|
||||
repeated string snapshotPath = 4;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -60,9 +60,10 @@ func (m *Sync) XXX_DiscardUnknown() {
|
||||
var xxx_messageInfo_Sync proto.InternalMessageInfo
|
||||
|
||||
type SyncHeadUpdate struct {
|
||||
Heads []*SyncHead `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"`
|
||||
TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"`
|
||||
SnapshotPath []string `protobuf:"bytes,4,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SyncHeadUpdate) Reset() { *m = SyncHeadUpdate{} }
|
||||
@ -98,7 +99,7 @@ func (m *SyncHeadUpdate) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_SyncHeadUpdate proto.InternalMessageInfo
|
||||
|
||||
func (m *SyncHeadUpdate) GetHeads() []*SyncHead {
|
||||
func (m *SyncHeadUpdate) GetHeads() []string {
|
||||
if m != nil {
|
||||
return m.Heads
|
||||
}
|
||||
@ -119,52 +120,7 @@ func (m *SyncHeadUpdate) GetTreeId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type SyncHead struct {
|
||||
Id string `protobuf:"bytes,1,opt,name=id,proto3" json:"id,omitempty"`
|
||||
SnapshotPath []string `protobuf:"bytes,2,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SyncHead) Reset() { *m = SyncHead{} }
|
||||
func (m *SyncHead) String() string { return proto.CompactTextString(m) }
|
||||
func (*SyncHead) ProtoMessage() {}
|
||||
func (*SyncHead) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 1}
|
||||
}
|
||||
func (m *SyncHead) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *SyncHead) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_SyncHead.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 *SyncHead) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_SyncHead.Merge(m, src)
|
||||
}
|
||||
func (m *SyncHead) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *SyncHead) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_SyncHead.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_SyncHead proto.InternalMessageInfo
|
||||
|
||||
func (m *SyncHead) GetId() string {
|
||||
if m != nil {
|
||||
return m.Id
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SyncHead) GetSnapshotPath() []string {
|
||||
func (m *SyncHeadUpdate) GetSnapshotPath() []string {
|
||||
if m != nil {
|
||||
return m.SnapshotPath
|
||||
}
|
||||
@ -178,7 +134,7 @@ func (m *SyncFull) Reset() { *m = SyncFull{} }
|
||||
func (m *SyncFull) String() string { return proto.CompactTextString(m) }
|
||||
func (*SyncFull) ProtoMessage() {}
|
||||
func (*SyncFull) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 2}
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 1}
|
||||
}
|
||||
func (m *SyncFull) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -209,16 +165,17 @@ var xxx_messageInfo_SyncFull proto.InternalMessageInfo
|
||||
|
||||
// here with send the request with all changes we have (we already know sender's snapshot path)
|
||||
type SyncFullRequest struct {
|
||||
Heads []*SyncHead `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"`
|
||||
TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"`
|
||||
SnapshotPath []string `protobuf:"bytes,4,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SyncFullRequest) Reset() { *m = SyncFullRequest{} }
|
||||
func (m *SyncFullRequest) String() string { return proto.CompactTextString(m) }
|
||||
func (*SyncFullRequest) ProtoMessage() {}
|
||||
func (*SyncFullRequest) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 2, 0}
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 1, 0}
|
||||
}
|
||||
func (m *SyncFullRequest) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -247,7 +204,7 @@ func (m *SyncFullRequest) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_SyncFullRequest proto.InternalMessageInfo
|
||||
|
||||
func (m *SyncFullRequest) GetHeads() []*SyncHead {
|
||||
func (m *SyncFullRequest) GetHeads() []string {
|
||||
if m != nil {
|
||||
return m.Heads
|
||||
}
|
||||
@ -268,17 +225,25 @@ func (m *SyncFullRequest) GetTreeId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SyncFullRequest) GetSnapshotPath() []string {
|
||||
if m != nil {
|
||||
return m.SnapshotPath
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
type SyncFullResponse struct {
|
||||
Heads []*SyncHead `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Heads []string `protobuf:"bytes,1,rep,name=heads,proto3" json:"heads,omitempty"`
|
||||
Changes []*aclpb.RawChange `protobuf:"bytes,2,rep,name=changes,proto3" json:"changes,omitempty"`
|
||||
TreeId string `protobuf:"bytes,3,opt,name=treeId,proto3" json:"treeId,omitempty"`
|
||||
SnapshotPath []string `protobuf:"bytes,4,rep,name=snapshotPath,proto3" json:"snapshotPath,omitempty"`
|
||||
}
|
||||
|
||||
func (m *SyncFullResponse) Reset() { *m = SyncFullResponse{} }
|
||||
func (m *SyncFullResponse) String() string { return proto.CompactTextString(m) }
|
||||
func (*SyncFullResponse) ProtoMessage() {}
|
||||
func (*SyncFullResponse) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 2, 1}
|
||||
return fileDescriptor_5f66cdd599c6466f, []int{0, 1, 1}
|
||||
}
|
||||
func (m *SyncFullResponse) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@ -307,7 +272,7 @@ func (m *SyncFullResponse) XXX_DiscardUnknown() {
|
||||
|
||||
var xxx_messageInfo_SyncFullResponse proto.InternalMessageInfo
|
||||
|
||||
func (m *SyncFullResponse) GetHeads() []*SyncHead {
|
||||
func (m *SyncFullResponse) GetHeads() []string {
|
||||
if m != nil {
|
||||
return m.Heads
|
||||
}
|
||||
@ -328,10 +293,16 @@ func (m *SyncFullResponse) GetTreeId() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *SyncFullResponse) GetSnapshotPath() []string {
|
||||
if m != nil {
|
||||
return m.SnapshotPath
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Sync)(nil), "anytype.Sync")
|
||||
proto.RegisterType((*SyncHeadUpdate)(nil), "anytype.Sync.HeadUpdate")
|
||||
proto.RegisterType((*SyncHead)(nil), "anytype.Sync.Head")
|
||||
proto.RegisterType((*SyncFull)(nil), "anytype.Sync.Full")
|
||||
proto.RegisterType((*SyncFullRequest)(nil), "anytype.Sync.Full.Request")
|
||||
proto.RegisterType((*SyncFullResponse)(nil), "anytype.Sync.Full.Response")
|
||||
@ -342,26 +313,25 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_5f66cdd599c6466f = []byte{
|
||||
// 297 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xbc, 0x92, 0xb1, 0x4e, 0xc3, 0x30,
|
||||
0x10, 0x86, 0xeb, 0xb6, 0xb4, 0xf4, 0x40, 0x1d, 0x3c, 0xa0, 0x28, 0x83, 0x55, 0x55, 0x42, 0xca,
|
||||
0xe4, 0x22, 0xd8, 0x18, 0x41, 0x42, 0xb0, 0x21, 0x23, 0x16, 0x36, 0xd7, 0x3e, 0x35, 0x15, 0x91,
|
||||
0x63, 0x6a, 0xb7, 0x90, 0xb7, 0xe0, 0x61, 0x78, 0x08, 0xc6, 0x8e, 0x8c, 0x28, 0x79, 0x06, 0x76,
|
||||
0x14, 0x27, 0xa8, 0xe2, 0x05, 0x3a, 0xd8, 0xba, 0xfb, 0xef, 0xbb, 0xdf, 0x96, 0x7d, 0x70, 0xea,
|
||||
0x70, 0xb5, 0x59, 0x2a, 0x9c, 0xb9, 0xc2, 0xa8, 0xb0, 0xd9, 0xf9, 0xcc, 0xae, 0x72, 0x9f, 0xbb,
|
||||
0x90, 0xf1, 0x10, 0xd3, 0xa1, 0x34, 0x85, 0x2f, 0x2c, 0xc6, 0x67, 0xf6, 0x79, 0x31, 0x93, 0x2a,
|
||||
0xab, 0x97, 0x4a, 0xa5, 0x59, 0xa0, 0xab, 0xc3, 0x5d, 0xd3, 0x4e, 0x6f, 0x5a, 0xa7, 0x1f, 0x3d,
|
||||
0xe8, 0x3f, 0x14, 0x46, 0xc5, 0x6f, 0x00, 0xb7, 0x28, 0xf5, 0xa3, 0xd5, 0xd2, 0x23, 0x4d, 0xe0,
|
||||
0x20, 0x45, 0xa9, 0x5d, 0x44, 0x26, 0xbd, 0xe4, 0xe8, 0x9c, 0xf2, 0xf6, 0x04, 0x5e, 0xb3, 0xbc,
|
||||
0x06, 0x45, 0x03, 0xd0, 0x04, 0x86, 0xad, 0x63, 0xd4, 0x0d, 0xec, 0x98, 0x4b, 0x95, 0x71, 0x21,
|
||||
0x5f, 0xaf, 0x83, 0x2c, 0xfe, 0xca, 0xf4, 0x04, 0x06, 0x7e, 0x85, 0x78, 0xa7, 0xa3, 0xde, 0x84,
|
||||
0x24, 0x23, 0xd1, 0x66, 0xf1, 0x25, 0xf4, 0x6b, 0x43, 0x3a, 0x86, 0xee, 0x52, 0x47, 0x24, 0xd4,
|
||||
0xba, 0x4b, 0x4d, 0xa7, 0x70, 0xec, 0x8c, 0xb4, 0x2e, 0xcd, 0xfd, 0xbd, 0xf4, 0x69, 0xb0, 0x1f,
|
||||
0x89, 0x7f, 0x5a, 0xfc, 0x43, 0xa0, 0x7f, 0xb3, 0xce, 0xb2, 0x78, 0x0d, 0x43, 0x81, 0x2f, 0x6b,
|
||||
0x74, 0x7e, 0xaf, 0x77, 0xdf, 0xc0, 0xa1, 0x40, 0x67, 0x73, 0xe3, 0xf6, 0xfa, 0x66, 0x57, 0x93,
|
||||
0xcf, 0x92, 0x91, 0x6d, 0xc9, 0xc8, 0x77, 0xc9, 0xc8, 0x7b, 0xc5, 0x3a, 0xdb, 0x8a, 0x75, 0xbe,
|
||||
0x2a, 0xd6, 0x79, 0x1a, 0x34, 0x53, 0x32, 0x1f, 0x84, 0xff, 0xbd, 0xf8, 0x0d, 0x00, 0x00, 0xff,
|
||||
0xff, 0xac, 0xf4, 0x50, 0xb7, 0x43, 0x02, 0x00, 0x00,
|
||||
// 273 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2d, 0x4e, 0x2d, 0x2a,
|
||||
0xcb, 0x4c, 0x4e, 0xd5, 0x2f, 0xae, 0xcc, 0x4b, 0x06, 0x13, 0x05, 0x49, 0xfa, 0x05, 0x45, 0xf9,
|
||||
0x25, 0xf9, 0xc5, 0x60, 0x9e, 0x1e, 0x98, 0x2d, 0xc4, 0x9e, 0x98, 0x57, 0x59, 0x52, 0x59, 0x90,
|
||||
0x2a, 0x65, 0x50, 0x90, 0x9d, 0xae, 0x9f, 0x98, 0x9c, 0x03, 0xc2, 0xc9, 0x19, 0x89, 0x79, 0xe9,
|
||||
0xa9, 0xc5, 0x20, 0x26, 0x42, 0x13, 0x42, 0x1c, 0xa2, 0x55, 0x69, 0x35, 0x33, 0x17, 0x4b, 0x70,
|
||||
0x65, 0x5e, 0xb2, 0x54, 0x07, 0x23, 0x17, 0x97, 0x47, 0x6a, 0x62, 0x4a, 0x68, 0x41, 0x4a, 0x62,
|
||||
0x49, 0xaa, 0x90, 0x08, 0x17, 0x6b, 0x46, 0x6a, 0x62, 0x4a, 0xb1, 0x04, 0xa3, 0x02, 0xb3, 0x06,
|
||||
0x67, 0x10, 0x84, 0x23, 0xa4, 0xc1, 0xc5, 0x0e, 0xd5, 0x2e, 0xc1, 0xa4, 0xc0, 0xac, 0xc1, 0x6d,
|
||||
0xc4, 0xa7, 0x97, 0x98, 0x9c, 0xa3, 0x17, 0x94, 0x58, 0xee, 0x0c, 0x16, 0x0e, 0x82, 0x49, 0x0b,
|
||||
0x89, 0x71, 0xb1, 0x95, 0x14, 0xa5, 0xa6, 0x7a, 0xa6, 0x48, 0x30, 0x2b, 0x30, 0x6a, 0x70, 0x06,
|
||||
0x41, 0x79, 0x42, 0x4a, 0x5c, 0x3c, 0xc5, 0x79, 0x89, 0x05, 0xc5, 0x19, 0xf9, 0x25, 0x01, 0x89,
|
||||
0x25, 0x19, 0x12, 0x2c, 0x60, 0xe3, 0x51, 0xc4, 0xa4, 0xa6, 0x33, 0x71, 0xb1, 0xb8, 0x95, 0xe6,
|
||||
0xe4, 0x48, 0xb5, 0x32, 0x72, 0xb1, 0x07, 0xa5, 0x16, 0x96, 0xa6, 0x16, 0x97, 0x0c, 0xa8, 0x83,
|
||||
0xda, 0x18, 0xb9, 0x38, 0x82, 0x52, 0x8b, 0x0b, 0xf2, 0xf3, 0x8a, 0x07, 0x34, 0x64, 0x9c, 0x14,
|
||||
0x4e, 0x3c, 0x92, 0x63, 0xbc, 0xf0, 0x48, 0x8e, 0xf1, 0xc1, 0x23, 0x39, 0xc6, 0x09, 0x8f, 0xe5,
|
||||
0x18, 0x2e, 0x3c, 0x96, 0x63, 0xb8, 0xf1, 0x58, 0x8e, 0x21, 0x8a, 0x0d, 0x92, 0x38, 0x92, 0xd8,
|
||||
0xc0, 0xd1, 0x6a, 0x0c, 0x08, 0x00, 0x00, 0xff, 0xff, 0x90, 0x29, 0xbc, 0x62, 0x3a, 0x02, 0x00,
|
||||
0x00,
|
||||
}
|
||||
|
||||
func (m *Sync) Marshal() (dAtA []byte, err error) {
|
||||
@ -407,6 +377,15 @@ func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SnapshotPath[iNdEx])
|
||||
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.TreeId) > 0 {
|
||||
i -= len(m.TreeId)
|
||||
copy(dAtA[i:], m.TreeId)
|
||||
@ -430,14 +409,9 @@ func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
}
|
||||
if len(m.Heads) > 0 {
|
||||
for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Heads[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSync(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= len(m.Heads[iNdEx])
|
||||
copy(dAtA[i:], m.Heads[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
@ -445,45 +419,6 @@ func (m *SyncHeadUpdate) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SyncHead) 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 *SyncHead) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *SyncHead) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SnapshotPath[iNdEx])
|
||||
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
}
|
||||
if len(m.Id) > 0 {
|
||||
i -= len(m.Id)
|
||||
copy(dAtA[i:], m.Id)
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.Id)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *SyncFull) Marshal() (dAtA []byte, err error) {
|
||||
size := m.Size()
|
||||
dAtA = make([]byte, size)
|
||||
@ -527,6 +462,15 @@ func (m *SyncFullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SnapshotPath[iNdEx])
|
||||
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.TreeId) > 0 {
|
||||
i -= len(m.TreeId)
|
||||
copy(dAtA[i:], m.TreeId)
|
||||
@ -550,14 +494,9 @@ func (m *SyncFullRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
}
|
||||
if len(m.Heads) > 0 {
|
||||
for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Heads[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSync(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= len(m.Heads[iNdEx])
|
||||
copy(dAtA[i:], m.Heads[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
@ -585,6 +524,15 @@ func (m *SyncFullResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for iNdEx := len(m.SnapshotPath) - 1; iNdEx >= 0; iNdEx-- {
|
||||
i -= len(m.SnapshotPath[iNdEx])
|
||||
copy(dAtA[i:], m.SnapshotPath[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.SnapshotPath[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0x22
|
||||
}
|
||||
}
|
||||
if len(m.TreeId) > 0 {
|
||||
i -= len(m.TreeId)
|
||||
copy(dAtA[i:], m.TreeId)
|
||||
@ -608,14 +556,9 @@ func (m *SyncFullResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
}
|
||||
if len(m.Heads) > 0 {
|
||||
for iNdEx := len(m.Heads) - 1; iNdEx >= 0; iNdEx-- {
|
||||
{
|
||||
size, err := m.Heads[iNdEx].MarshalToSizedBuffer(dAtA[:i])
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
i -= size
|
||||
i = encodeVarintSync(dAtA, i, uint64(size))
|
||||
}
|
||||
i -= len(m.Heads[iNdEx])
|
||||
copy(dAtA[i:], m.Heads[iNdEx])
|
||||
i = encodeVarintSync(dAtA, i, uint64(len(m.Heads[iNdEx])))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
@ -650,8 +593,8 @@ func (m *SyncHeadUpdate) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Heads) > 0 {
|
||||
for _, e := range m.Heads {
|
||||
l = e.Size()
|
||||
for _, s := range m.Heads {
|
||||
l = len(s)
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
}
|
||||
@ -665,19 +608,6 @@ func (m *SyncHeadUpdate) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *SyncHead) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.Id)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for _, s := range m.SnapshotPath {
|
||||
l = len(s)
|
||||
@ -703,8 +633,8 @@ func (m *SyncFullRequest) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Heads) > 0 {
|
||||
for _, e := range m.Heads {
|
||||
l = e.Size()
|
||||
for _, s := range m.Heads {
|
||||
l = len(s)
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
}
|
||||
@ -718,6 +648,12 @@ func (m *SyncFullRequest) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for _, s := range m.SnapshotPath {
|
||||
l = len(s)
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@ -728,8 +664,8 @@ func (m *SyncFullResponse) Size() (n int) {
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.Heads) > 0 {
|
||||
for _, e := range m.Heads {
|
||||
l = e.Size()
|
||||
for _, s := range m.Heads {
|
||||
l = len(s)
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
}
|
||||
@ -743,6 +679,12 @@ func (m *SyncFullResponse) Size() (n int) {
|
||||
if l > 0 {
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
if len(m.SnapshotPath) > 0 {
|
||||
for _, s := range m.SnapshotPath {
|
||||
l = len(s)
|
||||
n += 1 + l + sovSync(uint64(l))
|
||||
}
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
@ -835,7 +777,7 @@ func (m *SyncHeadUpdate) Unmarshal(dAtA []byte) error {
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType)
|
||||
}
|
||||
var msglen int
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
@ -845,25 +787,23 @@ func (m *SyncHeadUpdate) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Heads = append(m.Heads, &SyncHead{})
|
||||
if err := m.Heads[len(m.Heads)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
@ -931,89 +871,7 @@ func (m *SyncHeadUpdate) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
m.TreeId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSync(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *SyncHead) Unmarshal(dAtA []byte) error {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
for iNdEx < l {
|
||||
preIndex := iNdEx
|
||||
var wire uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
wire |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
fieldNum := int32(wire >> 3)
|
||||
wireType := int(wire & 0x7)
|
||||
if wireType == 4 {
|
||||
return fmt.Errorf("proto: Head: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: Head: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
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 ErrIntOverflowSync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Id = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType)
|
||||
}
|
||||
@ -1149,7 +1007,7 @@ func (m *SyncFullRequest) Unmarshal(dAtA []byte) error {
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType)
|
||||
}
|
||||
var msglen int
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
@ -1159,25 +1017,23 @@ func (m *SyncFullRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Heads = append(m.Heads, &SyncHead{})
|
||||
if err := m.Heads[len(m.Heads)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
@ -1245,6 +1101,38 @@ func (m *SyncFullRequest) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
m.TreeId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.SnapshotPath = append(m.SnapshotPath, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSync(dAtA[iNdEx:])
|
||||
@ -1299,7 +1187,7 @@ func (m *SyncFullResponse) Unmarshal(dAtA []byte) error {
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field Heads", wireType)
|
||||
}
|
||||
var msglen int
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
@ -1309,25 +1197,23 @@ func (m *SyncFullResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
msglen |= int(b&0x7F) << shift
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
if msglen < 0 {
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + msglen
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.Heads = append(m.Heads, &SyncHead{})
|
||||
if err := m.Heads[len(m.Heads)-1].Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
|
||||
return err
|
||||
}
|
||||
m.Heads = append(m.Heads, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
@ -1395,6 +1281,38 @@ func (m *SyncFullResponse) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
m.TreeId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 4:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field SnapshotPath", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowSync
|
||||
}
|
||||
if iNdEx >= l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
b := dAtA[iNdEx]
|
||||
iNdEx++
|
||||
stringLen |= uint64(b&0x7F) << shift
|
||||
if b < 0x80 {
|
||||
break
|
||||
}
|
||||
}
|
||||
intStringLen := int(stringLen)
|
||||
if intStringLen < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthSync
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.SnapshotPath = append(m.SnapshotPath, string(dAtA[iNdEx:postIndex]))
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipSync(dAtA[iNdEx:])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user