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

     1  package p2p
     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 *RawHandshakeMsg) 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 != 3 {
    17  		err = msgp.ArrayError{Wanted: 3, Got: zb0001}
    18  		return
    19  	}
    20  	err = dc.ReadExactBytes((z.Signature)[:])
    21  	if err != nil {
    22  		return
    23  	}
    24  	err = dc.ReadExactBytes((z.Nonce)[:])
    25  	if err != nil {
    26  		return
    27  	}
    28  	z.Version, err = dc.ReadUint32()
    29  	if err != nil {
    30  		return
    31  	}
    32  	return
    33  }
    34  
    35  // EncodeMsg implements msgp.Encodable
    36  func (z *RawHandshakeMsg) EncodeMsg(en *msgp.Writer) (err error) {
    37  	// array header, size 3
    38  	err = en.Append(0x93)
    39  	if err != nil {
    40  		return
    41  	}
    42  	err = en.WriteBytes((z.Signature)[:])
    43  	if err != nil {
    44  		return
    45  	}
    46  	err = en.WriteBytes((z.Nonce)[:])
    47  	if err != nil {
    48  		return
    49  	}
    50  	err = en.WriteUint32(z.Version)
    51  	if err != nil {
    52  		return
    53  	}
    54  	return
    55  }
    56  
    57  // MarshalMsg implements msgp.Marshaler
    58  func (z *RawHandshakeMsg) MarshalMsg(b []byte) (o []byte, err error) {
    59  	o = msgp.Require(b, z.Msgsize())
    60  	// array header, size 3
    61  	o = append(o, 0x93)
    62  	o = msgp.AppendBytes(o, (z.Signature)[:])
    63  	o = msgp.AppendBytes(o, (z.Nonce)[:])
    64  	o = msgp.AppendUint32(o, z.Version)
    65  	return
    66  }
    67  
    68  // UnmarshalMsg implements msgp.Unmarshaler
    69  func (z *RawHandshakeMsg) UnmarshalMsg(bts []byte) (o []byte, err error) {
    70  	var zb0001 uint32
    71  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
    72  	if err != nil {
    73  		return
    74  	}
    75  	if zb0001 != 3 {
    76  		err = msgp.ArrayError{Wanted: 3, Got: zb0001}
    77  		return
    78  	}
    79  	bts, err = msgp.ReadExactBytes(bts, (z.Signature)[:])
    80  	if err != nil {
    81  		return
    82  	}
    83  	bts, err = msgp.ReadExactBytes(bts, (z.Nonce)[:])
    84  	if err != nil {
    85  		return
    86  	}
    87  	z.Version, bts, err = msgp.ReadUint32Bytes(bts)
    88  	if err != nil {
    89  		return
    90  	}
    91  	o = bts
    92  	return
    93  }
    94  
    95  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
    96  func (z *RawHandshakeMsg) Msgsize() (s int) {
    97  	s = 1 + msgp.ArrayHeaderSize + (sigLen * (msgp.ByteSize)) + msgp.ArrayHeaderSize + (shaLen * (msgp.ByteSize)) + msgp.Uint32Size
    98  	return
    99  }
   100  
   101  // DecodeMsg implements msgp.Decodable
   102  func (z *RawHandshakeResponseMsg) DecodeMsg(dc *msgp.Reader) (err error) {
   103  	var zb0001 uint32
   104  	zb0001, err = dc.ReadArrayHeader()
   105  	if err != nil {
   106  		return
   107  	}
   108  	if zb0001 != 2 {
   109  		err = msgp.ArrayError{Wanted: 2, Got: zb0001}
   110  		return
   111  	}
   112  	err = dc.ReadExactBytes((z.Nonce)[:])
   113  	if err != nil {
   114  		return
   115  	}
   116  	z.Version, err = dc.ReadUint32()
   117  	if err != nil {
   118  		return
   119  	}
   120  	return
   121  }
   122  
   123  // EncodeMsg implements msgp.Encodable
   124  func (z *RawHandshakeResponseMsg) EncodeMsg(en *msgp.Writer) (err error) {
   125  	// array header, size 2
   126  	err = en.Append(0x92)
   127  	if err != nil {
   128  		return
   129  	}
   130  	err = en.WriteBytes((z.Nonce)[:])
   131  	if err != nil {
   132  		return
   133  	}
   134  	err = en.WriteUint32(z.Version)
   135  	if err != nil {
   136  		return
   137  	}
   138  	return
   139  }
   140  
   141  // MarshalMsg implements msgp.Marshaler
   142  func (z *RawHandshakeResponseMsg) MarshalMsg(b []byte) (o []byte, err error) {
   143  	o = msgp.Require(b, z.Msgsize())
   144  	// array header, size 2
   145  	o = append(o, 0x92)
   146  	o = msgp.AppendBytes(o, (z.Nonce)[:])
   147  	o = msgp.AppendUint32(o, z.Version)
   148  	return
   149  }
   150  
   151  // UnmarshalMsg implements msgp.Unmarshaler
   152  func (z *RawHandshakeResponseMsg) UnmarshalMsg(bts []byte) (o []byte, err error) {
   153  	var zb0001 uint32
   154  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   155  	if err != nil {
   156  		return
   157  	}
   158  	if zb0001 != 2 {
   159  		err = msgp.ArrayError{Wanted: 2, Got: zb0001}
   160  		return
   161  	}
   162  	bts, err = msgp.ReadExactBytes(bts, (z.Nonce)[:])
   163  	if err != nil {
   164  		return
   165  	}
   166  	z.Version, bts, err = msgp.ReadUint32Bytes(bts)
   167  	if err != nil {
   168  		return
   169  	}
   170  	o = bts
   171  	return
   172  }
   173  
   174  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   175  func (z *RawHandshakeResponseMsg) Msgsize() (s int) {
   176  	s = 1 + msgp.ArrayHeaderSize + (shaLen * (msgp.ByteSize)) + msgp.Uint32Size
   177  	return
   178  }