mirror of
https://github.com/planetmint/planetmint-go.git
synced 2025-11-24 06:25:47 +00:00
added machine index time and implemented indexing
Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
parent
bc97f3c46e
commit
f5cdba9ed5
@ -23,3 +23,10 @@ message Metadata {
|
||||
map<string, string> assetDefinition = 3;
|
||||
string additionalDataCID = 4;
|
||||
}
|
||||
|
||||
message MachineIndex {
|
||||
|
||||
string machineId = 1;
|
||||
string issuerPlanetmint = 2;
|
||||
string issuerLiquid = 3;
|
||||
}
|
||||
@ -10,12 +10,19 @@ import (
|
||||
func (k Keeper) StoreMachine(ctx sdk.Context, machine types.Machine) {
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MachineKey))
|
||||
appendValue := k.cdc.MustMarshal(&machine)
|
||||
k.StoreMachineIndex(ctx, machine)
|
||||
store.Set(GetMachineBytes(machine.IssuerPlanetmint), appendValue)
|
||||
}
|
||||
|
||||
func (k Keeper) GetMachine(ctx sdk.Context, pubKey string) (val types.Machine, found bool) {
|
||||
index, found := k.GetMachineIndex(ctx, pubKey)
|
||||
if !found {
|
||||
return val, false
|
||||
}
|
||||
|
||||
store := prefix.NewStore(ctx.KVStore(k.storeKey), types.KeyPrefix(types.MachineKey))
|
||||
machine := store.Get(GetMachineBytes(pubKey))
|
||||
machine := store.Get(GetMachineBytes(index.IssuerPlanetmint))
|
||||
|
||||
if machine == nil {
|
||||
return val, false
|
||||
}
|
||||
@ -23,6 +30,35 @@ func (k Keeper) GetMachine(ctx sdk.Context, pubKey string) (val types.Machine, f
|
||||
return val, true
|
||||
}
|
||||
|
||||
func (k Keeper) StoreMachineIndex(ctx sdk.Context, machine types.Machine) {
|
||||
indexStore := prefix.NewStore(ctx.KVStore(k.indexStoreKey), types.KeyPrefix(types.IndexKey))
|
||||
index := types.MachineIndex{
|
||||
MachineId: machine.MachineId,
|
||||
IssuerPlanetmint: machine.IssuerPlanetmint,
|
||||
IssuerLiquid: machine.IssuerPlanetmint,
|
||||
}
|
||||
|
||||
machineIdIndexKey := GetMachineBytes(machine.MachineId)
|
||||
issuerPlanetmintIndexKey := GetMachineBytes(machine.IssuerPlanetmint)
|
||||
issuerLiquidIndexKey := GetMachineBytes(machine.IssuerLiquid)
|
||||
indexAppendValue := k.cdc.MustMarshal(&index)
|
||||
indexStore.Set(machineIdIndexKey, indexAppendValue)
|
||||
indexStore.Set(issuerPlanetmintIndexKey, indexAppendValue)
|
||||
indexStore.Set(issuerLiquidIndexKey, indexAppendValue)
|
||||
}
|
||||
|
||||
func (k Keeper) GetMachineIndex(ctx sdk.Context, pubKey string) (val types.MachineIndex, found bool) {
|
||||
indexStore := prefix.NewStore(ctx.KVStore(k.indexStoreKey), types.KeyPrefix(types.IndexKey))
|
||||
index := indexStore.Get(GetMachineBytes(pubKey))
|
||||
|
||||
if index == nil {
|
||||
return val, false
|
||||
}
|
||||
|
||||
k.cdc.Unmarshal(index, &val)
|
||||
return val, true
|
||||
}
|
||||
|
||||
func GetMachineBytes(pubKey string) []byte {
|
||||
return []byte(pubKey)
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package keeper_test
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
keepertest "planetmint-go/testutil/keeper"
|
||||
@ -14,15 +15,25 @@ import (
|
||||
func createNMachine(keeper *keeper.Keeper, ctx sdk.Context, n int) []types.Machine {
|
||||
items := make([]types.Machine, n)
|
||||
for i := range items {
|
||||
// fill out machine
|
||||
items[i].IssuerPlanetmint = "asd"
|
||||
items[i].IssuerLiquid = "dsa"
|
||||
items[i].MachineId = fmt.Sprintf("machineId%v", i)
|
||||
items[i].IssuerPlanetmint = fmt.Sprintf("issuerPlanetmint%v", i)
|
||||
items[i].IssuerLiquid = fmt.Sprintf("issuerLiquid%v", i)
|
||||
keeper.StoreMachine(ctx, items[i])
|
||||
}
|
||||
return items
|
||||
}
|
||||
|
||||
func TestGetMachine(t *testing.T) {
|
||||
func TestGetMachineById(t *testing.T) {
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
items := createNMachine(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
machineById, found := keeper.GetMachine(ctx, item.MachineId)
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, item, machineById)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetMachineByIssuerPlanetmint(t *testing.T) {
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
items := createNMachine(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
@ -31,3 +42,13 @@ func TestGetMachine(t *testing.T) {
|
||||
assert.Equal(t, item, machineById)
|
||||
}
|
||||
}
|
||||
|
||||
func TestGetMachineByIssuerLiquid(t *testing.T) {
|
||||
keeper, ctx := keepertest.MachineKeeper(t)
|
||||
items := createNMachine(keeper, ctx, 10)
|
||||
for _, item := range items {
|
||||
machineById, found := keeper.GetMachine(ctx, item.IssuerLiquid)
|
||||
assert.True(t, found)
|
||||
assert.Equal(t, item, machineById)
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,12 +198,73 @@ func (m *Metadata) GetAdditionalDataCID() string {
|
||||
return ""
|
||||
}
|
||||
|
||||
type MachineIndex struct {
|
||||
MachineId string `protobuf:"bytes,1,opt,name=machineId,proto3" json:"machineId,omitempty"`
|
||||
IssuerPlanetmint string `protobuf:"bytes,2,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"`
|
||||
IssuerLiquid string `protobuf:"bytes,3,opt,name=issuerLiquid,proto3" json:"issuerLiquid,omitempty"`
|
||||
}
|
||||
|
||||
func (m *MachineIndex) Reset() { *m = MachineIndex{} }
|
||||
func (m *MachineIndex) String() string { return proto.CompactTextString(m) }
|
||||
func (*MachineIndex) ProtoMessage() {}
|
||||
func (*MachineIndex) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_cd9f258b3d94bc1e, []int{2}
|
||||
}
|
||||
func (m *MachineIndex) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
}
|
||||
func (m *MachineIndex) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
|
||||
if deterministic {
|
||||
return xxx_messageInfo_MachineIndex.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 *MachineIndex) XXX_Merge(src proto.Message) {
|
||||
xxx_messageInfo_MachineIndex.Merge(m, src)
|
||||
}
|
||||
func (m *MachineIndex) XXX_Size() int {
|
||||
return m.Size()
|
||||
}
|
||||
func (m *MachineIndex) XXX_DiscardUnknown() {
|
||||
xxx_messageInfo_MachineIndex.DiscardUnknown(m)
|
||||
}
|
||||
|
||||
var xxx_messageInfo_MachineIndex proto.InternalMessageInfo
|
||||
|
||||
func (m *MachineIndex) GetMachineId() string {
|
||||
if m != nil {
|
||||
return m.MachineId
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MachineIndex) GetIssuerPlanetmint() string {
|
||||
if m != nil {
|
||||
return m.IssuerPlanetmint
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func (m *MachineIndex) GetIssuerLiquid() string {
|
||||
if m != nil {
|
||||
return m.IssuerLiquid
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
func init() {
|
||||
proto.RegisterType((*Machine)(nil), "planetmintgo.machine.Machine")
|
||||
proto.RegisterType((*Metadata)(nil), "planetmintgo.machine.Metadata")
|
||||
proto.RegisterMapType((map[string]string)(nil), "planetmintgo.machine.Metadata.AssetDefinitionEntry")
|
||||
proto.RegisterMapType((map[string]string)(nil), "planetmintgo.machine.Metadata.DeviceEntry")
|
||||
proto.RegisterMapType((map[string]string)(nil), "planetmintgo.machine.Metadata.GpsEntry")
|
||||
proto.RegisterType((*MachineIndex)(nil), "planetmintgo.machine.MachineIndex")
|
||||
}
|
||||
|
||||
func init() {
|
||||
@ -211,35 +272,36 @@ func init() {
|
||||
}
|
||||
|
||||
var fileDescriptor_cd9f258b3d94bc1e = []byte{
|
||||
// 436 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x8b, 0xd3, 0x40,
|
||||
0x14, 0xee, 0x24, 0xdd, 0x6c, 0xf2, 0x2a, 0xb8, 0x0e, 0x45, 0x86, 0x45, 0x43, 0xe8, 0xc5, 0xb0,
|
||||
0x68, 0x0a, 0xbb, 0xa0, 0xee, 0xde, 0xac, 0x11, 0x59, 0x70, 0x41, 0x72, 0x14, 0x3c, 0x8c, 0xc9,
|
||||
0x58, 0x87, 0x6d, 0x26, 0x31, 0x33, 0x59, 0xec, 0xbf, 0xf0, 0x8f, 0xf8, 0x3f, 0xbc, 0x08, 0x7b,
|
||||
0xf4, 0x28, 0xed, 0x1f, 0x91, 0x4c, 0xa6, 0xed, 0xd6, 0x16, 0x4b, 0x4f, 0x79, 0xef, 0x7b, 0xdf,
|
||||
0xf7, 0x4d, 0xde, 0x9b, 0x79, 0x10, 0x96, 0x55, 0xa1, 0x8a, 0x61, 0x39, 0xa1, 0x82, 0xa9, 0x9c,
|
||||
0x0b, 0x35, 0x2e, 0x86, 0x39, 0x4d, 0xbf, 0x70, 0xc1, 0x16, 0xdf, 0x48, 0x53, 0x70, 0xff, 0x2e,
|
||||
0x27, 0x32, 0xb5, 0xc1, 0x0f, 0x0b, 0x0e, 0xaf, 0xda, 0x18, 0x63, 0xe8, 0x0a, 0x9a, 0x33, 0x82,
|
||||
0x02, 0x14, 0x7a, 0x89, 0x8e, 0xf1, 0x43, 0x70, 0x14, 0x4f, 0xaf, 0x59, 0x45, 0x2c, 0x8d, 0x9a,
|
||||
0xac, 0xc1, 0xb9, 0x94, 0x35, 0xcb, 0x88, 0x1d, 0xa0, 0xb0, 0x9b, 0x98, 0xac, 0xc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, 0xad, 0x7a, 0xc9, 0x66, 0xe1,
|
||||
0xf8, 0x39, 0xb8, 0x8b, 0x0e, 0xf1, 0x11, 0xd8, 0xd7, 0x6c, 0x6a, 0xde, 0x51, 0x13, 0xe2, 0x3e,
|
||||
0x1c, 0xdc, 0xd0, 0x49, 0xcd, 0xcc, 0x2b, 0x6a, 0x93, 0x0b, 0xeb, 0x25, 0x3a, 0x3e, 0x87, 0xde,
|
||||
0x9d, 0xde, 0xf6, 0x92, 0x8e, 0xa0, 0xbf, 0xad, 0x93, 0x7d, 0x3c, 0x46, 0x2f, 0x7e, 0xce, 0x7c,
|
||||
0x74, 0x3b, 0xf3, 0xd1, 0x9f, 0x99, 0x8f, 0xbe, 0xcf, 0xfd, 0xce, 0xed, 0xdc, 0xef, 0xfc, 0x9e,
|
||||
0xfb, 0x9d, 0x0f, 0x8f, 0x57, 0x33, 0x7c, 0x36, 0x2e, 0x86, 0xdf, 0x96, 0x6b, 0xa5, 0xa6, 0x25,
|
||||
0x93, 0x9f, 0x1c, 0xbd, 0x55, 0x67, 0x7f, 0x03, 0x00, 0x00, 0xff, 0xff, 0xde, 0x46, 0x2a, 0xfa,
|
||||
0x81, 0x03, 0x00, 0x00,
|
||||
// 462 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x6b, 0xdb, 0x30,
|
||||
0x18, 0x8d, 0xec, 0x34, 0x4d, 0xbe, 0x14, 0xd6, 0x89, 0x30, 0x44, 0xd9, 0x4c, 0xf0, 0x65, 0xa6,
|
||||
0x6c, 0x0e, 0xb4, 0xb0, 0xad, 0xbd, 0x2d, 0xf3, 0x18, 0x81, 0x15, 0x86, 0x8f, 0x83, 0x1d, 0x34,
|
||||
0x4b, 0xcb, 0x44, 0x63, 0xd9, 0xb3, 0xe4, 0xd2, 0xc0, 0x7e, 0xc4, 0xfe, 0xc8, 0xfe, 0xc7, 0x2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0x87, 0xae, 0x66, 0x1e, 0xfa, 0x3b, 0xf3,
|
||||
0xd0, 0x8f, 0xb9, 0xd7, 0xb8, 0x9a, 0x7b, 0x8d, 0x3f, 0x73, 0xaf, 0xf1, 0xf1, 0xc9, 0xea, 0x06,
|
||||
0x9f, 0x8f, 0xb3, 0xc1, 0xe5, 0xf2, 0x51, 0xeb, 0x69, 0xce, 0xd5, 0xe7, 0x96, 0x79, 0xd3, 0xc7,
|
||||
0xff, 0x02, 0x00, 0x00, 0xff, 0xff, 0x7d, 0x4f, 0x35, 0x26, 0xff, 0x03, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Machine) Marshal() (dAtA []byte, err error) {
|
||||
@ -414,6 +476,50 @@ func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func (m *MachineIndex) 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 *MachineIndex) MarshalTo(dAtA []byte) (int, error) {
|
||||
size := m.Size()
|
||||
return m.MarshalToSizedBuffer(dAtA[:size])
|
||||
}
|
||||
|
||||
func (m *MachineIndex) MarshalToSizedBuffer(dAtA []byte) (int, error) {
|
||||
i := len(dAtA)
|
||||
_ = i
|
||||
var l int
|
||||
_ = l
|
||||
if len(m.IssuerLiquid) > 0 {
|
||||
i -= len(m.IssuerLiquid)
|
||||
copy(dAtA[i:], m.IssuerLiquid)
|
||||
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerLiquid)))
|
||||
i--
|
||||
dAtA[i] = 0x1a
|
||||
}
|
||||
if len(m.IssuerPlanetmint) > 0 {
|
||||
i -= len(m.IssuerPlanetmint)
|
||||
copy(dAtA[i:], m.IssuerPlanetmint)
|
||||
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerPlanetmint)))
|
||||
i--
|
||||
dAtA[i] = 0x12
|
||||
}
|
||||
if len(m.MachineId) > 0 {
|
||||
i -= len(m.MachineId)
|
||||
copy(dAtA[i:], m.MachineId)
|
||||
i = encodeVarintMachine(dAtA, i, uint64(len(m.MachineId)))
|
||||
i--
|
||||
dAtA[i] = 0xa
|
||||
}
|
||||
return len(dAtA) - i, nil
|
||||
}
|
||||
|
||||
func encodeVarintMachine(dAtA []byte, offset int, v uint64) int {
|
||||
offset -= sovMachine(v)
|
||||
base := offset
|
||||
@ -504,6 +610,27 @@ func (m *Metadata) Size() (n int) {
|
||||
return n
|
||||
}
|
||||
|
||||
func (m *MachineIndex) Size() (n int) {
|
||||
if m == nil {
|
||||
return 0
|
||||
}
|
||||
var l int
|
||||
_ = l
|
||||
l = len(m.MachineId)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovMachine(uint64(l))
|
||||
}
|
||||
l = len(m.IssuerPlanetmint)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovMachine(uint64(l))
|
||||
}
|
||||
l = len(m.IssuerLiquid)
|
||||
if l > 0 {
|
||||
n += 1 + l + sovMachine(uint64(l))
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func sovMachine(x uint64) (n int) {
|
||||
return (math_bits.Len64(x|1) + 6) / 7
|
||||
}
|
||||
@ -1276,6 +1403,152 @@ func (m *Metadata) Unmarshal(dAtA []byte) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func (m *MachineIndex) 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 ErrIntOverflowMachine
|
||||
}
|
||||
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: MachineIndex: wiretype end group for non-group")
|
||||
}
|
||||
if fieldNum <= 0 {
|
||||
return fmt.Errorf("proto: MachineIndex: illegal tag %d (wire type %d)", fieldNum, wire)
|
||||
}
|
||||
switch fieldNum {
|
||||
case 1:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field MachineId", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMachine
|
||||
}
|
||||
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 ErrInvalidLengthMachine
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMachine
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.MachineId = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 2:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field IssuerPlanetmint", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMachine
|
||||
}
|
||||
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 ErrInvalidLengthMachine
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMachine
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.IssuerPlanetmint = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
case 3:
|
||||
if wireType != 2 {
|
||||
return fmt.Errorf("proto: wrong wireType = %d for field IssuerLiquid", wireType)
|
||||
}
|
||||
var stringLen uint64
|
||||
for shift := uint(0); ; shift += 7 {
|
||||
if shift >= 64 {
|
||||
return ErrIntOverflowMachine
|
||||
}
|
||||
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 ErrInvalidLengthMachine
|
||||
}
|
||||
postIndex := iNdEx + intStringLen
|
||||
if postIndex < 0 {
|
||||
return ErrInvalidLengthMachine
|
||||
}
|
||||
if postIndex > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
m.IssuerLiquid = string(dAtA[iNdEx:postIndex])
|
||||
iNdEx = postIndex
|
||||
default:
|
||||
iNdEx = preIndex
|
||||
skippy, err := skipMachine(dAtA[iNdEx:])
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if (skippy < 0) || (iNdEx+skippy) < 0 {
|
||||
return ErrInvalidLengthMachine
|
||||
}
|
||||
if (iNdEx + skippy) > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
iNdEx += skippy
|
||||
}
|
||||
}
|
||||
|
||||
if iNdEx > l {
|
||||
return io.ErrUnexpectedEOF
|
||||
}
|
||||
return nil
|
||||
}
|
||||
func skipMachine(dAtA []byte) (n int, err error) {
|
||||
l := len(dAtA)
|
||||
iNdEx := 0
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user