github.com/annchain/OG@v0.0.9/og/protocol/ogmessage/archive/token_info_gen.go (about)

     1  package archive
     2  
     3  // Code generated by github.com/tinylib/msgp DO NOT EDIT.
     4  
     5  import (
     6  	"github.com/annchain/OG/common/math"
     7  	"github.com/tinylib/msgp/msgp"
     8  )
     9  
    10  // DecodeMsg implements msgp.Decodable
    11  func (z *TokenInfo) DecodeMsg(dc *msgp.Reader) (err error) {
    12  	var zb0001 uint32
    13  	zb0001, err = dc.ReadArrayHeader()
    14  	if err != nil {
    15  		err = msgp.WrapError(err)
    16  		return
    17  	}
    18  	if zb0001 != 4 {
    19  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
    20  		return
    21  	}
    22  	err = PublicOffering.DecodeMsg(dc)
    23  	if err != nil {
    24  		err = msgp.WrapError(err, "PublicOffering")
    25  		return
    26  	}
    27  	err = z.Sender.DecodeMsg(dc)
    28  	if err != nil {
    29  		err = msgp.WrapError(err, "Sender")
    30  		return
    31  	}
    32  	if dc.IsNil() {
    33  		err = dc.ReadNil()
    34  		if err != nil {
    35  			err = msgp.WrapError(err, "CurrentValue")
    36  			return
    37  		}
    38  		z.CurrentValue = nil
    39  	} else {
    40  		if z.CurrentValue == nil {
    41  			z.CurrentValue = new(math.BigInt)
    42  		}
    43  		err = z.CurrentValue.DecodeMsg(dc)
    44  		if err != nil {
    45  			err = msgp.WrapError(err, "CurrentValue")
    46  			return
    47  		}
    48  	}
    49  	z.Destroyed, err = dc.ReadBool()
    50  	if err != nil {
    51  		err = msgp.WrapError(err, "Destroyed")
    52  		return
    53  	}
    54  	return
    55  }
    56  
    57  // EncodeMsg implements msgp.Encodable
    58  func (z *TokenInfo) EncodeMsg(en *msgp.Writer) (err error) {
    59  	// array header, size 4
    60  	err = en.Append(0x94)
    61  	if err != nil {
    62  		return
    63  	}
    64  	err = PublicOffering.EncodeMsg(en)
    65  	if err != nil {
    66  		err = msgp.WrapError(err, "PublicOffering")
    67  		return
    68  	}
    69  	err = z.Sender.EncodeMsg(en)
    70  	if err != nil {
    71  		err = msgp.WrapError(err, "Sender")
    72  		return
    73  	}
    74  	if z.CurrentValue == nil {
    75  		err = en.WriteNil()
    76  		if err != nil {
    77  			return
    78  		}
    79  	} else {
    80  		err = z.CurrentValue.EncodeMsg(en)
    81  		if err != nil {
    82  			err = msgp.WrapError(err, "CurrentValue")
    83  			return
    84  		}
    85  	}
    86  	err = en.WriteBool(z.Destroyed)
    87  	if err != nil {
    88  		err = msgp.WrapError(err, "Destroyed")
    89  		return
    90  	}
    91  	return
    92  }
    93  
    94  // MarshalMsg implements msgp.Marshaler
    95  func (z *TokenInfo) MarshalMsg(b []byte) (o []byte, err error) {
    96  	o = msgp.Require(b, z.Msgsize())
    97  	// array header, size 4
    98  	o = append(o, 0x94)
    99  	o, err = PublicOffering.MarshalMsg(o)
   100  	if err != nil {
   101  		err = msgp.WrapError(err, "PublicOffering")
   102  		return
   103  	}
   104  	o, err = z.Sender.MarshalMsg(o)
   105  	if err != nil {
   106  		err = msgp.WrapError(err, "Sender")
   107  		return
   108  	}
   109  	if z.CurrentValue == nil {
   110  		o = msgp.AppendNil(o)
   111  	} else {
   112  		o, err = z.CurrentValue.MarshalMsg(o)
   113  		if err != nil {
   114  			err = msgp.WrapError(err, "CurrentValue")
   115  			return
   116  		}
   117  	}
   118  	o = msgp.AppendBool(o, z.Destroyed)
   119  	return
   120  }
   121  
   122  // UnmarshalMsg implements msgp.Unmarshaler
   123  func (z *TokenInfo) UnmarshalMsg(bts []byte) (o []byte, err error) {
   124  	var zb0001 uint32
   125  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   126  	if err != nil {
   127  		err = msgp.WrapError(err)
   128  		return
   129  	}
   130  	if zb0001 != 4 {
   131  		err = msgp.ArrayError{Wanted: 4, Got: zb0001}
   132  		return
   133  	}
   134  	bts, err = PublicOffering.UnmarshalMsg(bts)
   135  	if err != nil {
   136  		err = msgp.WrapError(err, "PublicOffering")
   137  		return
   138  	}
   139  	bts, err = z.Sender.UnmarshalMsg(bts)
   140  	if err != nil {
   141  		err = msgp.WrapError(err, "Sender")
   142  		return
   143  	}
   144  	if msgp.IsNil(bts) {
   145  		bts, err = msgp.ReadNilBytes(bts)
   146  		if err != nil {
   147  			return
   148  		}
   149  		z.CurrentValue = nil
   150  	} else {
   151  		if z.CurrentValue == nil {
   152  			z.CurrentValue = new(math.BigInt)
   153  		}
   154  		bts, err = z.CurrentValue.UnmarshalMsg(bts)
   155  		if err != nil {
   156  			err = msgp.WrapError(err, "CurrentValue")
   157  			return
   158  		}
   159  	}
   160  	z.Destroyed, bts, err = msgp.ReadBoolBytes(bts)
   161  	if err != nil {
   162  		err = msgp.WrapError(err, "Destroyed")
   163  		return
   164  	}
   165  	o = bts
   166  	return
   167  }
   168  
   169  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   170  func (z *TokenInfo) Msgsize() (s int) {
   171  	s = 1 + PublicOffering.Msgsize() + z.Sender.Msgsize()
   172  	if z.CurrentValue == nil {
   173  		s += msgp.NilSize
   174  	} else {
   175  		s += z.CurrentValue.Msgsize()
   176  	}
   177  	s += msgp.BoolSize
   178  	return
   179  }
   180  
   181  // DecodeMsg implements msgp.Decodable
   182  func (z *TokensInfo) DecodeMsg(dc *msgp.Reader) (err error) {
   183  	var zb0002 uint32
   184  	zb0002, err = dc.ReadArrayHeader()
   185  	if err != nil {
   186  		err = msgp.WrapError(err)
   187  		return
   188  	}
   189  	if cap((*z)) >= int(zb0002) {
   190  		(*z) = (*z)[:zb0002]
   191  	} else {
   192  		(*z) = make(TokensInfo, zb0002)
   193  	}
   194  	for zb0001 := range *z {
   195  		if dc.IsNil() {
   196  			err = dc.ReadNil()
   197  			if err != nil {
   198  				err = msgp.WrapError(err, zb0001)
   199  				return
   200  			}
   201  			(*z)[zb0001] = nil
   202  		} else {
   203  			if (*z)[zb0001] == nil {
   204  				(*z)[zb0001] = new(TokenInfo)
   205  			}
   206  			err = (*z)[zb0001].DecodeMsg(dc)
   207  			if err != nil {
   208  				err = msgp.WrapError(err, zb0001)
   209  				return
   210  			}
   211  		}
   212  	}
   213  	return
   214  }
   215  
   216  // EncodeMsg implements msgp.Encodable
   217  func (z TokensInfo) EncodeMsg(en *msgp.Writer) (err error) {
   218  	err = en.WriteArrayHeader(uint32(len(z)))
   219  	if err != nil {
   220  		err = msgp.WrapError(err)
   221  		return
   222  	}
   223  	for zb0003 := range z {
   224  		if z[zb0003] == nil {
   225  			err = en.WriteNil()
   226  			if err != nil {
   227  				return
   228  			}
   229  		} else {
   230  			err = z[zb0003].EncodeMsg(en)
   231  			if err != nil {
   232  				err = msgp.WrapError(err, zb0003)
   233  				return
   234  			}
   235  		}
   236  	}
   237  	return
   238  }
   239  
   240  // MarshalMsg implements msgp.Marshaler
   241  func (z TokensInfo) MarshalMsg(b []byte) (o []byte, err error) {
   242  	o = msgp.Require(b, z.Msgsize())
   243  	o = msgp.AppendArrayHeader(o, uint32(len(z)))
   244  	for zb0003 := range z {
   245  		if z[zb0003] == nil {
   246  			o = msgp.AppendNil(o)
   247  		} else {
   248  			o, err = z[zb0003].MarshalMsg(o)
   249  			if err != nil {
   250  				err = msgp.WrapError(err, zb0003)
   251  				return
   252  			}
   253  		}
   254  	}
   255  	return
   256  }
   257  
   258  // UnmarshalMsg implements msgp.Unmarshaler
   259  func (z *TokensInfo) UnmarshalMsg(bts []byte) (o []byte, err error) {
   260  	var zb0002 uint32
   261  	zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
   262  	if err != nil {
   263  		err = msgp.WrapError(err)
   264  		return
   265  	}
   266  	if cap((*z)) >= int(zb0002) {
   267  		(*z) = (*z)[:zb0002]
   268  	} else {
   269  		(*z) = make(TokensInfo, zb0002)
   270  	}
   271  	for zb0001 := range *z {
   272  		if msgp.IsNil(bts) {
   273  			bts, err = msgp.ReadNilBytes(bts)
   274  			if err != nil {
   275  				return
   276  			}
   277  			(*z)[zb0001] = nil
   278  		} else {
   279  			if (*z)[zb0001] == nil {
   280  				(*z)[zb0001] = new(TokenInfo)
   281  			}
   282  			bts, err = (*z)[zb0001].UnmarshalMsg(bts)
   283  			if err != nil {
   284  				err = msgp.WrapError(err, zb0001)
   285  				return
   286  			}
   287  		}
   288  	}
   289  	o = bts
   290  	return
   291  }
   292  
   293  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   294  func (z TokensInfo) Msgsize() (s int) {
   295  	s = msgp.ArrayHeaderSize
   296  	for zb0003 := range z {
   297  		if z[zb0003] == nil {
   298  			s += msgp.NilSize
   299  		} else {
   300  			s += z[zb0003].Msgsize()
   301  		}
   302  	}
   303  	return
   304  }