diff --git a/CHANGELOG.md b/CHANGELOG.md index fabcec35d..d71f09c69 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,14 @@ # Changelog + +## Unreleased + +### Breaking Changes +- [\#355](https://github.com/cosmos/iavl/pull/355) `Get` in `iavlServer` no longer returns an error if the requested key does not exist. `GetResponse` now contains a `NotFound` boolean to indicate that a key does not exist, and the returned index will be that of the next occupied key. + +### Improvements +- [\#355](https://github.com/cosmos/iavl/pull/355) Add support for `GetByIndex` to `iavlServer` + ## 0.15.3 (December 21, 2020) Special thanks to external contributors on this release: @odeke-em diff --git a/proto/iavl/iavl_api.proto b/proto/iavl/iavl_api.proto index d08100d38..39e69f342 100644 --- a/proto/iavl/iavl_api.proto +++ b/proto/iavl/iavl_api.proto @@ -27,14 +27,23 @@ service IAVLService { }; } - // Get returns a result containing the IAVL tree version and value for a given + // Get returns a result containing the index and value for a given // key based on the current state (version) of the tree. + // If the key does not exist, Get returns the index of the next value. rpc Get(GetRequest) returns (GetResponse) { option (google.api.http) = { get: "/v1/get" }; } + // GetByIndex returns a result containing the key and value for a given + // index based on the current state (version) of the tree. + rpc GetByIndex(GetByIndexRequest) returns (GetByIndexResponse) { + option (google.api.http) = { + get: "/v1/getbyindex" + }; + } + // GetWithProof returns a result containing the IAVL tree version and value for // a given key based on the current state (version) of the tree including a // verifiable Merkle proof. @@ -217,6 +226,10 @@ message GetRequest { bytes key = 1; } +message GetByIndexRequest { + int64 index = 1; +} + message GetVersionedRequest { int64 version = 1; bytes key = 2; @@ -283,6 +296,12 @@ message HasResponse { message GetResponse { int64 index = 1; bytes value = 2; + bool not_found = 3; +} + +message GetByIndexResponse { + bytes key = 1; + bytes value = 2; } message SetResponse { diff --git a/proto/iavl_api.pb.go b/proto/iavl_api.pb.go index 2efdb9d5e..145eff504 100644 --- a/proto/iavl_api.pb.go +++ b/proto/iavl_api.pb.go @@ -168,6 +168,50 @@ func (m *GetRequest) GetKey() []byte { return nil } +type GetByIndexRequest struct { + Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` +} + +func (m *GetByIndexRequest) Reset() { *m = GetByIndexRequest{} } +func (m *GetByIndexRequest) String() string { return proto.CompactTextString(m) } +func (*GetByIndexRequest) ProtoMessage() {} +func (*GetByIndexRequest) Descriptor() ([]byte, []int) { + return fileDescriptor_5cad6b4fafc2c047, []int{3} +} +func (m *GetByIndexRequest) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetByIndexRequest) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetByIndexRequest.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 *GetByIndexRequest) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetByIndexRequest.Merge(m, src) +} +func (m *GetByIndexRequest) XXX_Size() int { + return m.Size() +} +func (m *GetByIndexRequest) XXX_DiscardUnknown() { + xxx_messageInfo_GetByIndexRequest.DiscardUnknown(m) +} + +var xxx_messageInfo_GetByIndexRequest proto.InternalMessageInfo + +func (m *GetByIndexRequest) GetIndex() int64 { + if m != nil { + return m.Index + } + return 0 +} + type GetVersionedRequest struct { Version int64 `protobuf:"varint,1,opt,name=version,proto3" json:"version,omitempty"` Key []byte `protobuf:"bytes,2,opt,name=key,proto3" json:"key,omitempty"` @@ -177,7 +221,7 @@ func (m *GetVersionedRequest) Reset() { *m = GetVersionedRequest{} } func (m *GetVersionedRequest) String() string { return proto.CompactTextString(m) } func (*GetVersionedRequest) ProtoMessage() {} func (*GetVersionedRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{3} + return fileDescriptor_5cad6b4fafc2c047, []int{4} } func (m *GetVersionedRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -229,7 +273,7 @@ func (m *SetRequest) Reset() { *m = SetRequest{} } func (m *SetRequest) String() string { return proto.CompactTextString(m) } func (*SetRequest) ProtoMessage() {} func (*SetRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{4} + return fileDescriptor_5cad6b4fafc2c047, []int{5} } func (m *SetRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -280,7 +324,7 @@ func (m *RemoveRequest) Reset() { *m = RemoveRequest{} } func (m *RemoveRequest) String() string { return proto.CompactTextString(m) } func (*RemoveRequest) ProtoMessage() {} func (*RemoveRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{5} + return fileDescriptor_5cad6b4fafc2c047, []int{6} } func (m *RemoveRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -324,7 +368,7 @@ func (m *DeleteVersionRequest) Reset() { *m = DeleteVersionRequest{} } func (m *DeleteVersionRequest) String() string { return proto.CompactTextString(m) } func (*DeleteVersionRequest) ProtoMessage() {} func (*DeleteVersionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{6} + return fileDescriptor_5cad6b4fafc2c047, []int{7} } func (m *DeleteVersionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -368,7 +412,7 @@ func (m *VersionExistsRequest) Reset() { *m = VersionExistsRequest{} } func (m *VersionExistsRequest) String() string { return proto.CompactTextString(m) } func (*VersionExistsRequest) ProtoMessage() {} func (*VersionExistsRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{7} + return fileDescriptor_5cad6b4fafc2c047, []int{8} } func (m *VersionExistsRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -413,7 +457,7 @@ func (m *VerifyRequest) Reset() { *m = VerifyRequest{} } func (m *VerifyRequest) String() string { return proto.CompactTextString(m) } func (*VerifyRequest) ProtoMessage() {} func (*VerifyRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{8} + return fileDescriptor_5cad6b4fafc2c047, []int{9} } func (m *VerifyRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -467,7 +511,7 @@ func (m *VerifyItemRequest) Reset() { *m = VerifyItemRequest{} } func (m *VerifyItemRequest) String() string { return proto.CompactTextString(m) } func (*VerifyItemRequest) ProtoMessage() {} func (*VerifyItemRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{9} + return fileDescriptor_5cad6b4fafc2c047, []int{10} } func (m *VerifyItemRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -534,7 +578,7 @@ func (m *VerifyAbsenceRequest) Reset() { *m = VerifyAbsenceRequest{} } func (m *VerifyAbsenceRequest) String() string { return proto.CompactTextString(m) } func (*VerifyAbsenceRequest) ProtoMessage() {} func (*VerifyAbsenceRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{10} + return fileDescriptor_5cad6b4fafc2c047, []int{11} } func (m *VerifyAbsenceRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -592,7 +636,7 @@ func (m *LoadVersionRequest) Reset() { *m = LoadVersionRequest{} } func (m *LoadVersionRequest) String() string { return proto.CompactTextString(m) } func (*LoadVersionRequest) ProtoMessage() {} func (*LoadVersionRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{11} + return fileDescriptor_5cad6b4fafc2c047, []int{12} } func (m *LoadVersionRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -636,7 +680,7 @@ func (m *LoadVersionForOverwritingRequest) Reset() { *m = LoadVersionFor func (m *LoadVersionForOverwritingRequest) String() string { return proto.CompactTextString(m) } func (*LoadVersionForOverwritingRequest) ProtoMessage() {} func (*LoadVersionForOverwritingRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{12} + return fileDescriptor_5cad6b4fafc2c047, []int{13} } func (m *LoadVersionForOverwritingRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -682,7 +726,7 @@ func (m *ListRequest) Reset() { *m = ListRequest{} } func (m *ListRequest) String() string { return proto.CompactTextString(m) } func (*ListRequest) ProtoMessage() {} func (*ListRequest) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{13} + return fileDescriptor_5cad6b4fafc2c047, []int{14} } func (m *ListRequest) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -740,7 +784,7 @@ func (m *HasResponse) Reset() { *m = HasResponse{} } func (m *HasResponse) String() string { return proto.CompactTextString(m) } func (*HasResponse) ProtoMessage() {} func (*HasResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{14} + return fileDescriptor_5cad6b4fafc2c047, []int{15} } func (m *HasResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -777,15 +821,16 @@ func (m *HasResponse) GetResult() bool { } type GetResponse struct { - Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` - Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + Index int64 `protobuf:"varint,1,opt,name=index,proto3" json:"index,omitempty"` + Value []byte `protobuf:"bytes,2,opt,name=value,proto3" json:"value,omitempty"` + NotFound bool `protobuf:"varint,3,opt,name=not_found,json=notFound,proto3" json:"not_found,omitempty"` } func (m *GetResponse) Reset() { *m = GetResponse{} } func (m *GetResponse) String() string { return proto.CompactTextString(m) } func (*GetResponse) ProtoMessage() {} func (*GetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{15} + return fileDescriptor_5cad6b4fafc2c047, []int{16} } func (m *GetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -828,6 +873,65 @@ func (m *GetResponse) GetValue() []byte { return nil } +func (m *GetResponse) GetNotFound() bool { + if m != nil { + return m.NotFound + } + return false +} + +type GetByIndexResponse 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"` +} + +func (m *GetByIndexResponse) Reset() { *m = GetByIndexResponse{} } +func (m *GetByIndexResponse) String() string { return proto.CompactTextString(m) } +func (*GetByIndexResponse) ProtoMessage() {} +func (*GetByIndexResponse) Descriptor() ([]byte, []int) { + return fileDescriptor_5cad6b4fafc2c047, []int{17} +} +func (m *GetByIndexResponse) XXX_Unmarshal(b []byte) error { + return m.Unmarshal(b) +} +func (m *GetByIndexResponse) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) { + if deterministic { + return xxx_messageInfo_GetByIndexResponse.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 *GetByIndexResponse) XXX_Merge(src proto.Message) { + xxx_messageInfo_GetByIndexResponse.Merge(m, src) +} +func (m *GetByIndexResponse) XXX_Size() int { + return m.Size() +} +func (m *GetByIndexResponse) XXX_DiscardUnknown() { + xxx_messageInfo_GetByIndexResponse.DiscardUnknown(m) +} + +var xxx_messageInfo_GetByIndexResponse proto.InternalMessageInfo + +func (m *GetByIndexResponse) GetKey() []byte { + if m != nil { + return m.Key + } + return nil +} + +func (m *GetByIndexResponse) GetValue() []byte { + if m != nil { + return m.Value + } + return nil +} + type SetResponse struct { Updated bool `protobuf:"varint,1,opt,name=updated,proto3" json:"updated,omitempty"` } @@ -836,7 +940,7 @@ func (m *SetResponse) Reset() { *m = SetResponse{} } func (m *SetResponse) String() string { return proto.CompactTextString(m) } func (*SetResponse) ProtoMessage() {} func (*SetResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{16} + return fileDescriptor_5cad6b4fafc2c047, []int{18} } func (m *SetResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -881,7 +985,7 @@ func (m *RemoveResponse) Reset() { *m = RemoveResponse{} } func (m *RemoveResponse) String() string { return proto.CompactTextString(m) } func (*RemoveResponse) ProtoMessage() {} func (*RemoveResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{17} + return fileDescriptor_5cad6b4fafc2c047, []int{19} } func (m *RemoveResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -933,7 +1037,7 @@ func (m *SaveVersionResponse) Reset() { *m = SaveVersionResponse{} } func (m *SaveVersionResponse) String() string { return proto.CompactTextString(m) } func (*SaveVersionResponse) ProtoMessage() {} func (*SaveVersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{18} + return fileDescriptor_5cad6b4fafc2c047, []int{20} } func (m *SaveVersionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -985,7 +1089,7 @@ func (m *DeleteVersionResponse) Reset() { *m = DeleteVersionResponse{} } func (m *DeleteVersionResponse) String() string { return proto.CompactTextString(m) } func (*DeleteVersionResponse) ProtoMessage() {} func (*DeleteVersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{19} + return fileDescriptor_5cad6b4fafc2c047, []int{21} } func (m *DeleteVersionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1036,7 +1140,7 @@ func (m *VersionResponse) Reset() { *m = VersionResponse{} } func (m *VersionResponse) String() string { return proto.CompactTextString(m) } func (*VersionResponse) ProtoMessage() {} func (*VersionResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{20} + return fileDescriptor_5cad6b4fafc2c047, []int{22} } func (m *VersionResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1080,7 +1184,7 @@ func (m *HashResponse) Reset() { *m = HashResponse{} } func (m *HashResponse) String() string { return proto.CompactTextString(m) } func (*HashResponse) ProtoMessage() {} func (*HashResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{21} + return fileDescriptor_5cad6b4fafc2c047, []int{23} } func (m *HashResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1124,7 +1228,7 @@ func (m *VersionExistsResponse) Reset() { *m = VersionExistsResponse{} } func (m *VersionExistsResponse) String() string { return proto.CompactTextString(m) } func (*VersionExistsResponse) ProtoMessage() {} func (*VersionExistsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{22} + return fileDescriptor_5cad6b4fafc2c047, []int{24} } func (m *VersionExistsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1169,7 +1273,7 @@ func (m *GetWithProofResponse) Reset() { *m = GetWithProofResponse{} } func (m *GetWithProofResponse) String() string { return proto.CompactTextString(m) } func (*GetWithProofResponse) ProtoMessage() {} func (*GetWithProofResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{23} + return fileDescriptor_5cad6b4fafc2c047, []int{25} } func (m *GetWithProofResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1220,7 +1324,7 @@ func (m *GetAvailableVersionsResponse) Reset() { *m = GetAvailableVersio func (m *GetAvailableVersionsResponse) String() string { return proto.CompactTextString(m) } func (*GetAvailableVersionsResponse) ProtoMessage() {} func (*GetAvailableVersionsResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{24} + return fileDescriptor_5cad6b4fafc2c047, []int{26} } func (m *GetAvailableVersionsResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1264,7 +1368,7 @@ func (m *SizeResponse) Reset() { *m = SizeResponse{} } func (m *SizeResponse) String() string { return proto.CompactTextString(m) } func (*SizeResponse) ProtoMessage() {} func (*SizeResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{25} + return fileDescriptor_5cad6b4fafc2c047, []int{27} } func (m *SizeResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1309,7 +1413,7 @@ func (m *ListResponse) Reset() { *m = ListResponse{} } func (m *ListResponse) String() string { return proto.CompactTextString(m) } func (*ListResponse) ProtoMessage() {} func (*ListResponse) Descriptor() ([]byte, []int) { - return fileDescriptor_5cad6b4fafc2c047, []int{26} + return fileDescriptor_5cad6b4fafc2c047, []int{28} } func (m *ListResponse) XXX_Unmarshal(b []byte) error { return m.Unmarshal(b) @@ -1356,6 +1460,7 @@ func init() { proto.RegisterType((*HasRequest)(nil), "iavl.HasRequest") proto.RegisterType((*HasVersionedRequest)(nil), "iavl.HasVersionedRequest") proto.RegisterType((*GetRequest)(nil), "iavl.GetRequest") + proto.RegisterType((*GetByIndexRequest)(nil), "iavl.GetByIndexRequest") proto.RegisterType((*GetVersionedRequest)(nil), "iavl.GetVersionedRequest") proto.RegisterType((*SetRequest)(nil), "iavl.SetRequest") proto.RegisterType((*RemoveRequest)(nil), "iavl.RemoveRequest") @@ -1369,6 +1474,7 @@ func init() { proto.RegisterType((*ListRequest)(nil), "iavl.ListRequest") proto.RegisterType((*HasResponse)(nil), "iavl.HasResponse") proto.RegisterType((*GetResponse)(nil), "iavl.GetResponse") + proto.RegisterType((*GetByIndexResponse)(nil), "iavl.GetByIndexResponse") proto.RegisterType((*SetResponse)(nil), "iavl.SetResponse") proto.RegisterType((*RemoveResponse)(nil), "iavl.RemoveResponse") proto.RegisterType((*SaveVersionResponse)(nil), "iavl.SaveVersionResponse") @@ -1385,84 +1491,88 @@ func init() { func init() { proto.RegisterFile("iavl/iavl_api.proto", fileDescriptor_5cad6b4fafc2c047) } var fileDescriptor_5cad6b4fafc2c047 = []byte{ - // 1228 bytes of a gzipped FileDescriptorProto - 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x5d, 0x6f, 0x1b, 0x45, - 0x17, 0xc7, 0xeb, 0xda, 0x49, 0xdc, 0x63, 0xe7, 0x89, 0x33, 0xb6, 0x13, 0xc7, 0x69, 0xfd, 0x84, - 0x41, 0x0d, 0x11, 0x91, 0xec, 0x52, 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 0x4a, 0xec, 0x51, 0xf1, 0x52, - 0x12, 0x6f, 0x01, 0x74, 0xa6, 0x48, 0xa0, 0x0a, 0xcc, 0xf9, 0xc4, 0x39, 0xa3, 0xfa, 0x9b, 0x60, - 0x81, 0x5f, 0x81, 0xc5, 0x36, 0x3d, 0x65, 0x3e, 0x4d, 0xb7, 0xed, 0x0e, 0x54, 0x76, 0xa9, 0x43, - 0x05, 0xd5, 0xe6, 0xcd, 0x34, 0x4e, 0x7e, 0xa1, 0xcf, 0x3e, 0x78, 0x66, 0x73, 0xc1, 0x67, 0x7f, - 0xf1, 0x18, 0x16, 0x0f, 0xa9, 0x67, 0xf7, 0xce, 0xc3, 0xa3, 0xeb, 0x70, 0xc3, 0x63, 0x4c, 0x58, - 0x03, 0xc2, 0x07, 0xda, 0x98, 0xbc, 0xdc, 0xd8, 0x27, 0x7c, 0x80, 0x36, 0x61, 0x4e, 0xdd, 0x9f, - 0x72, 0xa5, 0x70, 0xb7, 0xd4, 0x94, 0x57, 0xda, 0x6c, 0x13, 0xb7, 0x4f, 0x3f, 0x93, 0xfb, 0xed, - 0xe0, 0x67, 0xfc, 0x43, 0x06, 0x96, 0x03, 0xec, 0x43, 0x41, 0x4f, 0xff, 0x4d, 0x74, 0x18, 0xa6, - 0x6c, 0x42, 0x7c, 0x73, 0x66, 0x7c, 0x4f, 0x55, 0x28, 0xec, 0xde, 0xf9, 0xce, 0x11, 0xa7, 0xee, - 0x31, 0xfd, 0x6f, 0x8d, 0xc0, 0x4d, 0x40, 0x07, 0x8c, 0x74, 0xaf, 0x7c, 0x53, 0xef, 0xc2, 0x86, - 0x71, 0xfe, 0x43, 0xe6, 0x7d, 0xea, 0x53, 0xef, 0xa9, 0x67, 0x0b, 0xdb, 0xed, 0xcf, 0xfe, 0xda, - 0x82, 0xc2, 0x81, 0xcd, 0x47, 0x39, 0xb7, 0x06, 0xf9, 0x9e, 0xc7, 0x4e, 0xad, 0x28, 0x7f, 0x16, - 0xe4, 0xfa, 0x11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 0x8d, 0x35, 0x5e, 0x31, 0xda, 0x48, 0x8b, 0x06, 0xd0, - 0xcf, 0x61, 0x3e, 0x18, 0x48, 0xc2, 0x74, 0x88, 0xcd, 0x5d, 0xf5, 0x14, 0x17, 0x70, 0x43, 0x21, - 0x6b, 0x68, 0x45, 0x25, 0x84, 0x6c, 0xae, 0x41, 0x7a, 0x4a, 0xbc, 0x84, 0x1d, 0x01, 0x44, 0x93, - 0x16, 0x5a, 0x35, 0xd1, 0xc6, 0xec, 0x95, 0x8a, 0x8f, 0x55, 0xe2, 0x24, 0xde, 0xb2, 0x25, 0xf5, - 0x24, 0x1c, 0x12, 0xf5, 0x2c, 0x65, 0x04, 0x68, 0x62, 0xc0, 0x4a, 0x55, 0xda, 0x54, 0x4a, 0x1b, - 0xa8, 0x91, 0xa2, 0x44, 0x34, 0xbb, 0x03, 0xf9, 0x36, 0x73, 0x9c, 0x23, 0x72, 0x7c, 0x92, 0x7a, - 0xaf, 0x69, 0x1a, 0xab, 0x4a, 0x63, 0x19, 0x17, 0x95, 0x86, 0xa6, 0xc8, 0xbc, 0xf3, 0xd4, 0xcb, - 0x36, 0xf1, 0x06, 0xa5, 0x0a, 0xe0, 0x51, 0x1f, 0x49, 0x7d, 0xb7, 0xe2, 0x37, 0x43, 0xc2, 0x63, - 0x61, 0xb6, 0x73, 0xf4, 0x08, 0x72, 0x72, 0xc4, 0xfb, 0xc7, 0x4e, 0xe8, 0x4c, 0xc7, 0x2a, 0x41, - 0x1d, 0x46, 0xba, 0xd2, 0x81, 0xaf, 0xa0, 0x60, 0xcc, 0x8b, 0xa8, 0x16, 0xd8, 0x37, 0x39, 0x72, - 0xa6, 0x52, 0x63, 0xf5, 0x2f, 0xa9, 0x66, 0x59, 0xfe, 0x94, 0x81, 0xb5, 0xd4, 0x71, 0x14, 0x6d, - 0x4e, 0x88, 0x25, 0xce, 0xab, 0xa9, 0xd2, 0xdb, 0x4a, 0xfa, 0x36, 0xde, 0x18, 0x97, 0xb6, 0x7a, - 0xcc, 0xb3, 0x58, 0x04, 0x92, 0xa6, 0xec, 0x42, 0x4e, 0xbe, 0xf8, 0xb3, 0x4a, 0xda, 0x9c, 0x0a, - 0xe2, 0x25, 0x2d, 0x67, 0x02, 0xb4, 0x03, 0x39, 0x39, 0x13, 0x20, 0xdd, 0xaa, 0x8d, 0x61, 0x39, - 0x04, 0x98, 0x23, 0x43, 0x1c, 0xe0, 0xd8, 0x5c, 0xdc, 0xc9, 0x7c, 0xf0, 0xff, 0xdf, 0x2e, 0x1a, - 0x99, 0x17, 0x17, 0x8d, 0xcc, 0x9f, 0x17, 0x8d, 0xcc, 0xcf, 0x97, 0x8d, 0x6b, 0x2f, 0x2e, 0x1b, - 0xd7, 0xfe, 0xb8, 0x6c, 0x5c, 0xfb, 0x72, 0x2e, 0x30, 0x69, 0x5e, 0xfd, 0xf7, 0xe6, 0xdf, 0x01, - 0x00, 0x00, 0xff, 0xff, 0x4d, 0x93, 0xf4, 0x34, 0x2e, 0x0f, 0x00, 0x00, + // 1292 bytes of a gzipped FileDescriptorProto + 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xb4, 0x96, 0x4f, 0x6f, 0x1b, 0x45, + 0x14, 0xc0, 0xeb, 0xda, 0x89, 0xdd, 0x67, 0xa7, 0x75, 0xc6, 0x71, 0xe2, 0x38, 0xad, 0x09, 0x83, + 0x1a, 0x02, 0x91, 0xec, 0x52, 0x10, 0x87, 0xb6, 0x42, 0xa4, 0x4a, 0xeb, 0x84, 0x86, 0x3f, 0xb2, + 0x4b, 0x82, 0x10, 0x68, 0x35, 0xce, 0x8e, 0xed, 0x55, 0x9c, 0x1d, 0xb3, 0x3b, 0x76, 0xeb, 0x22, + 0x10, 0xe2, 0xc4, 0x11, 0x89, 0x2f, 0xc5, 0xb1, 0x12, 0x17, 0x8e, 0x28, 0xe1, 0x2b, 0x70, 0x47, + 0x33, 0x3b, 0xe3, 0xdd, 0xb5, 0x77, 0xed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x7c, 0x0b, 0x6d, 0x08, 0xf2, 0xf7, 0xca, 0x8b, 0x3f, 0x48, 0x19, 0xbe, 0x4b, 0x7f, 0x84, 0x62, + 0x10, 0xe7, 0x5b, 0x31, 0x43, 0xd6, 0x2c, 0x73, 0xaa, 0x52, 0xe8, 0x36, 0xda, 0x9a, 0x21, 0x34, + 0x68, 0xe2, 0x47, 0x90, 0x6c, 0xfa, 0x21, 0x6d, 0x4e, 0x85, 0x34, 0xd0, 0x17, 0x31, 0x92, 0xec, + 0x1c, 0x96, 0x21, 0x75, 0x29, 0xbf, 0x97, 0x78, 0x17, 0x7d, 0x02, 0x8b, 0x5e, 0x47, 0x44, 0x05, + 0x55, 0x73, 0xc1, 0x19, 0xa5, 0xbc, 0x12, 0xde, 0x54, 0xa0, 0xa2, 0x04, 0xdd, 0xc0, 0x20, 0x40, + 0x5e, 0x67, 0x14, 0xac, 0x6f, 0x21, 0x1b, 0xe8, 0x8d, 0x68, 0xb5, 0xea, 0xcd, 0x91, 0x55, 0x3d, + 0x47, 0x56, 0x1f, 0x89, 0x39, 0xb2, 0xac, 0x3c, 0x13, 0xd1, 0x46, 0xf1, 0x86, 0x04, 0x17, 0x71, + 0x5e, 0x6a, 0x48, 0x86, 0x54, 0x1b, 0x2d, 0xf0, 0x1d, 0x58, 0x0a, 0x35, 0x4b, 0xa4, 0xfc, 0x18, + 0x35, 0x32, 0x95, 0x37, 0x22, 0xbf, 0x29, 0x31, 0xb7, 0xa4, 0x98, 0x35, 0x2c, 0x73, 0xc6, 0x94, + 0x47, 0x82, 0x82, 0x3e, 0x85, 0xf4, 0x3c, 0x1b, 0x8a, 0x1e, 0x7e, 0x12, 0x5c, 0x90, 0xe0, 0x25, + 0x94, 0x15, 0x60, 0x3d, 0x40, 0xee, 0x41, 0x4a, 0xb6, 0xed, 0x38, 0x16, 0x1a, 0xd7, 0xf0, 0xb8, + 0x17, 0xe3, 0xbc, 0x04, 0x01, 0xca, 0xa8, 0x22, 0xee, 0x22, 0x53, 0xce, 0x6d, 0x7e, 0x03, 0xd6, + 0xd6, 0x47, 0x8d, 0x7f, 0xda, 0xfa, 0xc8, 0x8e, 0x1d, 0xae, 0x18, 0xa5, 0xa4, 0x41, 0x3d, 0xe8, + 0x97, 0xb0, 0xe8, 0x0d, 0x51, 0x3a, 0x1d, 0x42, 0xb3, 0x62, 0x39, 0xc6, 0x04, 0x5c, 0x91, 0xc8, + 0x12, 0x5a, 0x95, 0x09, 0x21, 0xba, 0xb6, 0x97, 0x9e, 0x02, 0x2f, 0x60, 0x2d, 0x00, 0x7f, 0x3a, + 0xd4, 0xbd, 0x63, 0x6a, 0x5e, 0x8c, 0xc5, 0x87, 0x2a, 0x71, 0x1a, 0x6f, 0x58, 0x82, 0x7a, 0xaa, + 0x07, 0x5b, 0x35, 0xff, 0x05, 0x1c, 0x34, 0x35, 0x14, 0xc6, 0x4a, 0xda, 0x92, 0x92, 0x36, 0x51, + 0x25, 0x46, 0x12, 0x51, 0xec, 0x26, 0x64, 0x1a, 0xac, 0xd7, 0x6b, 0x91, 0x93, 0xd3, 0xd8, 0xb8, + 0xc6, 0xc9, 0x58, 0x93, 0x32, 0x96, 0x71, 0x4e, 0xca, 0x50, 0x14, 0x91, 0x77, 0x8e, 0x7c, 0x32, + 0xa7, 0x1e, 0xb7, 0x58, 0x01, 0x78, 0xdc, 0x47, 0x62, 0x1f, 0xc4, 0x70, 0x64, 0x88, 0x3e, 0xa6, + 0xb3, 0xdd, 0x45, 0x4f, 0x20, 0x25, 0xc6, 0xd2, 0x57, 0x36, 0x42, 0x65, 0x3a, 0x96, 0x09, 0xda, + 0x63, 0xc4, 0x14, 0x06, 0x7c, 0x03, 0xd9, 0xc0, 0x8c, 0x8b, 0xd4, 0x53, 0x30, 0x3d, 0x26, 0xc7, + 0x52, 0x43, 0xf5, 0x2f, 0xa8, 0xc1, 0xb2, 0xfc, 0x25, 0x01, 0xeb, 0xb1, 0x23, 0x34, 0xda, 0x9a, + 0x12, 0x16, 0x39, 0x63, 0xc7, 0x8a, 0xde, 0x91, 0xa2, 0x6f, 0xe3, 0xcd, 0x49, 0xd1, 0x46, 0x9b, + 0x39, 0x06, 0xf3, 0x41, 0x42, 0x95, 0x3d, 0x48, 0x89, 0x51, 0x62, 0x5e, 0x49, 0x07, 0xc7, 0x8d, + 0x70, 0x49, 0x8b, 0x61, 0x03, 0xed, 0x42, 0x4a, 0x0c, 0x1b, 0x48, 0xb5, 0xea, 0xc0, 0x80, 0xaf, + 0x01, 0xc1, 0x59, 0x24, 0x0c, 0xe8, 0x59, 0x2e, 0xbf, 0x93, 0x78, 0xf8, 0xc6, 0xef, 0xe7, 0x95, + 0xc4, 0xcb, 0xf3, 0x4a, 0xe2, 0xaf, 0xf3, 0x4a, 0xe2, 0xd7, 0x8b, 0xca, 0x95, 0x97, 0x17, 0x95, + 0x2b, 0x7f, 0x5e, 0x54, 0xae, 0x7c, 0xbd, 0xe0, 0xa9, 0xb4, 0x28, 0xff, 0xbd, 0xff, 0x6f, 0x00, + 0x00, 0x00, 0xff, 0xff, 0x24, 0x22, 0x00, 0x6e, 0x0d, 0x10, 0x00, 0x00, } // Reference imports to suppress errors if they are not otherwise used. @@ -1481,9 +1591,13 @@ type IAVLServiceClient interface { // has a given key at a specific tree version. Has(ctx context.Context, in *HasRequest, opts ...grpc.CallOption) (*HasResponse, error) HasVersioned(ctx context.Context, in *HasVersionedRequest, opts ...grpc.CallOption) (*HasResponse, error) - // Get returns a result containing the IAVL tree version and value for a given + // Get returns a result containing the index and value for a given // key based on the current state (version) of the tree. + // If the key does not exist, Get returns the index of the next value. Get(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetResponse, error) + // GetByIndex returns a result containing the key and value for a given + // index based on the current state (version) of the tree. + GetByIndex(ctx context.Context, in *GetByIndexRequest, opts ...grpc.CallOption) (*GetByIndexResponse, error) // GetWithProof returns a result containing the IAVL tree version and value for // a given key based on the current state (version) of the tree including a // verifiable Merkle proof. @@ -1576,6 +1690,15 @@ func (c *iAVLServiceClient) Get(ctx context.Context, in *GetRequest, opts ...grp return out, nil } +func (c *iAVLServiceClient) GetByIndex(ctx context.Context, in *GetByIndexRequest, opts ...grpc.CallOption) (*GetByIndexResponse, error) { + out := new(GetByIndexResponse) + err := c.cc.Invoke(ctx, "/iavl.IAVLService/GetByIndex", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + func (c *iAVLServiceClient) GetWithProof(ctx context.Context, in *GetRequest, opts ...grpc.CallOption) (*GetWithProofResponse, error) { out := new(GetWithProofResponse) err := c.cc.Invoke(ctx, "/iavl.IAVLService/GetWithProof", in, out, opts...) @@ -1785,9 +1908,13 @@ type IAVLServiceServer interface { // has a given key at a specific tree version. Has(context.Context, *HasRequest) (*HasResponse, error) HasVersioned(context.Context, *HasVersionedRequest) (*HasResponse, error) - // Get returns a result containing the IAVL tree version and value for a given + // Get returns a result containing the index and value for a given // key based on the current state (version) of the tree. + // If the key does not exist, Get returns the index of the next value. Get(context.Context, *GetRequest) (*GetResponse, error) + // GetByIndex returns a result containing the key and value for a given + // index based on the current state (version) of the tree. + GetByIndex(context.Context, *GetByIndexRequest) (*GetByIndexResponse, error) // GetWithProof returns a result containing the IAVL tree version and value for // a given key based on the current state (version) of the tree including a // verifiable Merkle proof. @@ -1858,6 +1985,9 @@ func (*UnimplementedIAVLServiceServer) HasVersioned(ctx context.Context, req *Ha func (*UnimplementedIAVLServiceServer) Get(ctx context.Context, req *GetRequest) (*GetResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method Get not implemented") } +func (*UnimplementedIAVLServiceServer) GetByIndex(ctx context.Context, req *GetByIndexRequest) (*GetByIndexResponse, error) { + return nil, status.Errorf(codes.Unimplemented, "method GetByIndex not implemented") +} func (*UnimplementedIAVLServiceServer) GetWithProof(ctx context.Context, req *GetRequest) (*GetWithProofResponse, error) { return nil, status.Errorf(codes.Unimplemented, "method GetWithProof not implemented") } @@ -1977,6 +2107,24 @@ func _IAVLService_Get_Handler(srv interface{}, ctx context.Context, dec func(int return interceptor(ctx, in, info, handler) } +func _IAVLService_GetByIndex_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(GetByIndexRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(IAVLServiceServer).GetByIndex(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/iavl.IAVLService/GetByIndex", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(IAVLServiceServer).GetByIndex(ctx, req.(*GetByIndexRequest)) + } + return interceptor(ctx, in, info, handler) +} + func _IAVLService_GetWithProof_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { in := new(GetRequest) if err := dec(in); err != nil { @@ -2356,6 +2504,10 @@ var _IAVLService_serviceDesc = grpc.ServiceDesc{ MethodName: "Get", Handler: _IAVLService_Get_Handler, }, + { + MethodName: "GetByIndex", + Handler: _IAVLService_GetByIndex_Handler, + }, { MethodName: "GetWithProof", Handler: _IAVLService_GetWithProof_Handler, @@ -2538,6 +2690,34 @@ func (m *GetRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *GetByIndexRequest) 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 *GetByIndexRequest) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetByIndexRequest) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if m.Index != 0 { + i = encodeVarintIavlApi(dAtA, i, uint64(m.Index)) + i-- + dAtA[i] = 0x8 + } + return len(dAtA) - i, nil +} + func (m *GetVersionedRequest) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -2999,6 +3179,16 @@ func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { _ = i var l int _ = l + if m.NotFound { + i-- + if m.NotFound { + dAtA[i] = 1 + } else { + dAtA[i] = 0 + } + i-- + dAtA[i] = 0x18 + } if len(m.Value) > 0 { i -= len(m.Value) copy(dAtA[i:], m.Value) @@ -3014,6 +3204,43 @@ func (m *GetResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { return len(dAtA) - i, nil } +func (m *GetByIndexResponse) 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 *GetByIndexResponse) MarshalTo(dAtA []byte) (int, error) { + size := m.Size() + return m.MarshalToSizedBuffer(dAtA[:size]) +} + +func (m *GetByIndexResponse) MarshalToSizedBuffer(dAtA []byte) (int, error) { + i := len(dAtA) + _ = i + var l int + _ = l + if len(m.Value) > 0 { + i -= len(m.Value) + copy(dAtA[i:], m.Value) + i = encodeVarintIavlApi(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 = encodeVarintIavlApi(dAtA, i, uint64(len(m.Key))) + i-- + dAtA[i] = 0xa + } + return len(dAtA) - i, nil +} + func (m *SetResponse) Marshal() (dAtA []byte, err error) { size := m.Size() dAtA = make([]byte, size) @@ -3450,6 +3677,18 @@ func (m *GetRequest) Size() (n int) { return n } +func (m *GetByIndexRequest) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + if m.Index != 0 { + n += 1 + sovIavlApi(uint64(m.Index)) + } + return n +} + func (m *GetVersionedRequest) Size() (n int) { if m == nil { return 0 @@ -3652,6 +3891,26 @@ func (m *GetResponse) Size() (n int) { if l > 0 { n += 1 + l + sovIavlApi(uint64(l)) } + if m.NotFound { + n += 2 + } + return n +} + +func (m *GetByIndexResponse) Size() (n int) { + if m == nil { + return 0 + } + var l int + _ = l + l = len(m.Key) + if l > 0 { + n += 1 + l + sovIavlApi(uint64(l)) + } + l = len(m.Value) + if l > 0 { + n += 1 + l + sovIavlApi(uint64(l)) + } return n } @@ -4100,6 +4359,78 @@ func (m *GetRequest) Unmarshal(dAtA []byte) error { } return nil } +func (m *GetByIndexRequest) 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 ErrIntOverflowIavlApi + } + 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: GetByIndexRequest: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetByIndexRequest: illegal tag %d (wire type %d)", fieldNum, wire) + } + switch fieldNum { + case 1: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field Index", wireType) + } + m.Index = 0 + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIavlApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + m.Index |= int64(b&0x7F) << shift + if b < 0x80 { + break + } + } + default: + iNdEx = preIndex + skippy, err := skipIavlApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthIavlApi + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthIavlApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} func (m *GetVersionedRequest) Unmarshal(dAtA []byte) error { l := len(dAtA) iNdEx := 0 @@ -5469,6 +5800,147 @@ func (m *GetResponse) Unmarshal(dAtA []byte) error { m.Value = []byte{} } iNdEx = postIndex + case 3: + if wireType != 0 { + return fmt.Errorf("proto: wrong wireType = %d for field NotFound", wireType) + } + var v int + for shift := uint(0); ; shift += 7 { + if shift >= 64 { + return ErrIntOverflowIavlApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + v |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + m.NotFound = bool(v != 0) + default: + iNdEx = preIndex + skippy, err := skipIavlApi(dAtA[iNdEx:]) + if err != nil { + return err + } + if skippy < 0 { + return ErrInvalidLengthIavlApi + } + if (iNdEx + skippy) < 0 { + return ErrInvalidLengthIavlApi + } + if (iNdEx + skippy) > l { + return io.ErrUnexpectedEOF + } + iNdEx += skippy + } + } + + if iNdEx > l { + return io.ErrUnexpectedEOF + } + return nil +} +func (m *GetByIndexResponse) 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 ErrIntOverflowIavlApi + } + 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: GetByIndexResponse: wiretype end group for non-group") + } + if fieldNum <= 0 { + return fmt.Errorf("proto: GetByIndexResponse: 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 ErrIntOverflowIavlApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthIavlApi + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthIavlApi + } + 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 ErrIntOverflowIavlApi + } + if iNdEx >= l { + return io.ErrUnexpectedEOF + } + b := dAtA[iNdEx] + iNdEx++ + byteLen |= int(b&0x7F) << shift + if b < 0x80 { + break + } + } + if byteLen < 0 { + return ErrInvalidLengthIavlApi + } + postIndex := iNdEx + byteLen + if postIndex < 0 { + return ErrInvalidLengthIavlApi + } + if postIndex > l { + return io.ErrUnexpectedEOF + } + m.Value = append(m.Value[:0], dAtA[iNdEx:postIndex]...) + if m.Value == nil { + m.Value = []byte{} + } + iNdEx = postIndex default: iNdEx = preIndex skippy, err := skipIavlApi(dAtA[iNdEx:]) diff --git a/proto/iavl_api.pb.gw.go b/proto/iavl_api.pb.gw.go index 345f62fd4..785d108a6 100644 --- a/proto/iavl_api.pb.gw.go +++ b/proto/iavl_api.pb.gw.go @@ -140,6 +140,42 @@ func local_request_IAVLService_Get_0(ctx context.Context, marshaler runtime.Mars } +var ( + filter_IAVLService_GetByIndex_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} +) + +func request_IAVLService_GetByIndex_0(ctx context.Context, marshaler runtime.Marshaler, client IAVLServiceClient, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetByIndexRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_IAVLService_GetByIndex_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := client.GetByIndex(ctx, &protoReq, grpc.Header(&metadata.HeaderMD), grpc.Trailer(&metadata.TrailerMD)) + return msg, metadata, err + +} + +func local_request_IAVLService_GetByIndex_0(ctx context.Context, marshaler runtime.Marshaler, server IAVLServiceServer, req *http.Request, pathParams map[string]string) (proto.Message, runtime.ServerMetadata, error) { + var protoReq GetByIndexRequest + var metadata runtime.ServerMetadata + + if err := req.ParseForm(); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + if err := runtime.PopulateQueryParameters(&protoReq, req.Form, filter_IAVLService_GetByIndex_0); err != nil { + return nil, metadata, status.Errorf(codes.InvalidArgument, "%v", err) + } + + msg, err := server.GetByIndex(ctx, &protoReq) + return msg, metadata, err + +} + var ( filter_IAVLService_GetWithProof_0 = &utilities.DoubleArray{Encoding: map[string]int{}, Base: []int(nil), Check: []int(nil)} ) @@ -902,6 +938,26 @@ func RegisterIAVLServiceHandlerServer(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("GET", pattern_IAVLService_GetByIndex_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateIncomingContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := local_request_IAVLService_GetByIndex_0(rctx, inboundMarshaler, server, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_IAVLService_GetByIndex_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_IAVLService_GetWithProof_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1390,6 +1446,26 @@ func RegisterIAVLServiceHandlerClient(ctx context.Context, mux *runtime.ServeMux }) + mux.Handle("GET", pattern_IAVLService_GetByIndex_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { + ctx, cancel := context.WithCancel(req.Context()) + defer cancel() + inboundMarshaler, outboundMarshaler := runtime.MarshalerForRequest(mux, req) + rctx, err := runtime.AnnotateContext(ctx, mux, req) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + resp, md, err := request_IAVLService_GetByIndex_0(rctx, inboundMarshaler, client, req, pathParams) + ctx = runtime.NewServerMetadataContext(ctx, md) + if err != nil { + runtime.HTTPError(ctx, mux, outboundMarshaler, w, req, err) + return + } + + forward_IAVLService_GetByIndex_0(ctx, mux, outboundMarshaler, w, req, resp, mux.GetForwardResponseOptions()...) + + }) + mux.Handle("GET", pattern_IAVLService_GetWithProof_0, func(w http.ResponseWriter, req *http.Request, pathParams map[string]string) { ctx, cancel := context.WithCancel(req.Context()) defer cancel() @@ -1800,6 +1876,8 @@ var ( pattern_IAVLService_Get_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "get"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_IAVLService_GetByIndex_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "getbyindex"}, "", runtime.AssumeColonVerbOpt(true))) + pattern_IAVLService_GetWithProof_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 2, 1}, []string{"v1", "get_with_proof"}, "", runtime.AssumeColonVerbOpt(true))) pattern_IAVLService_GetVersioned_0 = runtime.MustPattern(runtime.NewPattern(1, []int{2, 0, 1, 0, 4, 1, 5, 1, 2, 2}, []string{"v1", "version", "get_versioned"}, "", runtime.AssumeColonVerbOpt(true))) @@ -1848,6 +1926,8 @@ var ( forward_IAVLService_Get_0 = runtime.ForwardResponseMessage + forward_IAVLService_GetByIndex_0 = runtime.ForwardResponseMessage + forward_IAVLService_GetWithProof_0 = runtime.ForwardResponseMessage forward_IAVLService_GetVersioned_0 = runtime.ForwardResponseMessage diff --git a/server/server.go b/server/server.go index 5da0718e0..e72a25233 100644 --- a/server/server.go +++ b/server/server.go @@ -70,20 +70,34 @@ func (s *IAVLServer) Has(_ context.Context, req *pb.HasRequest) (*pb.HasResponse return &pb.HasResponse{Result: s.tree.Has(req.Key)}, nil } -// Get returns a result containing the IAVL tree version and value for a given +// Get returns a result containing the index and value for a given // key based on the current state (version) of the tree. +// If the key does not exist, Get returns the index of the next value. func (s *IAVLServer) Get(_ context.Context, req *pb.GetRequest) (*pb.GetResponse, error) { s.rwLock.RLock() defer s.rwLock.RUnlock() idx, value := s.tree.Get(req.Key) - if value == nil { - s := status.New(codes.NotFound, "the key requested does not exist") - return nil, s.Err() + return &pb.GetResponse{Index: idx, Value: value, NotFound: value == nil}, nil + +} + +// GetByIndex returns a result containing the key and value for a given +// index based on the current state (version) of the tree. +func (s *IAVLServer) GetByIndex(_ context.Context, req *pb.GetByIndexRequest) (*pb.GetByIndexResponse, error) { + + s.rwLock.RLock() + defer s.rwLock.RUnlock() + + key, value := s.tree.GetByIndex(req.Index) + if key == nil { + e := status.New(codes.NotFound, "the index requested does not exist") + return nil, e.Err() } - return &pb.GetResponse{Index: idx, Value: value}, nil + return &pb.GetByIndexResponse{Key: key, Value: value}, nil + } // GetWithProof returns a result containing the IAVL tree version and value for diff --git a/server/server_test.go b/server/server_test.go index dab873509..e8e26fcd0 100644 --- a/server/server_test.go +++ b/server/server_test.go @@ -123,14 +123,14 @@ func (suite *ServerTestSuite) TestGet() { preRun func() key []byte expectErr bool - result []byte + result *pb.GetResponse }{ { "existing key", nil, []byte("key-0"), false, - []byte("value-0"), + &pb.GetResponse{Index: 0, Value: []byte("value-0"), NotFound: false}, }, { "existing modified key", @@ -148,12 +148,71 @@ func (suite *ServerTestSuite) TestGet() { }, []byte("key-0"), false, - []byte("NEW_VALUE"), + &pb.GetResponse{Index: 0, Value: []byte("NEW_VALUE"), NotFound: false}, }, { "non-existent key", nil, []byte("key-1000"), + false, + &pb.GetResponse{Index: 3, Value: nil, NotFound: true}, + }, + } + + for _, tc := range testCases { + tc := tc + suite.Run(tc.name, func() { + if tc.preRun != nil { + tc.preRun() + } + + res, err := suite.server.Get(context.Background(), &pb.GetRequest{Key: tc.key}) + suite.Equal(tc.expectErr, err != nil) + + if !tc.expectErr { + suite.Equal(tc.result, res) + } + }) + } +} + +func (suite *ServerTestSuite) TestGetByIndex() { + testCases := []struct { + name string + preRun func() + index int64 + expectErr bool + result *pb.GetByIndexResponse + }{ + { + "existing index", + nil, + 0, + false, + &pb.GetByIndexResponse{Key: []byte("key-0"), Value: []byte("value-0")}, + }, + { + "existing modified index", + func() { + req := &pb.SetRequest{ + Key: []byte("key-0"), + Value: []byte("NEW_VALUE"), + } + + _, err := suite.server.Set(context.Background(), req) + suite.NoError(err) + + _, err = suite.server.SaveVersion(context.Background(), nil) + suite.NoError(err) + }, + 0, + false, + &pb.GetByIndexResponse{Key: []byte("key-0"), Value: []byte("NEW_VALUE")}, + }, + { + "non-existent index", + nil, + 1000, true, nil, }, @@ -166,11 +225,11 @@ func (suite *ServerTestSuite) TestGet() { tc.preRun() } - res, err := suite.server.Get(context.Background(), &pb.GetRequest{Key: tc.key}) + res, err := suite.server.GetByIndex(context.Background(), &pb.GetByIndexRequest{Index: tc.index}) suite.Equal(tc.expectErr, err != nil) if !tc.expectErr { - suite.Equal(tc.result, res.Value) + suite.Equal(tc.result, res) } }) }