From 247a5615b19e16effc4c4bd594b8f40e5bf31081 Mon Sep 17 00:00:00 2001 From: yihuang Date: Tue, 1 Mar 2022 00:47:43 +0800 Subject: [PATCH] fix: rootmulti's Restore don't return the next unknown item as expected (#11286) ## Description Solution: - return the next unknown item and add a unit test to ensure that. --- ### Author Checklist *All items are required. Please add a note to the item if the item is not applicable and please add links to any relevant follow up issues.* I have... - [ ] included the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] added `!` to the type prefix if API or client breaking change - [ ] targeted the correct branch (see [PR Targeting](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#pr-targeting)) - [ ] provided a link to the relevant issue or specification - [ ] followed the guidelines for [building modules](https://github.com/cosmos/cosmos-sdk/blob/master/docs/building-modules) - [ ] included the necessary unit and integration [tests](https://github.com/cosmos/cosmos-sdk/blob/master/CONTRIBUTING.md#testing) - [ ] added a changelog entry to `CHANGELOG.md` - [ ] included comments for [documenting Go code](https://blog.golang.org/godoc) - [ ] updated the relevant documentation or specification - [ ] reviewed "Files changed" and left comments if necessary - [ ] confirmed all CI checks have passed ### Reviewers Checklist *All items are required. Please add a note if the item is not applicable and please add your handle next to the items reviewed if you only reviewed selected items.* I have... - [ ] confirmed the correct [type prefix](https://github.com/commitizen/conventional-commit-types/blob/v3.0.0/index.json) in the PR title - [ ] confirmed `!` in the type prefix if API or client breaking change - [ ] confirmed all author checklist items have been addressed - [ ] reviewed state machine logic - [ ] reviewed API design and naming - [ ] reviewed documentation is accurate - [ ] reviewed tests and test coverage - [ ] manually tested (if applicable) --- store/rootmulti/snapshot_test.go | 14 +- store/rootmulti/store.go | 11 +- store/types/snapshot.pb.go | 1490 ------------------------------ 3 files changed, 19 insertions(+), 1496 deletions(-) delete mode 100644 store/types/snapshot.pb.go diff --git a/store/rootmulti/snapshot_test.go b/store/rootmulti/snapshot_test.go index fe80d9584df1..cbdb481a05f7 100644 --- a/store/rootmulti/snapshot_test.go +++ b/store/rootmulti/snapshot_test.go @@ -182,6 +182,14 @@ func TestMultistoreSnapshotRestore(t *testing.T) { target := newMultiStoreWithMixedMounts(dbm.NewMemDB()) version := uint64(source.LastCommitID().Version) require.EqualValues(t, 3, version) + dummyExtensionItem := snapshottypes.SnapshotItem{ + Item: &snapshottypes.SnapshotItem_Extension{ + Extension: &snapshottypes.SnapshotExtensionMeta{ + Name: "test", + Format: 1, + }, + }, + } chunks := make(chan io.ReadCloser, 100) go func() { @@ -190,12 +198,16 @@ func TestMultistoreSnapshotRestore(t *testing.T) { defer streamWriter.Close() err := source.Snapshot(version, streamWriter) require.NoError(t, err) + // write an extension metadata + err = streamWriter.WriteMsg(&dummyExtensionItem) + require.NoError(t, err) }() streamReader, err := snapshots.NewStreamReader(chunks) require.NoError(t, err) - _, err = target.Restore(version, snapshottypes.CurrentFormat, streamReader) + nextItem, err := target.Restore(version, snapshottypes.CurrentFormat, streamReader) require.NoError(t, err) + require.Equal(t, *dummyExtensionItem.GetExtension(), *nextItem.GetExtension()) assert.Equal(t, source.LastCommitID(), target.LastCommitID()) for key, sourceStore := range source.GetStores() { diff --git a/store/rootmulti/store.go b/store/rootmulti/store.go index 676708dda37f..53cb6853cc23 100644 --- a/store/rootmulti/store.go +++ b/store/rootmulti/store.go @@ -742,9 +742,11 @@ func (rs *Store) Restore( // a SnapshotStoreItem, telling us which store to import into. The following items will contain // SnapshotNodeItem (i.e. ExportNode) until we reach the next SnapshotStoreItem or EOF. var importer *iavltree.Importer + var snapshotItem snapshottypes.SnapshotItem +loop: for { - snapshotItem := &snapshottypes.SnapshotItem{} - err := protoReader.ReadMsg(snapshotItem) + snapshotItem = snapshottypes.SnapshotItem{} + err := protoReader.ReadMsg(&snapshotItem) if err == io.EOF { break } else if err != nil { @@ -798,8 +800,7 @@ func (rs *Store) Restore( } default: - // pass back the unrecognized item. - return *snapshotItem, nil + break loop } } @@ -812,7 +813,7 @@ func (rs *Store) Restore( } flushMetadata(rs.db, int64(height), rs.buildCommitInfo(int64(height)), []int64{}) - return snapshottypes.SnapshotItem{}, rs.LoadLatestVersion() + return snapshotItem, rs.LoadLatestVersion() } func (rs *Store) loadCommitStoreFromParams(key types.StoreKey, id types.CommitID, params storeParams) (types.CommitKVStore, error) { diff --git a/store/types/snapshot.pb.go b/store/types/snapshot.pb.go deleted file mode 100644 index f0b7da06dbbd..000000000000 --- a/store/types/snapshot.pb.go +++ /dev/null @@ -1,1490 +0,0 @@ -// Code generated by protoc-gen-gogo. DO NOT EDIT. -// source: cosmos/base/store/v1beta1/snapshot.proto - -package types - -import ( - fmt "fmt" - _ "github.com/gogo/protobuf/gogoproto" - 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 - -// SnapshotItem is an item contained in a rootmulti.Store snapshot. -type SnapshotItem struct { - // item is the specific type of snapshot item. - // - // Types that are valid to be assigned to Item: - // *SnapshotItem_Store - // *SnapshotItem_IAVL - // *SnapshotItem_Extension - // *SnapshotItem_ExtensionPayload - Item isSnapshotItem_Item `protobuf_oneof:"item"` -} - -func (m *SnapshotItem) Reset() { *m = SnapshotItem{} } -func (m *SnapshotItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotItem) ProtoMessage() {} -func (*SnapshotItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{0} -} -func (m *SnapshotItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotItem.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 *SnapshotItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotItem.Merge(m, src) -} -func (m *SnapshotItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotItem proto.InternalMessageInfo - -type isSnapshotItem_Item interface { - isSnapshotItem_Item() - MarshalTo([]byte) (int, error) - Size() int -} - -type SnapshotItem_Store struct { - Store *SnapshotStoreItem `protobuf:"bytes,1,opt,name=store,proto3,oneof" json:"store,omitempty"` -} -type SnapshotItem_IAVL struct { - IAVL *SnapshotIAVLItem `protobuf:"bytes,2,opt,name=iavl,proto3,oneof" json:"iavl,omitempty"` -} -type SnapshotItem_Extension struct { - Extension *SnapshotExtensionMeta `protobuf:"bytes,3,opt,name=extension,proto3,oneof" json:"extension,omitempty"` -} -type SnapshotItem_ExtensionPayload struct { - ExtensionPayload *SnapshotExtensionPayload `protobuf:"bytes,4,opt,name=extension_payload,json=extensionPayload,proto3,oneof" json:"extension_payload,omitempty"` -} - -func (*SnapshotItem_Store) isSnapshotItem_Item() {} -func (*SnapshotItem_IAVL) isSnapshotItem_Item() {} -func (*SnapshotItem_Extension) isSnapshotItem_Item() {} -func (*SnapshotItem_ExtensionPayload) isSnapshotItem_Item() {} - -func (m *SnapshotItem) GetItem() isSnapshotItem_Item { - if m != nil { - return m.Item - } - return nil -} - -func (m *SnapshotItem) GetStore() *SnapshotStoreItem { - if x, ok := m.GetItem().(*SnapshotItem_Store); ok { - return x.Store - } - return nil -} - -func (m *SnapshotItem) GetIAVL() *SnapshotIAVLItem { - if x, ok := m.GetItem().(*SnapshotItem_IAVL); ok { - return x.IAVL - } - return nil -} - -func (m *SnapshotItem) GetExtension() *SnapshotExtensionMeta { - if x, ok := m.GetItem().(*SnapshotItem_Extension); ok { - return x.Extension - } - return nil -} - -func (m *SnapshotItem) GetExtensionPayload() *SnapshotExtensionPayload { - if x, ok := m.GetItem().(*SnapshotItem_ExtensionPayload); ok { - return x.ExtensionPayload - } - return nil -} - -// XXX_OneofWrappers is for the internal use of the proto package. -func (*SnapshotItem) XXX_OneofWrappers() []interface{} { - return []interface{}{ - (*SnapshotItem_Store)(nil), - (*SnapshotItem_IAVL)(nil), - (*SnapshotItem_Extension)(nil), - (*SnapshotItem_ExtensionPayload)(nil), - } -} - -// SnapshotStoreItem contains metadata about a snapshotted store. -type SnapshotStoreItem struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (m *SnapshotStoreItem) Reset() { *m = SnapshotStoreItem{} } -func (m *SnapshotStoreItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotStoreItem) ProtoMessage() {} -func (*SnapshotStoreItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{1} -} -func (m *SnapshotStoreItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotStoreItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotStoreItem.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 *SnapshotStoreItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotStoreItem.Merge(m, src) -} -func (m *SnapshotStoreItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotStoreItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotStoreItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotStoreItem proto.InternalMessageInfo - -func (m *SnapshotStoreItem) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -// SnapshotIAVLItem is an exported IAVL node. -type SnapshotIAVLItem struct { - Key []byte `protobuf:"bytes,1,opt,name=key,proto3" json:"key,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` - Version int64 `protobuf:"varint,3,opt,name=version,proto3" json:"version,omitempty"` - Height int32 `protobuf:"varint,4,opt,name=height,proto3" json:"height,omitempty"` -} - -func (m *SnapshotIAVLItem) Reset() { *m = SnapshotIAVLItem{} } -func (m *SnapshotIAVLItem) String() string { return proto.CompactTextString(m) } -func (*SnapshotIAVLItem) ProtoMessage() {} -func (*SnapshotIAVLItem) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{2} -} -func (m *SnapshotIAVLItem) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotIAVLItem) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotIAVLItem.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 *SnapshotIAVLItem) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotIAVLItem.Merge(m, src) -} -func (m *SnapshotIAVLItem) XXX_Size() int { - return m.Size() -} -func (m *SnapshotIAVLItem) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotIAVLItem.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotIAVLItem proto.InternalMessageInfo - -func (m *SnapshotIAVLItem) GetKey() []byte { - if m != nil { - return m.Key - } - return nil -} - -func (m *SnapshotIAVLItem) GetValue() []byte { - if m != nil { - return m.Value - } - return nil -} - -func (m *SnapshotIAVLItem) GetVersion() int64 { - if m != nil { - return m.Version - } - return 0 -} - -func (m *SnapshotIAVLItem) GetHeight() int32 { - if m != nil { - return m.Height - } - return 0 -} - -// SnapshotExtensionMeta contains metadata about an external snapshotter. -type SnapshotExtensionMeta struct { - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` - Format int32 `protobuf:"varint,2,opt,name=format,proto3" json:"format,omitempty"` -} - -func (m *SnapshotExtensionMeta) Reset() { *m = SnapshotExtensionMeta{} } -func (m *SnapshotExtensionMeta) String() string { return proto.CompactTextString(m) } -func (*SnapshotExtensionMeta) ProtoMessage() {} -func (*SnapshotExtensionMeta) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{3} -} -func (m *SnapshotExtensionMeta) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotExtensionMeta) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotExtensionMeta.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 *SnapshotExtensionMeta) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotExtensionMeta.Merge(m, src) -} -func (m *SnapshotExtensionMeta) XXX_Size() int { - return m.Size() -} -func (m *SnapshotExtensionMeta) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotExtensionMeta.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotExtensionMeta proto.InternalMessageInfo - -func (m *SnapshotExtensionMeta) GetName() string { - if m != nil { - return m.Name - } - return "" -} - -func (m *SnapshotExtensionMeta) GetFormat() int32 { - if m != nil { - return m.Format - } - return 0 -} - -// SnapshotExtensionPayload contains payloads of an external snapshotter. -type SnapshotExtensionPayload struct { - Payload []byte `protobuf:"bytes,1,opt,name=payload,proto3" json:"payload,omitempty"` -} - -func (m *SnapshotExtensionPayload) Reset() { *m = SnapshotExtensionPayload{} } -func (m *SnapshotExtensionPayload) String() string { return proto.CompactTextString(m) } -func (*SnapshotExtensionPayload) ProtoMessage() {} -func (*SnapshotExtensionPayload) Descriptor() ([]byte, []int) { - return fileDescriptor_9c55879db4cc4502, []int{4} -} -func (m *SnapshotExtensionPayload) XXX_Unmarshal(b []byte) error { - return m.Unmarshal(b) -} -func (m *SnapshotExtensionPayload) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { - if deterministic { - return xxx_messageInfo_SnapshotExtensionPayload.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 *SnapshotExtensionPayload) XXX_Merge(src proto.Message) { - xxx_messageInfo_SnapshotExtensionPayload.Merge(m, src) -} -func (m *SnapshotExtensionPayload) XXX_Size() int { - return m.Size() -} -func (m *SnapshotExtensionPayload) XXX_DiscardUnknown() { - xxx_messageInfo_SnapshotExtensionPayload.DiscardUnknown(m) -} - -var xxx_messageInfo_SnapshotExtensionPayload proto.InternalMessageInfo - -func (m *SnapshotExtensionPayload) GetPayload() []byte { - if m != nil { - return m.Payload - } - return nil -} - -func init() { - proto.RegisterType((*SnapshotItem)(nil), "cosmos.base.store.v1beta1.SnapshotItem") - proto.RegisterType((*SnapshotStoreItem)(nil), "cosmos.base.store.v1beta1.SnapshotStoreItem") - proto.RegisterType((*SnapshotIAVLItem)(nil), "cosmos.base.store.v1beta1.SnapshotIAVLItem") - proto.RegisterType((*SnapshotExtensionMeta)(nil), "cosmos.base.store.v1beta1.SnapshotExtensionMeta") - proto.RegisterType((*SnapshotExtensionPayload)(nil), "cosmos.base.store.v1beta1.SnapshotExtensionPayload") -} - -func init() { - proto.RegisterFile("cosmos/base/store/v1beta1/snapshot.proto", fileDescriptor_9c55879db4cc4502) -} - -var fileDescriptor_9c55879db4cc4502 = []byte{ - // 409 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x92, 0xc1, 0xae, 0x93, 0x40, - 0x14, 0x86, 0xe1, 0x16, 0xaa, 0xf7, 0xd8, 0x45, 0xef, 0xe4, 0x6a, 0xd0, 0x05, 0x1a, 0x36, 0x36, - 0x51, 0xc1, 0xeb, 0xf5, 0x05, 0x44, 0x4d, 0xb8, 0x51, 0x93, 0x66, 0x9a, 0xb8, 0x70, 0x63, 0x86, - 0x76, 0x04, 0x52, 0x60, 0x08, 0x33, 0x25, 0xf6, 0x2d, 0x7c, 0x2c, 0x97, 0x5d, 0xba, 0x52, 0x43, - 0x5f, 0xc4, 0xcc, 0x0c, 0xd4, 0xa4, 0xb6, 0x49, 0x5d, 0xf5, 0xfc, 0x93, 0xff, 0xff, 0x7a, 0xf8, - 0x73, 0x60, 0x32, 0x67, 0xbc, 0x60, 0x3c, 0x88, 0x09, 0xa7, 0x01, 0x17, 0xac, 0xa6, 0x41, 0x73, - 0x15, 0x53, 0x41, 0xae, 0x02, 0x5e, 0x92, 0x8a, 0xa7, 0x4c, 0xf8, 0x55, 0xcd, 0x04, 0x43, 0xf7, - 0xb5, 0xd3, 0x97, 0x4e, 0x5f, 0x39, 0xfd, 0xce, 0xf9, 0xe0, 0x32, 0x61, 0x09, 0x53, 0xae, 0x40, - 0x4e, 0x3a, 0xe0, 0xfd, 0x3a, 0x83, 0xd1, 0xac, 0x63, 0xdc, 0x08, 0x5a, 0xa0, 0x37, 0x60, 0xab, - 0x9c, 0x63, 0x3e, 0x32, 0x27, 0x77, 0x5e, 0x3c, 0xf5, 0x8f, 0x12, 0xfd, 0x3e, 0x37, 0x93, 0xaf, - 0x32, 0x1c, 0x19, 0x58, 0x87, 0xd1, 0x3b, 0xb0, 0x32, 0xd2, 0xe4, 0xce, 0x99, 0x82, 0x3c, 0x39, - 0x01, 0x72, 0xf3, 0xea, 0xe3, 0x7b, 0xc9, 0x08, 0x6f, 0xb7, 0x3f, 0x1f, 0x5a, 0x52, 0x45, 0x06, - 0x56, 0x10, 0x34, 0x85, 0x73, 0xfa, 0x55, 0xd0, 0x92, 0x67, 0xac, 0x74, 0x06, 0x8a, 0xf8, 0xfc, - 0x04, 0xe2, 0xdb, 0x3e, 0xf3, 0x81, 0x0a, 0x12, 0x19, 0xf8, 0x2f, 0x04, 0xc5, 0x70, 0xb1, 0x13, - 0x9f, 0x2b, 0xb2, 0xce, 0x19, 0x59, 0x38, 0x96, 0x22, 0x5f, 0xff, 0x0f, 0x79, 0xaa, 0xa3, 0x91, - 0x81, 0xc7, 0x74, 0xef, 0x2d, 0x1c, 0x82, 0x95, 0x09, 0x5a, 0x78, 0x8f, 0xe1, 0xe2, 0x9f, 0xa2, - 0x10, 0x02, 0xab, 0x24, 0x85, 0x2e, 0xf9, 0x1c, 0xab, 0xd9, 0xcb, 0x61, 0xbc, 0x5f, 0x06, 0x1a, - 0xc3, 0x60, 0x49, 0xd7, 0xca, 0x36, 0xc2, 0x72, 0x44, 0x97, 0x60, 0x37, 0x24, 0x5f, 0x51, 0x55, - 0xed, 0x08, 0x6b, 0x81, 0x1c, 0xb8, 0xd5, 0xd0, 0x7a, 0x57, 0xd0, 0x00, 0xf7, 0x12, 0xdd, 0x83, - 0x61, 0x4a, 0xb3, 0x24, 0x15, 0xea, 0xfb, 0x6c, 0xdc, 0x29, 0xef, 0x35, 0xdc, 0x3d, 0x58, 0xd4, - 0xa1, 0xd5, 0x24, 0xe4, 0x0b, 0xab, 0x0b, 0x22, 0xd4, 0xbf, 0xda, 0xb8, 0x53, 0xde, 0x4b, 0x70, - 0x8e, 0x75, 0x22, 0x57, 0xea, 0x9b, 0xd5, 0xeb, 0xf7, 0x32, 0x0c, 0xbf, 0xb7, 0xae, 0xb9, 0x69, - 0x5d, 0xf3, 0x77, 0xeb, 0x9a, 0xdf, 0xb6, 0xae, 0xb1, 0xd9, 0xba, 0xc6, 0x8f, 0xad, 0x6b, 0x7c, - 0x9a, 0x24, 0x99, 0x48, 0x57, 0xb1, 0x3f, 0x67, 0x45, 0xd0, 0xdd, 0xbc, 0xfe, 0x79, 0xc6, 0x17, - 0xcb, 0xee, 0xf2, 0xc5, 0xba, 0xa2, 0x3c, 0x1e, 0xaa, 0xf3, 0xbd, 0xfe, 0x13, 0x00, 0x00, 0xff, - 0xff, 0x21, 0xfd, 0xa5, 0x3f, 0x1b, 0x03, 0x00, 0x00, -} - -func (m *SnapshotItem) 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 *SnapshotItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Item != nil { - { - size := m.Item.Size() - i -= size - if _, err := m.Item.MarshalTo(dAtA[i:]); err != nil { - return 0, err - } - } - } - return len(dAtA) - i, nil -} - -func (m *SnapshotItem_Store) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_Store) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Store != nil { - { - size, err := m.Store.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} -func (m *SnapshotItem_IAVL) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_IAVL) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.IAVL != nil { - { - size, err := m.IAVL.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x12 - } - return len(dAtA) - i, nil -} -func (m *SnapshotItem_Extension) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_Extension) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.Extension != nil { - { - size, err := m.Extension.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x1a - } - return len(dAtA) - i, nil -} -func (m *SnapshotItem_ExtensionPayload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotItem_ExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - if m.ExtensionPayload != nil { - { - size, err := m.ExtensionPayload.MarshalToSizedBuffer(dAtA[:i]) - if err != nil { - return 0, err - } - i -= size - i = encodeVarintSnapshot(dAtA, i, uint64(size)) - } - i-- - dAtA[i] = 0x22 - } - return len(dAtA) - i, nil -} -func (m *SnapshotStoreItem) 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 *SnapshotStoreItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotStoreItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SnapshotIAVLItem) 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 *SnapshotIAVLItem) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotIAVLItem) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Height != 0 { - i = encodeVarintSnapshot(dAtA, i, uint64(m.Height)) - i-- - dAtA[i] = 0x20 - } - if m.Version != 0 { - i = encodeVarintSnapshot(dAtA, i, uint64(m.Version)) - i-- - dAtA[i] = 0x18 - } - if len(m.Value) > 0 { - i -= len(m.Value) - copy(dAtA[i:], m.Value) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Value))) - i-- - dAtA[i] = 0x12 - } - if len(m.Key) > 0 { - i -= len(m.Key) - copy(dAtA[i:], m.Key) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Key))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SnapshotExtensionMeta) 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 *SnapshotExtensionMeta) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotExtensionMeta) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if m.Format != 0 { - i = encodeVarintSnapshot(dAtA, i, uint64(m.Format)) - i-- - dAtA[i] = 0x10 - } - if len(m.Name) > 0 { - i -= len(m.Name) - copy(dAtA[i:], m.Name) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Name))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func (m *SnapshotExtensionPayload) 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 *SnapshotExtensionPayload) MarshalTo(dAtA []byte) (int, error) { - size := m.Size() - return m.MarshalToSizedBuffer(dAtA[:size]) -} - -func (m *SnapshotExtensionPayload) MarshalToSizedBuffer(dAtA []byte) (int, error) { - i := len(dAtA) - _ = i - var l int - _ = l - if len(m.Payload) > 0 { - i -= len(m.Payload) - copy(dAtA[i:], m.Payload) - i = encodeVarintSnapshot(dAtA, i, uint64(len(m.Payload))) - i-- - dAtA[i] = 0xa - } - return len(dAtA) - i, nil -} - -func encodeVarintSnapshot(dAtA []byte, offset int, v uint64) int { - offset -= sovSnapshot(v) - base := offset - for v >= 1<<7 { - dAtA[offset] = uint8(v&0x7f | 0x80) - v >>= 7 - offset++ - } - dAtA[offset] = uint8(v) - return base -} -func (m *SnapshotItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Item != nil { - n += m.Item.Size() - } - return n -} - -func (m *SnapshotItem_Store) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Store != nil { - l = m.Store.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotItem_IAVL) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.IAVL != nil { - l = m.IAVL.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotItem_Extension) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.Extension != nil { - l = m.Extension.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotItem_ExtensionPayload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - if m.ExtensionPayload != nil { - l = m.ExtensionPayload.Size() - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} -func (m *SnapshotStoreItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} - -func (m *SnapshotIAVLItem) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Key) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - l = len(m.Value) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - if m.Version != 0 { - n += 1 + sovSnapshot(uint64(m.Version)) - } - if m.Height != 0 { - n += 1 + sovSnapshot(uint64(m.Height)) - } - return n -} - -func (m *SnapshotExtensionMeta) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Name) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - if m.Format != 0 { - n += 1 + sovSnapshot(uint64(m.Format)) - } - return n -} - -func (m *SnapshotExtensionPayload) Size() (n int) { - if m == nil { - return 0 - } - var l int - _ = l - l = len(m.Payload) - if l > 0 { - n += 1 + l + sovSnapshot(uint64(l)) - } - return n -} - -func sovSnapshot(x uint64) (n int) { - return (math_bits.Len64(x|1) + 6) / 7 -} -func sozSnapshot(x uint64) (n int) { - return sovSnapshot(uint64((x << 1) ^ uint64((int64(x) >> 63)))) -} -func (m *SnapshotItem) 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 ErrIntOverflowSnapshot - } - 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: SnapshotItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Store", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotStoreItem{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_Store{v} - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field IAVL", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotIAVLItem{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_IAVL{v} - iNdEx = postIndex - case 3: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Extension", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotExtensionMeta{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_Extension{v} - iNdEx = postIndex - case 4: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field ExtensionPayload", wireType) - } - var msglen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - msglen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if msglen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + msglen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - v := &SnapshotExtensionPayload{} - if err := v.Unmarshal(dAtA[iNdEx:postIndex]); err != nil { - return err - } - m.Item = &SnapshotItem_ExtensionPayload{v} - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotStoreItem) 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 ErrIntOverflowSnapshot - } - 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: SnapshotStoreItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotStoreItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotIAVLItem) 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 ErrIntOverflowSnapshot - } - 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: SnapshotIAVLItem: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotIAVLItem: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Key", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Key = append(m.Key[:0], dAtA[iNdEx:postIndex]...) - if m.Key == nil { - m.Key = []byte{} - } - iNdEx = postIndex - case 2: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Value", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) - if m.Value == nil { - m.Value = []byte{} - } - iNdEx = postIndex - case 3: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Version", wireType) - } - m.Version = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Version |= int64(b&0x7F) << shift - if b < 0x80 { - break - } - } - case 4: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Height", wireType) - } - m.Height = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Height |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotExtensionMeta) 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 ErrIntOverflowSnapshot - } - 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: SnapshotExtensionMeta: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotExtensionMeta: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Name", wireType) - } - var stringLen uint64 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - 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 ErrInvalidLengthSnapshot - } - postIndex := iNdEx + intStringLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Name = string(dAtA[iNdEx:postIndex]) - iNdEx = postIndex - case 2: - if wireType != 0 { - return fmt.Errorf("proto: wrong wireType = %d for field Format", wireType) - } - m.Format = 0 - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - m.Format |= int32(b&0x7F) << shift - if b < 0x80 { - break - } - } - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func (m *SnapshotExtensionPayload) 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 ErrIntOverflowSnapshot - } - 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: SnapshotExtensionPayload: wiretype end group for non-group") - } - if fieldNum <= 0 { - return fmt.Errorf("proto: SnapshotExtensionPayload: illegal tag %d (wire type %d)", fieldNum, wire) - } - switch fieldNum { - case 1: - if wireType != 2 { - return fmt.Errorf("proto: wrong wireType = %d for field Payload", wireType) - } - var byteLen int - for shift := uint(0); ; shift += 7 { - if shift >= 64 { - return ErrIntOverflowSnapshot - } - if iNdEx >= l { - return io.ErrUnexpectedEOF - } - b := dAtA[iNdEx] - iNdEx++ - byteLen |= int(b&0x7F) << shift - if b < 0x80 { - break - } - } - if byteLen < 0 { - return ErrInvalidLengthSnapshot - } - postIndex := iNdEx + byteLen - if postIndex < 0 { - return ErrInvalidLengthSnapshot - } - if postIndex > l { - return io.ErrUnexpectedEOF - } - m.Payload = append(m.Payload[:0], dAtA[iNdEx:postIndex]...) - if m.Payload == nil { - m.Payload = []byte{} - } - iNdEx = postIndex - default: - iNdEx = preIndex - skippy, err := skipSnapshot(dAtA[iNdEx:]) - if err != nil { - return err - } - if (skippy < 0) || (iNdEx+skippy) < 0 { - return ErrInvalidLengthSnapshot - } - if (iNdEx + skippy) > l { - return io.ErrUnexpectedEOF - } - iNdEx += skippy - } - } - - if iNdEx > l { - return io.ErrUnexpectedEOF - } - return nil -} -func skipSnapshot(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, ErrIntOverflowSnapshot - } - 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, ErrIntOverflowSnapshot - } - 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, ErrIntOverflowSnapshot - } - 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, ErrInvalidLengthSnapshot - } - iNdEx += length - case 3: - depth++ - case 4: - if depth == 0 { - return 0, ErrUnexpectedEndOfGroupSnapshot - } - depth-- - case 5: - iNdEx += 4 - default: - return 0, fmt.Errorf("proto: illegal wireType %d", wireType) - } - if iNdEx < 0 { - return 0, ErrInvalidLengthSnapshot - } - if depth == 0 { - return iNdEx, nil - } - } - return 0, io.ErrUnexpectedEOF -} - -var ( - ErrInvalidLengthSnapshot = fmt.Errorf("proto: negative length found during unmarshaling") - ErrIntOverflowSnapshot = fmt.Errorf("proto: integer overflow") - ErrUnexpectedEndOfGroupSnapshot = fmt.Errorf("proto: unexpected end of group") -)