github.com/annchain/OG@v0.0.9/p2p/enr/enr_gen.go (about) 1 package enr 2 3 // Code generated by github.com/tinylib/msgp DO NOT EDIT. 4 5 import ( 6 "github.com/tinylib/msgp/msgp" 7 ) 8 9 // DecodeMsg implements msgp.Decodable 10 func (z *Pair) DecodeMsg(dc *msgp.Reader) (err error) { 11 var zb0001 uint32 12 zb0001, err = dc.ReadArrayHeader() 13 if err != nil { 14 return 15 } 16 if zb0001 != 2 { 17 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 18 return 19 } 20 z.K, err = dc.ReadString() 21 if err != nil { 22 return 23 } 24 z.V, err = dc.ReadBytes(z.V) 25 if err != nil { 26 return 27 } 28 return 29 } 30 31 // EncodeMsg implements msgp.Encodable 32 func (z *Pair) EncodeMsg(en *msgp.Writer) (err error) { 33 // array header, size 2 34 err = en.Append(0x92) 35 if err != nil { 36 return 37 } 38 err = en.WriteString(z.K) 39 if err != nil { 40 return 41 } 42 err = en.WriteBytes(z.V) 43 if err != nil { 44 return 45 } 46 return 47 } 48 49 // MarshalMsg implements msgp.Marshaler 50 func (z *Pair) MarshalMsg(b []byte) (o []byte, err error) { 51 o = msgp.Require(b, z.Msgsize()) 52 // array header, size 2 53 o = append(o, 0x92) 54 o = msgp.AppendString(o, z.K) 55 o = msgp.AppendBytes(o, z.V) 56 return 57 } 58 59 // UnmarshalMsg implements msgp.Unmarshaler 60 func (z *Pair) UnmarshalMsg(bts []byte) (o []byte, err error) { 61 var zb0001 uint32 62 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 63 if err != nil { 64 return 65 } 66 if zb0001 != 2 { 67 err = msgp.ArrayError{Wanted: 2, Got: zb0001} 68 return 69 } 70 z.K, bts, err = msgp.ReadStringBytes(bts) 71 if err != nil { 72 return 73 } 74 z.V, bts, err = msgp.ReadBytesBytes(bts, z.V) 75 if err != nil { 76 return 77 } 78 o = bts 79 return 80 } 81 82 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 83 func (z *Pair) Msgsize() (s int) { 84 s = 1 + msgp.StringPrefixSize + len(z.K) + msgp.BytesPrefixSize + len(z.V) 85 return 86 } 87 88 // DecodeMsg implements msgp.Decodable 89 func (z *Record) DecodeMsg(dc *msgp.Reader) (err error) { 90 var zb0001 uint32 91 zb0001, err = dc.ReadArrayHeader() 92 if err != nil { 93 return 94 } 95 if zb0001 != 3 { 96 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 97 return 98 } 99 z.Seq, err = dc.ReadUint64() 100 if err != nil { 101 return 102 } 103 z.Signature, err = dc.ReadBytes(z.Signature) 104 if err != nil { 105 return 106 } 107 var zb0002 uint32 108 zb0002, err = dc.ReadArrayHeader() 109 if err != nil { 110 return 111 } 112 if cap(z.Pairs) >= int(zb0002) { 113 z.Pairs = (z.Pairs)[:zb0002] 114 } else { 115 z.Pairs = make([]Pair, zb0002) 116 } 117 for za0001 := range z.Pairs { 118 var zb0003 uint32 119 zb0003, err = dc.ReadArrayHeader() 120 if err != nil { 121 return 122 } 123 if zb0003 != 2 { 124 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 125 return 126 } 127 z.Pairs[za0001].K, err = dc.ReadString() 128 if err != nil { 129 return 130 } 131 z.Pairs[za0001].V, err = dc.ReadBytes(z.Pairs[za0001].V) 132 if err != nil { 133 return 134 } 135 } 136 return 137 } 138 139 // EncodeMsg implements msgp.Encodable 140 func (z *Record) EncodeMsg(en *msgp.Writer) (err error) { 141 // array header, size 3 142 err = en.Append(0x93) 143 if err != nil { 144 return 145 } 146 err = en.WriteUint64(z.Seq) 147 if err != nil { 148 return 149 } 150 err = en.WriteBytes(z.Signature) 151 if err != nil { 152 return 153 } 154 err = en.WriteArrayHeader(uint32(len(z.Pairs))) 155 if err != nil { 156 return 157 } 158 for za0001 := range z.Pairs { 159 // array header, size 2 160 err = en.Append(0x92) 161 if err != nil { 162 return 163 } 164 err = en.WriteString(z.Pairs[za0001].K) 165 if err != nil { 166 return 167 } 168 err = en.WriteBytes(z.Pairs[za0001].V) 169 if err != nil { 170 return 171 } 172 } 173 return 174 } 175 176 // MarshalMsg implements msgp.Marshaler 177 func (z *Record) MarshalMsg(b []byte) (o []byte, err error) { 178 o = msgp.Require(b, z.Msgsize()) 179 // array header, size 3 180 o = append(o, 0x93) 181 o = msgp.AppendUint64(o, z.Seq) 182 o = msgp.AppendBytes(o, z.Signature) 183 o = msgp.AppendArrayHeader(o, uint32(len(z.Pairs))) 184 for za0001 := range z.Pairs { 185 // array header, size 2 186 o = append(o, 0x92) 187 o = msgp.AppendString(o, z.Pairs[za0001].K) 188 o = msgp.AppendBytes(o, z.Pairs[za0001].V) 189 } 190 return 191 } 192 193 // UnmarshalMsg implements msgp.Unmarshaler 194 func (z *Record) UnmarshalMsg(bts []byte) (o []byte, err error) { 195 var zb0001 uint32 196 zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts) 197 if err != nil { 198 return 199 } 200 if zb0001 != 3 { 201 err = msgp.ArrayError{Wanted: 3, Got: zb0001} 202 return 203 } 204 z.Seq, bts, err = msgp.ReadUint64Bytes(bts) 205 if err != nil { 206 return 207 } 208 z.Signature, bts, err = msgp.ReadBytesBytes(bts, z.Signature) 209 if err != nil { 210 return 211 } 212 var zb0002 uint32 213 zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts) 214 if err != nil { 215 return 216 } 217 if cap(z.Pairs) >= int(zb0002) { 218 z.Pairs = (z.Pairs)[:zb0002] 219 } else { 220 z.Pairs = make([]Pair, zb0002) 221 } 222 for za0001 := range z.Pairs { 223 var zb0003 uint32 224 zb0003, bts, err = msgp.ReadArrayHeaderBytes(bts) 225 if err != nil { 226 return 227 } 228 if zb0003 != 2 { 229 err = msgp.ArrayError{Wanted: 2, Got: zb0003} 230 return 231 } 232 z.Pairs[za0001].K, bts, err = msgp.ReadStringBytes(bts) 233 if err != nil { 234 return 235 } 236 z.Pairs[za0001].V, bts, err = msgp.ReadBytesBytes(bts, z.Pairs[za0001].V) 237 if err != nil { 238 return 239 } 240 } 241 o = bts 242 return 243 } 244 245 // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message 246 func (z *Record) Msgsize() (s int) { 247 s = 1 + msgp.Uint64Size + msgp.BytesPrefixSize + len(z.Signature) + msgp.ArrayHeaderSize 248 for za0001 := range z.Pairs { 249 s += 1 + msgp.StringPrefixSize + len(z.Pairs[za0001].K) + msgp.BytesPrefixSize + len(z.Pairs[za0001].V) 250 } 251 return 252 }