adjusted machine.proto and updated code accordingly

Signed-off-by: Lorenz Herzberger <lorenzherzberger@gmail.com>
This commit is contained in:
Lorenz Herzberger 2023-06-15 15:01:16 +02:00
parent 945cfc4e61
commit 70b6fc4b7c
No known key found for this signature in database
GPG Key ID: FA5EE906EB55316A
5 changed files with 846 additions and 50 deletions

1
.gitignore vendored
View File

@ -1 +1,2 @@
planetmint-god planetmint-god
.vscode

View File

@ -8,8 +8,18 @@ message Machine {
string name = 1; string name = 1;
string ticker = 2; string ticker = 2;
uint64 issued = 3; uint64 issued = 3;
uint64 precision = 4; uint64 amount = 4;
string issuerPlanetmint = 5; uint64 precision = 5;
string issuerLiquid = 6; string issuerPlanetmint = 6;
string cid = 7; string issuerLiquid = 7;
string machineId = 8;
Metadata metadata = 9;
} }
message Metadata {
map<string, string> gps = 1;
map<string, string> device = 2;
map<string, string> assetDefinition = 3;
string additionalDataCID = 4;
}

View File

@ -48,8 +48,8 @@ func AssetKeeper(t testing.TB) (*keeper.Keeper, sdk.Context) {
ctrl := gomock.NewController(t) ctrl := gomock.NewController(t)
mk := assettestutils.NewMockMachineKeeper(ctrl) mk := assettestutils.NewMockMachineKeeper(ctrl)
sk, pk := sample.KeyPair() sk, pk := sample.KeyPair()
mk.EXPECT().GetMachine(ctx, pk).Return(sample.Machine(pk, pk), true).AnyTimes() mk.EXPECT().GetMachine(ctx, pk).Return(sample.Machine(pk, pk, pk), true).AnyTimes()
mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk), false).AnyTimes() mk.EXPECT().GetMachine(ctx, sk).Return(sample.Machine(pk, pk, pk), false).AnyTimes()
k := keeper.NewKeeper( k := keeper.NewKeeper(
cdc, cdc,

View File

@ -23,15 +23,33 @@ func AccAddress() string {
return sdk.AccAddress(addr).String() return sdk.AccAddress(addr).String()
} }
func Machine(pkPM string, pkL string) machinetypes.Machine { func Machine(machineId string, pkPM string, pkL string) machinetypes.Machine {
m := machinetypes.Machine{ m := machinetypes.Machine{
Name: "machine", Name: "machine",
Ticker: "PM", Ticker: "PM",
Issued: 1, Issued: 1,
Amount: 1000,
Precision: 8, Precision: 8,
IssuerPlanetmint: pkPM, IssuerPlanetmint: pkPM,
IssuerLiquid: pkL, IssuerLiquid: pkL,
Cid: "Cid", MachineId: machineId,
} }
return m return m
} }
func Metadata() machinetypes.Metadata {
return machinetypes.Metadata{
Gps: map[string]string{
"Latitude": "-48.876667",
"Longitude": "-123.393333",
},
Device: map[string]string{
"Manufacturer": "RDDL",
"Serial": "AdnT2uyt",
},
AssetDefinition: map[string]string{
"Version": "0.1",
},
AdditionalDataCID: "CID",
}
}

View File

@ -1,5 +1,5 @@
// Code generated by protoc-gen-gogo. DO NOT EDIT. // Code generated by protoc-gen-gogo. DO NOT EDIT.
// source: planetmintgo/machine/machine.proto // source: proto/planetmintgo/machine/machine.proto
package types package types
@ -23,20 +23,22 @@ var _ = math.Inf
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
type Machine struct { type Machine struct {
Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"`
Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"` Ticker string `protobuf:"bytes,2,opt,name=ticker,proto3" json:"ticker,omitempty"`
Issued uint64 `protobuf:"varint,3,opt,name=issued,proto3" json:"issued,omitempty"` Issued uint64 `protobuf:"varint,3,opt,name=issued,proto3" json:"issued,omitempty"`
Precision uint64 `protobuf:"varint,4,opt,name=precision,proto3" json:"precision,omitempty"` Amount uint64 `protobuf:"varint,4,opt,name=amount,proto3" json:"amount,omitempty"`
IssuerPlanetmint string `protobuf:"bytes,5,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"` Precision uint64 `protobuf:"varint,5,opt,name=precision,proto3" json:"precision,omitempty"`
IssuerLiquid string `protobuf:"bytes,6,opt,name=issuerLiquid,proto3" json:"issuerLiquid,omitempty"` IssuerPlanetmint string `protobuf:"bytes,6,opt,name=issuerPlanetmint,proto3" json:"issuerPlanetmint,omitempty"`
Cid string `protobuf:"bytes,7,opt,name=cid,proto3" json:"cid,omitempty"` IssuerLiquid string `protobuf:"bytes,7,opt,name=issuerLiquid,proto3" json:"issuerLiquid,omitempty"`
MachineId string `protobuf:"bytes,8,opt,name=machineId,proto3" json:"machineId,omitempty"`
Metadata *Metadata `protobuf:"bytes,9,opt,name=metadata,proto3" json:"metadata,omitempty"`
} }
func (m *Machine) Reset() { *m = Machine{} } func (m *Machine) Reset() { *m = Machine{} }
func (m *Machine) String() string { return proto.CompactTextString(m) } func (m *Machine) String() string { return proto.CompactTextString(m) }
func (*Machine) ProtoMessage() {} func (*Machine) ProtoMessage() {}
func (*Machine) Descriptor() ([]byte, []int) { func (*Machine) Descriptor() ([]byte, []int) {
return fileDescriptor_1bb279745bef7c4b, []int{0} return fileDescriptor_cd9f258b3d94bc1e, []int{0}
} }
func (m *Machine) XXX_Unmarshal(b []byte) error { func (m *Machine) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b) return m.Unmarshal(b)
@ -86,6 +88,13 @@ func (m *Machine) GetIssued() uint64 {
return 0 return 0
} }
func (m *Machine) GetAmount() uint64 {
if m != nil {
return m.Amount
}
return 0
}
func (m *Machine) GetPrecision() uint64 { func (m *Machine) GetPrecision() uint64 {
if m != nil { if m != nil {
return m.Precision return m.Precision
@ -107,38 +116,130 @@ func (m *Machine) GetIssuerLiquid() string {
return "" return ""
} }
func (m *Machine) GetCid() string { func (m *Machine) GetMachineId() string {
if m != nil { if m != nil {
return m.Cid return m.MachineId
}
return ""
}
func (m *Machine) GetMetadata() *Metadata {
if m != nil {
return m.Metadata
}
return nil
}
type Metadata struct {
Gps map[string]string `protobuf:"bytes,1,rep,name=gps,proto3" json:"gps,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
Device map[string]string `protobuf:"bytes,2,rep,name=device,proto3" json:"device,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
AssetDefinition map[string]string `protobuf:"bytes,3,rep,name=assetDefinition,proto3" json:"assetDefinition,omitempty" protobuf_key:"bytes,1,opt,name=key,proto3" protobuf_val:"bytes,2,opt,name=value,proto3"`
AdditionalDataCID string `protobuf:"bytes,4,opt,name=additionalDataCID,proto3" json:"additionalDataCID,omitempty"`
}
func (m *Metadata) Reset() { *m = Metadata{} }
func (m *Metadata) String() string { return proto.CompactTextString(m) }
func (*Metadata) ProtoMessage() {}
func (*Metadata) Descriptor() ([]byte, []int) {
return fileDescriptor_cd9f258b3d94bc1e, []int{1}
}
func (m *Metadata) XXX_Unmarshal(b []byte) error {
return m.Unmarshal(b)
}
func (m *Metadata) XXX_Marshal(b []byte, deterministic bool) ([]byte, error) {
if deterministic {
return xxx_messageInfo_Metadata.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 *Metadata) XXX_Merge(src proto.Message) {
xxx_messageInfo_Metadata.Merge(m, src)
}
func (m *Metadata) XXX_Size() int {
return m.Size()
}
func (m *Metadata) XXX_DiscardUnknown() {
xxx_messageInfo_Metadata.DiscardUnknown(m)
}
var xxx_messageInfo_Metadata proto.InternalMessageInfo
func (m *Metadata) GetGps() map[string]string {
if m != nil {
return m.Gps
}
return nil
}
func (m *Metadata) GetDevice() map[string]string {
if m != nil {
return m.Device
}
return nil
}
func (m *Metadata) GetAssetDefinition() map[string]string {
if m != nil {
return m.AssetDefinition
}
return nil
}
func (m *Metadata) GetAdditionalDataCID() string {
if m != nil {
return m.AdditionalDataCID
} }
return "" return ""
} }
func init() { func init() {
proto.RegisterType((*Machine)(nil), "planetmintgo.machine.Machine") 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")
} }
func init() { func init() {
proto.RegisterFile("planetmintgo/machine/machine.proto", fileDescriptor_1bb279745bef7c4b) proto.RegisterFile("proto/planetmintgo/machine/machine.proto", fileDescriptor_cd9f258b3d94bc1e)
} }
var fileDescriptor_1bb279745bef7c4b = []byte{ var fileDescriptor_cd9f258b3d94bc1e = []byte{
// 233 bytes of a gzipped FileDescriptorProto // 436 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xe2, 0x52, 0x2a, 0xc8, 0x49, 0xcc, 0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x94, 0x53, 0x41, 0x8b, 0xd3, 0x40,
0x4b, 0x2d, 0xc9, 0xcd, 0xcc, 0x2b, 0x49, 0xcf, 0xd7, 0xcf, 0x4d, 0x4c, 0xce, 0xc8, 0xcc, 0x4b, 0x14, 0xee, 0x24, 0xdd, 0x6c, 0xf2, 0x2a, 0xb8, 0x0e, 0x45, 0x86, 0x45, 0x43, 0xe8, 0xc5, 0xb0,
0x85, 0xd1, 0x7a, 0x05, 0x45, 0xf9, 0x25, 0xf9, 0x42, 0x22, 0xc8, 0x6a, 0xf4, 0xa0, 0x72, 0x4a, 0x68, 0x0a, 0xbb, 0xa0, 0xee, 0xde, 0xac, 0x11, 0x59, 0x70, 0x41, 0x72, 0x14, 0x3c, 0x8c, 0xc9,
0x67, 0x19, 0xb9, 0xd8, 0x7d, 0x21, 0x6c, 0x21, 0x21, 0x2e, 0x96, 0xbc, 0xc4, 0xdc, 0x54, 0x09, 0x58, 0x87, 0x6d, 0x26, 0x31, 0x33, 0x59, 0xec, 0xbf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m *Machine) Marshal() (dAtA []byte, err error) {
@ -161,30 +262,47 @@ func (m *Machine) MarshalToSizedBuffer(dAtA []byte) (int, error) {
_ = i _ = i
var l int var l int
_ = l _ = l
if len(m.Cid) > 0 { if m.Metadata != nil {
i -= len(m.Cid) {
copy(dAtA[i:], m.Cid) size, err := m.Metadata.MarshalToSizedBuffer(dAtA[:i])
i = encodeVarintMachine(dAtA, i, uint64(len(m.Cid))) if err != nil {
return 0, err
}
i -= size
i = encodeVarintMachine(dAtA, i, uint64(size))
}
i-- i--
dAtA[i] = 0x3a dAtA[i] = 0x4a
}
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] = 0x42
} }
if len(m.IssuerLiquid) > 0 { if len(m.IssuerLiquid) > 0 {
i -= len(m.IssuerLiquid) i -= len(m.IssuerLiquid)
copy(dAtA[i:], m.IssuerLiquid) copy(dAtA[i:], m.IssuerLiquid)
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerLiquid))) i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerLiquid)))
i-- i--
dAtA[i] = 0x32 dAtA[i] = 0x3a
} }
if len(m.IssuerPlanetmint) > 0 { if len(m.IssuerPlanetmint) > 0 {
i -= len(m.IssuerPlanetmint) i -= len(m.IssuerPlanetmint)
copy(dAtA[i:], m.IssuerPlanetmint) copy(dAtA[i:], m.IssuerPlanetmint)
i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerPlanetmint))) i = encodeVarintMachine(dAtA, i, uint64(len(m.IssuerPlanetmint)))
i-- i--
dAtA[i] = 0x2a dAtA[i] = 0x32
} }
if m.Precision != 0 { if m.Precision != 0 {
i = encodeVarintMachine(dAtA, i, uint64(m.Precision)) i = encodeVarintMachine(dAtA, i, uint64(m.Precision))
i-- i--
dAtA[i] = 0x28
}
if m.Amount != 0 {
i = encodeVarintMachine(dAtA, i, uint64(m.Amount))
i--
dAtA[i] = 0x20 dAtA[i] = 0x20
} }
if m.Issued != 0 { if m.Issued != 0 {
@ -209,6 +327,93 @@ func (m *Machine) MarshalToSizedBuffer(dAtA []byte) (int, error) {
return len(dAtA) - i, nil return len(dAtA) - i, nil
} }
func (m *Metadata) 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 *Metadata) MarshalTo(dAtA []byte) (int, error) {
size := m.Size()
return m.MarshalToSizedBuffer(dAtA[:size])
}
func (m *Metadata) MarshalToSizedBuffer(dAtA []byte) (int, error) {
i := len(dAtA)
_ = i
var l int
_ = l
if len(m.AdditionalDataCID) > 0 {
i -= len(m.AdditionalDataCID)
copy(dAtA[i:], m.AdditionalDataCID)
i = encodeVarintMachine(dAtA, i, uint64(len(m.AdditionalDataCID)))
i--
dAtA[i] = 0x22
}
if len(m.AssetDefinition) > 0 {
for k := range m.AssetDefinition {
v := m.AssetDefinition[k]
baseI := i
i -= len(v)
copy(dAtA[i:], v)
i = encodeVarintMachine(dAtA, i, uint64(len(v)))
i--
dAtA[i] = 0x12
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintMachine(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintMachine(dAtA, i, uint64(baseI-i))
i--
dAtA[i] = 0x1a
}
}
if len(m.Device) > 0 {
for k := range m.Device {
v := m.Device[k]
baseI := i
i -= len(v)
copy(dAtA[i:], v)
i = encodeVarintMachine(dAtA, i, uint64(len(v)))
i--
dAtA[i] = 0x12
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintMachine(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintMachine(dAtA, i, uint64(baseI-i))
i--
dAtA[i] = 0x12
}
}
if len(m.Gps) > 0 {
for k := range m.Gps {
v := m.Gps[k]
baseI := i
i -= len(v)
copy(dAtA[i:], v)
i = encodeVarintMachine(dAtA, i, uint64(len(v)))
i--
dAtA[i] = 0x12
i -= len(k)
copy(dAtA[i:], k)
i = encodeVarintMachine(dAtA, i, uint64(len(k)))
i--
dAtA[i] = 0xa
i = encodeVarintMachine(dAtA, i, uint64(baseI-i))
i--
dAtA[i] = 0xa
}
}
return len(dAtA) - i, nil
}
func encodeVarintMachine(dAtA []byte, offset int, v uint64) int { func encodeVarintMachine(dAtA []byte, offset int, v uint64) int {
offset -= sovMachine(v) offset -= sovMachine(v)
base := offset base := offset
@ -237,6 +442,9 @@ func (m *Machine) Size() (n int) {
if m.Issued != 0 { if m.Issued != 0 {
n += 1 + sovMachine(uint64(m.Issued)) n += 1 + sovMachine(uint64(m.Issued))
} }
if m.Amount != 0 {
n += 1 + sovMachine(uint64(m.Amount))
}
if m.Precision != 0 { if m.Precision != 0 {
n += 1 + sovMachine(uint64(m.Precision)) n += 1 + sovMachine(uint64(m.Precision))
} }
@ -248,7 +456,48 @@ func (m *Machine) Size() (n int) {
if l > 0 { if l > 0 {
n += 1 + l + sovMachine(uint64(l)) n += 1 + l + sovMachine(uint64(l))
} }
l = len(m.Cid) l = len(m.MachineId)
if l > 0 {
n += 1 + l + sovMachine(uint64(l))
}
if m.Metadata != nil {
l = m.Metadata.Size()
n += 1 + l + sovMachine(uint64(l))
}
return n
}
func (m *Metadata) Size() (n int) {
if m == nil {
return 0
}
var l int
_ = l
if len(m.Gps) > 0 {
for k, v := range m.Gps {
_ = k
_ = v
mapEntrySize := 1 + len(k) + sovMachine(uint64(len(k))) + 1 + len(v) + sovMachine(uint64(len(v)))
n += mapEntrySize + 1 + sovMachine(uint64(mapEntrySize))
}
}
if len(m.Device) > 0 {
for k, v := range m.Device {
_ = k
_ = v
mapEntrySize := 1 + len(k) + sovMachine(uint64(len(k))) + 1 + len(v) + sovMachine(uint64(len(v)))
n += mapEntrySize + 1 + sovMachine(uint64(mapEntrySize))
}
}
if len(m.AssetDefinition) > 0 {
for k, v := range m.AssetDefinition {
_ = k
_ = v
mapEntrySize := 1 + len(k) + sovMachine(uint64(len(k))) + 1 + len(v) + sovMachine(uint64(len(v)))
n += mapEntrySize + 1 + sovMachine(uint64(mapEntrySize))
}
}
l = len(m.AdditionalDataCID)
if l > 0 { if l > 0 {
n += 1 + l + sovMachine(uint64(l)) n += 1 + l + sovMachine(uint64(l))
} }
@ -374,6 +623,25 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
} }
} }
case 4: case 4:
if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Amount", wireType)
}
m.Amount = 0
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
m.Amount |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
case 5:
if wireType != 0 { if wireType != 0 {
return fmt.Errorf("proto: wrong wireType = %d for field Precision", wireType) return fmt.Errorf("proto: wrong wireType = %d for field Precision", wireType)
} }
@ -392,7 +660,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
break break
} }
} }
case 5: case 6:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IssuerPlanetmint", wireType) return fmt.Errorf("proto: wrong wireType = %d for field IssuerPlanetmint", wireType)
} }
@ -424,7 +692,7 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
} }
m.IssuerPlanetmint = string(dAtA[iNdEx:postIndex]) m.IssuerPlanetmint = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 6: case 7:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field IssuerLiquid", wireType) return fmt.Errorf("proto: wrong wireType = %d for field IssuerLiquid", wireType)
} }
@ -456,9 +724,9 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
} }
m.IssuerLiquid = string(dAtA[iNdEx:postIndex]) m.IssuerLiquid = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
case 7: case 8:
if wireType != 2 { if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Cid", wireType) return fmt.Errorf("proto: wrong wireType = %d for field MachineId", wireType)
} }
var stringLen uint64 var stringLen uint64
for shift := uint(0); ; shift += 7 { for shift := uint(0); ; shift += 7 {
@ -486,7 +754,506 @@ func (m *Machine) Unmarshal(dAtA []byte) error {
if postIndex > l { if postIndex > l {
return io.ErrUnexpectedEOF return io.ErrUnexpectedEOF
} }
m.Cid = string(dAtA[iNdEx:postIndex]) m.MachineId = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex
case 9:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Metadata", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthMachine
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMachine
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Metadata == nil {
m.Metadata = &Metadata{}
}
if err := m.Metadata.Unmarshal(dAtA[iNdEx:postIndex]); err != nil {
return err
}
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 (m *Metadata) 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: Metadata: wiretype end group for non-group")
}
if fieldNum <= 0 {
return fmt.Errorf("proto: Metadata: illegal tag %d (wire type %d)", fieldNum, wire)
}
switch fieldNum {
case 1:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Gps", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthMachine
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMachine
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Gps == nil {
m.Gps = make(map[string]string)
}
var mapkey string
var mapvalue string
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var stringLenmapvalue uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapvalue := int(stringLenmapvalue)
if intStringLenmapvalue < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF
}
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
iNdEx = postStringIndexmapvalue
} else {
iNdEx = entryPreIndex
skippy, err := skipMachine(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthMachine
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Gps[mapkey] = mapvalue
iNdEx = postIndex
case 2:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field Device", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthMachine
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMachine
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.Device == nil {
m.Device = make(map[string]string)
}
var mapkey string
var mapvalue string
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var stringLenmapvalue uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapvalue := int(stringLenmapvalue)
if intStringLenmapvalue < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF
}
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
iNdEx = postStringIndexmapvalue
} else {
iNdEx = entryPreIndex
skippy, err := skipMachine(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthMachine
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.Device[mapkey] = mapvalue
iNdEx = postIndex
case 3:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AssetDefinition", wireType)
}
var msglen int
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
msglen |= int(b&0x7F) << shift
if b < 0x80 {
break
}
}
if msglen < 0 {
return ErrInvalidLengthMachine
}
postIndex := iNdEx + msglen
if postIndex < 0 {
return ErrInvalidLengthMachine
}
if postIndex > l {
return io.ErrUnexpectedEOF
}
if m.AssetDefinition == nil {
m.AssetDefinition = make(map[string]string)
}
var mapkey string
var mapvalue string
for iNdEx < postIndex {
entryPreIndex := iNdEx
var wire uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
wire |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
fieldNum := int32(wire >> 3)
if fieldNum == 1 {
var stringLenmapkey uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapkey |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapkey := int(stringLenmapkey)
if intStringLenmapkey < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapkey := iNdEx + intStringLenmapkey
if postStringIndexmapkey < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapkey > l {
return io.ErrUnexpectedEOF
}
mapkey = string(dAtA[iNdEx:postStringIndexmapkey])
iNdEx = postStringIndexmapkey
} else if fieldNum == 2 {
var stringLenmapvalue uint64
for shift := uint(0); ; shift += 7 {
if shift >= 64 {
return ErrIntOverflowMachine
}
if iNdEx >= l {
return io.ErrUnexpectedEOF
}
b := dAtA[iNdEx]
iNdEx++
stringLenmapvalue |= uint64(b&0x7F) << shift
if b < 0x80 {
break
}
}
intStringLenmapvalue := int(stringLenmapvalue)
if intStringLenmapvalue < 0 {
return ErrInvalidLengthMachine
}
postStringIndexmapvalue := iNdEx + intStringLenmapvalue
if postStringIndexmapvalue < 0 {
return ErrInvalidLengthMachine
}
if postStringIndexmapvalue > l {
return io.ErrUnexpectedEOF
}
mapvalue = string(dAtA[iNdEx:postStringIndexmapvalue])
iNdEx = postStringIndexmapvalue
} else {
iNdEx = entryPreIndex
skippy, err := skipMachine(dAtA[iNdEx:])
if err != nil {
return err
}
if (skippy < 0) || (iNdEx+skippy) < 0 {
return ErrInvalidLengthMachine
}
if (iNdEx + skippy) > postIndex {
return io.ErrUnexpectedEOF
}
iNdEx += skippy
}
}
m.AssetDefinition[mapkey] = mapvalue
iNdEx = postIndex
case 4:
if wireType != 2 {
return fmt.Errorf("proto: wrong wireType = %d for field AdditionalDataCID", 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.AdditionalDataCID = string(dAtA[iNdEx:postIndex])
iNdEx = postIndex iNdEx = postIndex
default: default:
iNdEx = preIndex iNdEx = preIndex