github.com/annchain/OG@v0.0.9/consensus/vrf/model_gen.go (about)

     1  package vrf
     2  
     3  import "github.com/tinylib/msgp/msgp"
     4  
     5  // DecodeMsg implements msgp.Decodable
     6  func (z *VrfInfo) DecodeMsg(dc *msgp.Reader) (err error) {
     7  	var zb0001 uint32
     8  	zb0001, err = dc.ReadArrayHeader()
     9  	if err != nil {
    10  		return
    11  	}
    12  	if zb0001 != 4 {
    13  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
    14  		return
    15  	}
    16  	z.Message, err = dc.ReadBytes(z.Message)
    17  	if err != nil {
    18  		return
    19  	}
    20  	z.Proof, err = dc.ReadBytes(z.Proof)
    21  	if err != nil {
    22  		return
    23  	}
    24  	z.PublicKey, err = dc.ReadBytes(z.PublicKey)
    25  	if err != nil {
    26  		return
    27  	}
    28  	z.Vrf, err = dc.ReadBytes(z.Vrf)
    29  	if err != nil {
    30  		return
    31  	}
    32  	return
    33  }
    34  
    35  // EncodeMsg implements msgp.Encodable
    36  func (z *VrfInfo) EncodeMsg(en *msgp.Writer) (err error) {
    37  	// array header, size 4
    38  	err = en.Append(0x94)
    39  	if err != nil {
    40  		return
    41  	}
    42  	err = en.WriteBytes(z.Message)
    43  	if err != nil {
    44  		return
    45  	}
    46  	err = en.WriteBytes(z.Proof)
    47  	if err != nil {
    48  		return
    49  	}
    50  	err = en.WriteBytes(z.PublicKey)
    51  	if err != nil {
    52  		return
    53  	}
    54  	err = en.WriteBytes(z.Vrf)
    55  	if err != nil {
    56  		return
    57  	}
    58  	return
    59  }
    60  
    61  // MarshalMsg implements msgp.Marshaler
    62  func (z *VrfInfo) MarshalMsg(b []byte) (o []byte, err error) {
    63  	o = msgp.Require(b, z.Msgsize())
    64  	// array header, size 4
    65  	o = append(o, 0x94)
    66  	o = msgp.AppendBytes(o, z.Message)
    67  	o = msgp.AppendBytes(o, z.Proof)
    68  	o = msgp.AppendBytes(o, z.PublicKey)
    69  	o = msgp.AppendBytes(o, z.Vrf)
    70  	return
    71  }
    72  
    73  // UnmarshalMsg implements msgp.Unmarshaler
    74  func (z *VrfInfo) UnmarshalMsg(bts []byte) (o []byte, err error) {
    75  	var zb0001 uint32
    76  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
    77  	if err != nil {
    78  		return
    79  	}
    80  	if zb0001 != 4 {
    81  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
    82  		return
    83  	}
    84  	z.Message, bts, err = msgp.ReadBytesBytes(bts, z.Message)
    85  	if err != nil {
    86  		return
    87  	}
    88  	z.Proof, bts, err = msgp.ReadBytesBytes(bts, z.Proof)
    89  	if err != nil {
    90  		return
    91  	}
    92  	z.PublicKey, bts, err = msgp.ReadBytesBytes(bts, z.PublicKey)
    93  	if err != nil {
    94  		return
    95  	}
    96  	z.Vrf, bts, err = msgp.ReadBytesBytes(bts, z.Vrf)
    97  	if err != nil {
    98  		return
    99  	}
   100  	o = bts
   101  	return
   102  }
   103  
   104  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   105  func (z *VrfInfo) Msgsize() (s int) {
   106  	s = 1 + msgp.BytesPrefixSize + len(z.Message) + msgp.BytesPrefixSize + len(z.Proof) + msgp.BytesPrefixSize + len(z.PublicKey) + msgp.BytesPrefixSize + len(z.Vrf)
   107  	return
   108  }