github.com/annchain/OG@v0.0.9/p2p/rlpx_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 *AuthMsgV4) 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  	err = dc.ReadExactBytes((z.Signature)[:])
    21  	if err != nil {
    22  		return
    23  	}
    24  	err = dc.ReadExactBytes((z.InitiatorPubkey)[:])
    25  	if err != nil {
    26  		return
    27  	}
    28  	err = dc.ReadExactBytes((z.Nonce)[:])
    29  	if err != nil {
    30  		return
    31  	}
    32  	z.Version, err = dc.ReadUint32()
    33  	if err != nil {
    34  		return
    35  	}
    36  	return
    37  }
    38  
    39  // EncodeMsg implements msgp.Encodable
    40  func (z *AuthMsgV4) 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.Signature)[:])
    47  	if err != nil {
    48  		return
    49  	}
    50  	err = en.WriteBytes((z.InitiatorPubkey)[:])
    51  	if err != nil {
    52  		return
    53  	}
    54  	err = en.WriteBytes((z.Nonce)[:])
    55  	if err != nil {
    56  		return
    57  	}
    58  	err = en.WriteUint32(z.Version)
    59  	if err != nil {
    60  		return
    61  	}
    62  	return
    63  }
    64  
    65  // MarshalMsg implements msgp.Marshaler
    66  func (z *AuthMsgV4) 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.Signature)[:])
    71  	o = msgp.AppendBytes(o, (z.InitiatorPubkey)[:])
    72  	o = msgp.AppendBytes(o, (z.Nonce)[:])
    73  	o = msgp.AppendUint32(o, z.Version)
    74  	return
    75  }
    76  
    77  // UnmarshalMsg implements msgp.Unmarshaler
    78  func (z *AuthMsgV4) 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  	bts, err = msgp.ReadExactBytes(bts, (z.Signature)[:])
    89  	if err != nil {
    90  		return
    91  	}
    92  	bts, err = msgp.ReadExactBytes(bts, (z.InitiatorPubkey)[:])
    93  	if err != nil {
    94  		return
    95  	}
    96  	bts, err = msgp.ReadExactBytes(bts, (z.Nonce)[:])
    97  	if err != nil {
    98  		return
    99  	}
   100  	z.Version, bts, err = msgp.ReadUint32Bytes(bts)
   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 *AuthMsgV4) Msgsize() (s int) {
   110  	s = 1 + msgp.ArrayHeaderSize + (sigLen * (msgp.ByteSize)) + msgp.ArrayHeaderSize + (pubLen * (msgp.ByteSize)) + msgp.ArrayHeaderSize + (shaLen * (msgp.ByteSize)) + msgp.Uint32Size
   111  	return
   112  }
   113  
   114  // DecodeMsg implements msgp.Decodable
   115  func (z *AuthRespV4) DecodeMsg(dc *msgp.Reader) (err error) {
   116  	var zb0001 uint32
   117  	zb0001, err = dc.ReadArrayHeader()
   118  	if err != nil {
   119  		return
   120  	}
   121  	if zb0001 != 3 {
   122  		err = msgp.ArrayError{Wanted: 3, Got: zb0001}
   123  		return
   124  	}
   125  	err = dc.ReadExactBytes((z.RandomPubkey)[:])
   126  	if err != nil {
   127  		return
   128  	}
   129  	err = dc.ReadExactBytes((z.Nonce)[:])
   130  	if err != nil {
   131  		return
   132  	}
   133  	z.Version, err = dc.ReadUint32()
   134  	if err != nil {
   135  		return
   136  	}
   137  	return
   138  }
   139  
   140  // EncodeMsg implements msgp.Encodable
   141  func (z *AuthRespV4) EncodeMsg(en *msgp.Writer) (err error) {
   142  	// array header, size 3
   143  	err = en.Append(0x93)
   144  	if err != nil {
   145  		return
   146  	}
   147  	err = en.WriteBytes((z.RandomPubkey)[:])
   148  	if err != nil {
   149  		return
   150  	}
   151  	err = en.WriteBytes((z.Nonce)[:])
   152  	if err != nil {
   153  		return
   154  	}
   155  	err = en.WriteUint32(z.Version)
   156  	if err != nil {
   157  		return
   158  	}
   159  	return
   160  }
   161  
   162  // MarshalMsg implements msgp.Marshaler
   163  func (z *AuthRespV4) MarshalMsg(b []byte) (o []byte, err error) {
   164  	o = msgp.Require(b, z.Msgsize())
   165  	// array header, size 3
   166  	o = append(o, 0x93)
   167  	o = msgp.AppendBytes(o, (z.RandomPubkey)[:])
   168  	o = msgp.AppendBytes(o, (z.Nonce)[:])
   169  	o = msgp.AppendUint32(o, z.Version)
   170  	return
   171  }
   172  
   173  // UnmarshalMsg implements msgp.Unmarshaler
   174  func (z *AuthRespV4) UnmarshalMsg(bts []byte) (o []byte, err error) {
   175  	var zb0001 uint32
   176  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   177  	if err != nil {
   178  		return
   179  	}
   180  	if zb0001 != 3 {
   181  		err = msgp.ArrayError{Wanted: 3, Got: zb0001}
   182  		return
   183  	}
   184  	bts, err = msgp.ReadExactBytes(bts, (z.RandomPubkey)[:])
   185  	if err != nil {
   186  		return
   187  	}
   188  	bts, err = msgp.ReadExactBytes(bts, (z.Nonce)[:])
   189  	if err != nil {
   190  		return
   191  	}
   192  	z.Version, bts, err = msgp.ReadUint32Bytes(bts)
   193  	if err != nil {
   194  		return
   195  	}
   196  	o = bts
   197  	return
   198  }
   199  
   200  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   201  func (z *AuthRespV4) Msgsize() (s int) {
   202  	s = 1 + msgp.ArrayHeaderSize + (pubLen * (msgp.ByteSize)) + msgp.ArrayHeaderSize + (shaLen * (msgp.ByteSize)) + msgp.Uint32Size
   203  	return
   204  }