package block

// Code generated by github.com/tinylib/msgp DO NOT EDIT.

import (
	"github.com/tinylib/msgp/msgp"
)

// MarshalMsg implements msgp.Marshaler
func (z *MPK) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 2
	// string "ID"
	o = append(o, 0x82, 0xa2, 0x49, 0x44)
	o = msgp.AppendString(o, z.ID)
	// string "Mpk"
	o = append(o, 0xa3, 0x4d, 0x70, 0x6b)
	o = msgp.AppendArrayHeader(o, uint32(len(z.Mpk)))
	for za0001 := range z.Mpk {
		o = msgp.AppendString(o, z.Mpk[za0001])
	}
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *MPK) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zb0001 uint32
	zb0001, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	for zb0001 > 0 {
		zb0001--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		switch msgp.UnsafeString(field) {
		case "ID":
			z.ID, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "ID")
				return
			}
		case "Mpk":
			var zb0002 uint32
			zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Mpk")
				return
			}
			if cap(z.Mpk) >= int(zb0002) {
				z.Mpk = (z.Mpk)[:zb0002]
			} else {
				z.Mpk = make([]string, zb0002)
			}
			for za0001 := range z.Mpk {
				z.Mpk[za0001], bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Mpk", za0001)
					return
				}
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	o = bts
	return
}

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *MPK) Msgsize() (s int) {
	s = 1 + 3 + msgp.StringPrefixSize + len(z.ID) + 4 + msgp.ArrayHeaderSize
	for za0001 := range z.Mpk {
		s += msgp.StringPrefixSize + len(z.Mpk[za0001])
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z *Mpks) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 1
	// string "Mpks"
	o = append(o, 0x81, 0xa4, 0x4d, 0x70, 0x6b, 0x73)
	o = msgp.AppendMapHeader(o, uint32(len(z.Mpks)))
	keys_za0001 := make([]string, 0, len(z.Mpks))
	for k := range z.Mpks {
		keys_za0001 = append(keys_za0001, k)
	}
	msgp.Sort(keys_za0001)
	for _, k := range keys_za0001 {
		za0002 := z.Mpks[k]
		o = msgp.AppendString(o, k)
		if za0002 == nil {
			o = msgp.AppendNil(o)
		} else {
			// map header, size 2
			// string "ID"
			o = append(o, 0x82, 0xa2, 0x49, 0x44)
			o = msgp.AppendString(o, za0002.ID)
			// string "Mpk"
			o = append(o, 0xa3, 0x4d, 0x70, 0x6b)
			o = msgp.AppendArrayHeader(o, uint32(len(za0002.Mpk)))
			for za0003 := range za0002.Mpk {
				o = msgp.AppendString(o, za0002.Mpk[za0003])
			}
		}
	}
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *Mpks) UnmarshalMsg(bts []byte) (o []byte, err error) {
	var field []byte
	_ = field
	var zb0001 uint32
	zb0001, bts, err = msgp.ReadMapHeaderBytes(bts)
	if err != nil {
		err = msgp.WrapError(err)
		return
	}
	for zb0001 > 0 {
		zb0001--
		field, bts, err = msgp.ReadMapKeyZC(bts)
		if err != nil {
			err = msgp.WrapError(err)
			return
		}
		switch msgp.UnsafeString(field) {
		case "Mpks":
			var zb0002 uint32
			zb0002, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Mpks")
				return
			}
			if z.Mpks == nil {
				z.Mpks = make(map[string]*MPK, zb0002)
			} else if len(z.Mpks) > 0 {
				for key := range z.Mpks {
					delete(z.Mpks, key)
				}
			}
			for zb0002 > 0 {
				var za0001 string
				var za0002 *MPK
				zb0002--
				za0001, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Mpks")
					return
				}
				if msgp.IsNil(bts) {
					bts, err = msgp.ReadNilBytes(bts)
					if err != nil {
						return
					}
					za0002 = nil
				} else {
					if za0002 == nil {
						za0002 = new(MPK)
					}
					var zb0003 uint32
					zb0003, bts, err = msgp.ReadMapHeaderBytes(bts)
					if err != nil {
						err = msgp.WrapError(err, "Mpks", za0001)
						return
					}
					for zb0003 > 0 {
						zb0003--
						field, bts, err = msgp.ReadMapKeyZC(bts)
						if err != nil {
							err = msgp.WrapError(err, "Mpks", za0001)
							return
						}
						switch msgp.UnsafeString(field) {
						case "ID":
							za0002.ID, bts, err = msgp.ReadStringBytes(bts)
							if err != nil {
								err = msgp.WrapError(err, "Mpks", za0001, "ID")
								return
							}
						case "Mpk":
							var zb0004 uint32
							zb0004, bts, err = msgp.ReadArrayHeaderBytes(bts)
							if err != nil {
								err = msgp.WrapError(err, "Mpks", za0001, "Mpk")
								return
							}
							if cap(za0002.Mpk) >= int(zb0004) {
								za0002.Mpk = (za0002.Mpk)[:zb0004]
							} else {
								za0002.Mpk = make([]string, zb0004)
							}
							for za0003 := range za0002.Mpk {
								za0002.Mpk[za0003], bts, err = msgp.ReadStringBytes(bts)
								if err != nil {
									err = msgp.WrapError(err, "Mpks", za0001, "Mpk", za0003)
									return
								}
							}
						default:
							bts, err = msgp.Skip(bts)
							if err != nil {
								err = msgp.WrapError(err, "Mpks", za0001)
								return
							}
						}
					}
				}
				z.Mpks[za0001] = za0002
			}
		default:
			bts, err = msgp.Skip(bts)
			if err != nil {
				err = msgp.WrapError(err)
				return
			}
		}
	}
	o = bts
	return
}

// Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (z *Mpks) Msgsize() (s int) {
	s = 1 + 5 + msgp.MapHeaderSize
	if z.Mpks != nil {
		for za0001, za0002 := range z.Mpks {
			_ = za0002
			s += msgp.StringPrefixSize + len(za0001)
			if za0002 == nil {
				s += msgp.NilSize
			} else {
				s += 1 + 3 + msgp.StringPrefixSize + len(za0002.ID) + 4 + msgp.ArrayHeaderSize
				for za0003 := range za0002.Mpk {
					s += msgp.StringPrefixSize + len(za0002.Mpk[za0003])
				}
			}
		}
	}
	return
}
