package minersc

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

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

// MarshalMsg implements msgp.Marshaler
func (z *DKGMinerNodesV2) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 12
	// string "mn"
	o = append(o, 0x8c, 0xa2, 0x6d, 0x6e)
	o = msgp.AppendInt(o, z.MinN)
	// string "mx"
	o = append(o, 0xa2, 0x6d, 0x78)
	o = msgp.AppendInt(o, z.MaxN)
	// string "tp"
	o = append(o, 0xa2, 0x74, 0x70)
	o = msgp.AppendFloat64(o, z.TPercent)
	// string "kp"
	o = append(o, 0xa2, 0x6b, 0x70)
	o = msgp.AppendFloat64(o, z.KPercent)
	// string "nd"
	o = append(o, 0xa2, 0x6e, 0x64)
	o = msgp.AppendArrayHeader(o, uint32(len(z.Nodes)))
	for za0001 := range z.Nodes {
		// map header, size 2
		// string "k"
		o = append(o, 0x82, 0xa1, 0x6b)
		o = msgp.AppendString(o, z.Nodes[za0001].Key)
		// string "p"
		o = append(o, 0xa1, 0x70)
		o = msgp.AppendString(o, z.Nodes[za0001].PublicKey)
	}
	// string "t"
	o = append(o, 0xa1, 0x74)
	o = msgp.AppendInt(o, z.T)
	// string "k"
	o = append(o, 0xa1, 0x6b)
	o = msgp.AppendInt(o, z.K)
	// string "n"
	o = append(o, 0xa1, 0x6e)
	o = msgp.AppendInt(o, z.N)
	// string "xp"
	o = append(o, 0xa2, 0x78, 0x70)
	o = msgp.AppendFloat64(o, z.XPercent)
	// string "rs"
	o = append(o, 0xa2, 0x72, 0x73)
	o = msgp.AppendMapHeader(o, uint32(len(z.RevealedShares)))
	keys_za0002 := make([]string, 0, len(z.RevealedShares))
	for k := range z.RevealedShares {
		keys_za0002 = append(keys_za0002, k)
	}
	msgp.Sort(keys_za0002)
	for _, k := range keys_za0002 {
		za0003 := z.RevealedShares[k]
		o = msgp.AppendString(o, k)
		o = msgp.AppendInt(o, za0003)
	}
	// string "w"
	o = append(o, 0xa1, 0x77)
	o = msgp.AppendMapHeader(o, uint32(len(z.Waited)))
	keys_za0004 := make([]string, 0, len(z.Waited))
	for k := range z.Waited {
		keys_za0004 = append(keys_za0004, k)
	}
	msgp.Sort(keys_za0004)
	for _, k := range keys_za0004 {
		za0005 := z.Waited[k]
		o = msgp.AppendString(o, k)
		o = msgp.AppendBool(o, za0005)
	}
	// string "sr"
	o = append(o, 0xa2, 0x73, 0x72)
	o = msgp.AppendInt64(o, z.StartRound)
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *DKGMinerNodesV2) 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 "mn":
			z.MinN, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "MinN")
				return
			}
		case "mx":
			z.MaxN, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "MaxN")
				return
			}
		case "tp":
			z.TPercent, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "TPercent")
				return
			}
		case "kp":
			z.KPercent, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "KPercent")
				return
			}
		case "nd":
			var zb0002 uint32
			zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Nodes")
				return
			}
			if cap(z.Nodes) >= int(zb0002) {
				z.Nodes = (z.Nodes)[:zb0002]
			} else {
				z.Nodes = make([]LightNode, zb0002)
			}
			for za0001 := range z.Nodes {
				var zb0003 uint32
				zb0003, bts, err = msgp.ReadMapHeaderBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Nodes", za0001)
					return
				}
				for zb0003 > 0 {
					zb0003--
					field, bts, err = msgp.ReadMapKeyZC(bts)
					if err != nil {
						err = msgp.WrapError(err, "Nodes", za0001)
						return
					}
					switch msgp.UnsafeString(field) {
					case "k":
						z.Nodes[za0001].Key, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							err = msgp.WrapError(err, "Nodes", za0001, "Key")
							return
						}
					case "p":
						z.Nodes[za0001].PublicKey, bts, err = msgp.ReadStringBytes(bts)
						if err != nil {
							err = msgp.WrapError(err, "Nodes", za0001, "PublicKey")
							return
						}
					default:
						bts, err = msgp.Skip(bts)
						if err != nil {
							err = msgp.WrapError(err, "Nodes", za0001)
							return
						}
					}
				}
			}
		case "t":
			z.T, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "T")
				return
			}
		case "k":
			z.K, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "K")
				return
			}
		case "n":
			z.N, bts, err = msgp.ReadIntBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "N")
				return
			}
		case "xp":
			z.XPercent, bts, err = msgp.ReadFloat64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "XPercent")
				return
			}
		case "rs":
			var zb0004 uint32
			zb0004, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "RevealedShares")
				return
			}
			if z.RevealedShares == nil {
				z.RevealedShares = make(map[string]int, zb0004)
			} else if len(z.RevealedShares) > 0 {
				for key := range z.RevealedShares {
					delete(z.RevealedShares, key)
				}
			}
			for zb0004 > 0 {
				var za0002 string
				var za0003 int
				zb0004--
				za0002, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "RevealedShares")
					return
				}
				za0003, bts, err = msgp.ReadIntBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "RevealedShares", za0002)
					return
				}
				z.RevealedShares[za0002] = za0003
			}
		case "w":
			var zb0005 uint32
			zb0005, bts, err = msgp.ReadMapHeaderBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Waited")
				return
			}
			if z.Waited == nil {
				z.Waited = make(map[string]bool, zb0005)
			} else if len(z.Waited) > 0 {
				for key := range z.Waited {
					delete(z.Waited, key)
				}
			}
			for zb0005 > 0 {
				var za0004 string
				var za0005 bool
				zb0005--
				za0004, bts, err = msgp.ReadStringBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Waited")
					return
				}
				za0005, bts, err = msgp.ReadBoolBytes(bts)
				if err != nil {
					err = msgp.WrapError(err, "Waited", za0004)
					return
				}
				z.Waited[za0004] = za0005
			}
		case "sr":
			z.StartRound, bts, err = msgp.ReadInt64Bytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "StartRound")
				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 *DKGMinerNodesV2) Msgsize() (s int) {
	s = 1 + 3 + msgp.IntSize + 3 + msgp.IntSize + 3 + msgp.Float64Size + 3 + msgp.Float64Size + 3 + msgp.ArrayHeaderSize
	for za0001 := range z.Nodes {
		s += 1 + 2 + msgp.StringPrefixSize + len(z.Nodes[za0001].Key) + 2 + msgp.StringPrefixSize + len(z.Nodes[za0001].PublicKey)
	}
	s += 2 + msgp.IntSize + 2 + msgp.IntSize + 2 + msgp.IntSize + 3 + msgp.Float64Size + 3 + msgp.MapHeaderSize
	if z.RevealedShares != nil {
		for za0002, za0003 := range z.RevealedShares {
			_ = za0003
			s += msgp.StringPrefixSize + len(za0002) + msgp.IntSize
		}
	}
	s += 2 + msgp.MapHeaderSize
	if z.Waited != nil {
		for za0004, za0005 := range z.Waited {
			_ = za0005
			s += msgp.StringPrefixSize + len(za0004) + msgp.BoolSize
		}
	}
	s += 3 + msgp.Int64Size
	return
}

