github.com/annchain/OG@v0.0.9/p2p/discv5/node_gen.go (about)

     1  package discv5
     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 *Node) 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 != 4 {
    17  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
    18  		return
    19  	}
    20  	z.IP, err = dc.ReadBytes(z.IP)
    21  	if err != nil {
    22  		return
    23  	}
    24  	z.UDP, err = dc.ReadUint16()
    25  	if err != nil {
    26  		return
    27  	}
    28  	z.TCP, err = dc.ReadUint16()
    29  	if err != nil {
    30  		return
    31  	}
    32  	err = dc.ReadExactBytes((z.ID)[:])
    33  	if err != nil {
    34  		return
    35  	}
    36  	return
    37  }
    38  
    39  // EncodeMsg implements msgp.Encodable
    40  func (z *Node) EncodeMsg(en *msgp.Writer) (err error) {
    41  	// array header, size 4
    42  	err = en.Append(0x94)
    43  	if err != nil {
    44  		return
    45  	}
    46  	err = en.WriteBytes(z.IP)
    47  	if err != nil {
    48  		return
    49  	}
    50  	err = en.WriteUint16(z.UDP)
    51  	if err != nil {
    52  		return
    53  	}
    54  	err = en.WriteUint16(z.TCP)
    55  	if err != nil {
    56  		return
    57  	}
    58  	err = en.WriteBytes((z.ID)[:])
    59  	if err != nil {
    60  		return
    61  	}
    62  	return
    63  }
    64  
    65  // MarshalMsg implements msgp.Marshaler
    66  func (z *Node) MarshalMsg(b []byte) (o []byte, err error) {
    67  	o = msgp.Require(b, z.Msgsize())
    68  	// array header, size 4
    69  	o = append(o, 0x94)
    70  	o = msgp.AppendBytes(o, z.IP)
    71  	o = msgp.AppendUint16(o, z.UDP)
    72  	o = msgp.AppendUint16(o, z.TCP)
    73  	o = msgp.AppendBytes(o, (z.ID)[:])
    74  	return
    75  }
    76  
    77  // UnmarshalMsg implements msgp.Unmarshaler
    78  func (z *Node) UnmarshalMsg(bts []byte) (o []byte, err error) {
    79  	var zb0001 uint32
    80  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
    81  	if err != nil {
    82  		return
    83  	}
    84  	if zb0001 != 4 {
    85  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
    86  		return
    87  	}
    88  	z.IP, bts, err = msgp.ReadBytesBytes(bts, z.IP)
    89  	if err != nil {
    90  		return
    91  	}
    92  	z.UDP, bts, err = msgp.ReadUint16Bytes(bts)
    93  	if err != nil {
    94  		return
    95  	}
    96  	z.TCP, bts, err = msgp.ReadUint16Bytes(bts)
    97  	if err != nil {
    98  		return
    99  	}
   100  	bts, err = msgp.ReadExactBytes(bts, (z.ID)[:])
   101  	if err != nil {
   102  		return
   103  	}
   104  	o = bts
   105  	return
   106  }
   107  
   108  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   109  func (z *Node) Msgsize() (s int) {
   110  	s = 1 + msgp.BytesPrefixSize + len(z.IP) + msgp.Uint16Size + msgp.Uint16Size + msgp.ArrayHeaderSize + (64 * (msgp.ByteSize))
   111  	return
   112  }