// MarshalMsg implements msgp.Marshaler
func (z *LightMinerNode) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 1
	// string "SimpleNode"
	o = append(o, 0x81, 0xaa, 0x53, 0x69, 0x6d, 0x70, 0x6c, 0x65, 0x4e, 0x6f, 0x64, 0x65)
	if z.SimpleNode == nil {
		o = msgp.AppendNil(o)
	} else {
		o, err = z.SimpleNode.MarshalMsg(o)
		if err != nil {
			err = msgp.WrapError(err, "SimpleNode")
			return
		}
	}
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *LightMinerNode) 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 "SimpleNode":
			if msgp.IsNil(bts) {
				bts, err = msgp.ReadNilBytes(bts)
				if err != nil {
					return
				}
				z.SimpleNode = nil
			} else {
				if z.SimpleNode == nil {
					z.SimpleNode = new(SimpleNode)
				}
				bts, err = z.SimpleNode.UnmarshalMsg(bts)
				if err != nil {
					err = msgp.WrapError(err, "SimpleNode")
					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 *LightMinerNode) Msgsize() (s int) {
	s = 1 + 11
	if z.SimpleNode == nil {
		s += msgp.NilSize
	} else {
		s += z.SimpleNode.Msgsize()
	}
	return
}

// MarshalMsg implements msgp.Marshaler
func (z LightNode) MarshalMsg(b []byte) (o []byte, err error) {
	o = msgp.Require(b, z.Msgsize())
	// map header, size 2
	// string "k"
	o = append(o, 0x82, 0xa1, 0x6b)
	o = msgp.AppendString(o, z.Key)
	// string "p"
	o = append(o, 0xa1, 0x70)
	o = msgp.AppendString(o, z.PublicKey)
	return
}

// UnmarshalMsg implements msgp.Unmarshaler
func (z *LightNode) 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 "k":
			z.Key, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "Key")
				return
			}
		case "p":
			z.PublicKey, bts, err = msgp.ReadStringBytes(bts)
			if err != nil {
				err = msgp.WrapError(err, "PublicKey")
				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 LightNode) Msgsize() (s int) {
	s = 1 + 2 + msgp.StringPrefixSize + len(z.Key) + 2 + msgp.StringPrefixSize + len(z.PublicKey)
	return
}
