github.com/annchain/OG@v0.0.9/og/protocol/dagmessage/message_content_gen.go (about)

     1  package dagmessage
     2  
     3  // Code generated by github.com/tinylib/msgp DO NOT EDIT.
     4  
     5  import (
     6  	"github.com/annchain/OG/arefactor/og/types"
     7  	"github.com/annchain/OG/common/math"
     8  	"github.com/tinylib/msgp/msgp"
     9  )
    10  
    11  // DecodeMsg implements msgp.Decodable
    12  func (z *MessageContentTx) DecodeMsg(dc *msgp.Reader) (err error) {
    13  	var zb0001 uint32
    14  	zb0001, err = dc.ReadArrayHeader()
    15  	if err != nil {
    16  		err = msgp.WrapError(err)
    17  		return
    18  	}
    19  	if zb0001 != 11 {
    20  		err = msgp.ArrayError{Wanted: 11, Got: zb0001}
    21  		return
    22  	}
    23  	err = z.Hash.DecodeMsg(dc)
    24  	if err != nil {
    25  		err = msgp.WrapError(err, "Hash")
    26  		return
    27  	}
    28  	var zb0002 uint32
    29  	zb0002, err = dc.ReadArrayHeader()
    30  	if err != nil {
    31  		err = msgp.WrapError(err, "ParentsHash")
    32  		return
    33  	}
    34  	if cap(z.ParentsHash) >= int(zb0002) {
    35  		z.ParentsHash = (z.ParentsHash)[:zb0002]
    36  	} else {
    37  		z.ParentsHash = make([]types.Hash, zb0002)
    38  	}
    39  	for za0001 := range z.ParentsHash {
    40  		err = z.ParentsHash[za0001].DecodeMsg(dc)
    41  		if err != nil {
    42  			err = msgp.WrapError(err, "ParentsHash", za0001)
    43  			return
    44  		}
    45  	}
    46  	z.MineNonce, err = dc.ReadUint64()
    47  	if err != nil {
    48  		err = msgp.WrapError(err, "MineNonce")
    49  		return
    50  	}
    51  	z.AccountNonce, err = dc.ReadUint64()
    52  	if err != nil {
    53  		err = msgp.WrapError(err, "AccountNonce")
    54  		return
    55  	}
    56  	err = z.From.DecodeMsg(dc)
    57  	if err != nil {
    58  		err = msgp.WrapError(err, "From")
    59  		return
    60  	}
    61  	err = z.To.DecodeMsg(dc)
    62  	if err != nil {
    63  		err = msgp.WrapError(err, "To")
    64  		return
    65  	}
    66  	if dc.IsNil() {
    67  		err = dc.ReadNil()
    68  		if err != nil {
    69  			err = msgp.WrapError(err, "Value")
    70  			return
    71  		}
    72  		z.Value = nil
    73  	} else {
    74  		if z.Value == nil {
    75  			z.Value = new(math.BigInt)
    76  		}
    77  		err = z.Value.DecodeMsg(dc)
    78  		if err != nil {
    79  			err = msgp.WrapError(err, "Value")
    80  			return
    81  		}
    82  	}
    83  	z.TokenId, err = dc.ReadInt32()
    84  	if err != nil {
    85  		err = msgp.WrapError(err, "TokenId")
    86  		return
    87  	}
    88  	z.PublicKey, err = dc.ReadBytes(z.PublicKey)
    89  	if err != nil {
    90  		err = msgp.WrapError(err, "PublicKey")
    91  		return
    92  	}
    93  	z.Data, err = dc.ReadBytes(z.Data)
    94  	if err != nil {
    95  		err = msgp.WrapError(err, "Data")
    96  		return
    97  	}
    98  	z.Signature, err = dc.ReadBytes(z.Signature)
    99  	if err != nil {
   100  		err = msgp.WrapError(err, "Signature")
   101  		return
   102  	}
   103  	return
   104  }
   105  
   106  // EncodeMsg implements msgp.Encodable
   107  func (z *MessageContentTx) EncodeMsg(en *msgp.Writer) (err error) {
   108  	// array header, size 11
   109  	err = en.Append(0x9b)
   110  	if err != nil {
   111  		return
   112  	}
   113  	err = z.Hash.EncodeMsg(en)
   114  	if err != nil {
   115  		err = msgp.WrapError(err, "Hash")
   116  		return
   117  	}
   118  	err = en.WriteArrayHeader(uint32(len(z.ParentsHash)))
   119  	if err != nil {
   120  		err = msgp.WrapError(err, "ParentsHash")
   121  		return
   122  	}
   123  	for za0001 := range z.ParentsHash {
   124  		err = z.ParentsHash[za0001].EncodeMsg(en)
   125  		if err != nil {
   126  			err = msgp.WrapError(err, "ParentsHash", za0001)
   127  			return
   128  		}
   129  	}
   130  	err = en.WriteUint64(z.MineNonce)
   131  	if err != nil {
   132  		err = msgp.WrapError(err, "MineNonce")
   133  		return
   134  	}
   135  	err = en.WriteUint64(z.AccountNonce)
   136  	if err != nil {
   137  		err = msgp.WrapError(err, "AccountNonce")
   138  		return
   139  	}
   140  	err = z.From.EncodeMsg(en)
   141  	if err != nil {
   142  		err = msgp.WrapError(err, "From")
   143  		return
   144  	}
   145  	err = z.To.EncodeMsg(en)
   146  	if err != nil {
   147  		err = msgp.WrapError(err, "To")
   148  		return
   149  	}
   150  	if z.Value == nil {
   151  		err = en.WriteNil()
   152  		if err != nil {
   153  			return
   154  		}
   155  	} else {
   156  		err = z.Value.EncodeMsg(en)
   157  		if err != nil {
   158  			err = msgp.WrapError(err, "Value")
   159  			return
   160  		}
   161  	}
   162  	err = en.WriteInt32(z.TokenId)
   163  	if err != nil {
   164  		err = msgp.WrapError(err, "TokenId")
   165  		return
   166  	}
   167  	err = en.WriteBytes(z.PublicKey)
   168  	if err != nil {
   169  		err = msgp.WrapError(err, "PublicKey")
   170  		return
   171  	}
   172  	err = en.WriteBytes(z.Data)
   173  	if err != nil {
   174  		err = msgp.WrapError(err, "Data")
   175  		return
   176  	}
   177  	err = en.WriteBytes(z.Signature)
   178  	if err != nil {
   179  		err = msgp.WrapError(err, "Signature")
   180  		return
   181  	}
   182  	return
   183  }
   184  
   185  // MarshalMsg implements msgp.Marshaler
   186  func (z *MessageContentTx) MarshalMsg(b []byte) (o []byte, err error) {
   187  	o = msgp.Require(b, z.Msgsize())
   188  	// array header, size 11
   189  	o = append(o, 0x9b)
   190  	o, err = z.Hash.MarshalMsg(o)
   191  	if err != nil {
   192  		err = msgp.WrapError(err, "Hash")
   193  		return
   194  	}
   195  	o = msgp.AppendArrayHeader(o, uint32(len(z.ParentsHash)))
   196  	for za0001 := range z.ParentsHash {
   197  		o, err = z.ParentsHash[za0001].MarshalMsg(o)
   198  		if err != nil {
   199  			err = msgp.WrapError(err, "ParentsHash", za0001)
   200  			return
   201  		}
   202  	}
   203  	o = msgp.AppendUint64(o, z.MineNonce)
   204  	o = msgp.AppendUint64(o, z.AccountNonce)
   205  	o, err = z.From.MarshalMsg(o)
   206  	if err != nil {
   207  		err = msgp.WrapError(err, "From")
   208  		return
   209  	}
   210  	o, err = z.To.MarshalMsg(o)
   211  	if err != nil {
   212  		err = msgp.WrapError(err, "To")
   213  		return
   214  	}
   215  	if z.Value == nil {
   216  		o = msgp.AppendNil(o)
   217  	} else {
   218  		o, err = z.Value.MarshalMsg(o)
   219  		if err != nil {
   220  			err = msgp.WrapError(err, "Value")
   221  			return
   222  		}
   223  	}
   224  	o = msgp.AppendInt32(o, z.TokenId)
   225  	o = msgp.AppendBytes(o, z.PublicKey)
   226  	o = msgp.AppendBytes(o, z.Data)
   227  	o = msgp.AppendBytes(o, z.Signature)
   228  	return
   229  }
   230  
   231  // UnmarshalMsg implements msgp.Unmarshaler
   232  func (z *MessageContentTx) UnmarshalMsg(bts []byte) (o []byte, err error) {
   233  	var zb0001 uint32
   234  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   235  	if err != nil {
   236  		err = msgp.WrapError(err)
   237  		return
   238  	}
   239  	if zb0001 != 11 {
   240  		err = msgp.ArrayError{Wanted: 11, Got: zb0001}
   241  		return
   242  	}
   243  	bts, err = z.Hash.UnmarshalMsg(bts)
   244  	if err != nil {
   245  		err = msgp.WrapError(err, "Hash")
   246  		return
   247  	}
   248  	var zb0002 uint32
   249  	zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
   250  	if err != nil {
   251  		err = msgp.WrapError(err, "ParentsHash")
   252  		return
   253  	}
   254  	if cap(z.ParentsHash) >= int(zb0002) {
   255  		z.ParentsHash = (z.ParentsHash)[:zb0002]
   256  	} else {
   257  		z.ParentsHash = make([]types.Hash, zb0002)
   258  	}
   259  	for za0001 := range z.ParentsHash {
   260  		bts, err = z.ParentsHash[za0001].UnmarshalMsg(bts)
   261  		if err != nil {
   262  			err = msgp.WrapError(err, "ParentsHash", za0001)
   263  			return
   264  		}
   265  	}
   266  	z.MineNonce, bts, err = msgp.ReadUint64Bytes(bts)
   267  	if err != nil {
   268  		err = msgp.WrapError(err, "MineNonce")
   269  		return
   270  	}
   271  	z.AccountNonce, bts, err = msgp.ReadUint64Bytes(bts)
   272  	if err != nil {
   273  		err = msgp.WrapError(err, "AccountNonce")
   274  		return
   275  	}
   276  	bts, err = z.From.UnmarshalMsg(bts)
   277  	if err != nil {
   278  		err = msgp.WrapError(err, "From")
   279  		return
   280  	}
   281  	bts, err = z.To.UnmarshalMsg(bts)
   282  	if err != nil {
   283  		err = msgp.WrapError(err, "To")
   284  		return
   285  	}
   286  	if msgp.IsNil(bts) {
   287  		bts, err = msgp.ReadNilBytes(bts)
   288  		if err != nil {
   289  			return
   290  		}
   291  		z.Value = nil
   292  	} else {
   293  		if z.Value == nil {
   294  			z.Value = new(math.BigInt)
   295  		}
   296  		bts, err = z.Value.UnmarshalMsg(bts)
   297  		if err != nil {
   298  			err = msgp.WrapError(err, "Value")
   299  			return
   300  		}
   301  	}
   302  	z.TokenId, bts, err = msgp.ReadInt32Bytes(bts)
   303  	if err != nil {
   304  		err = msgp.WrapError(err, "TokenId")
   305  		return
   306  	}
   307  	z.PublicKey, bts, err = msgp.ReadBytesBytes(bts, z.PublicKey)
   308  	if err != nil {
   309  		err = msgp.WrapError(err, "PublicKey")
   310  		return
   311  	}
   312  	z.Data, bts, err = msgp.ReadBytesBytes(bts, z.Data)
   313  	if err != nil {
   314  		err = msgp.WrapError(err, "Data")
   315  		return
   316  	}
   317  	z.Signature, bts, err = msgp.ReadBytesBytes(bts, z.Signature)
   318  	if err != nil {
   319  		err = msgp.WrapError(err, "Signature")
   320  		return
   321  	}
   322  	o = bts
   323  	return
   324  }
   325  
   326  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   327  func (z *MessageContentTx) Msgsize() (s int) {
   328  	s = 1 + z.Hash.Msgsize() + msgp.ArrayHeaderSize
   329  	for za0001 := range z.ParentsHash {
   330  		s += z.ParentsHash[za0001].Msgsize()
   331  	}
   332  	s += msgp.Uint64Size + msgp.Uint64Size + z.From.Msgsize() + z.To.Msgsize()
   333  	if z.Value == nil {
   334  		s += msgp.NilSize
   335  	} else {
   336  		s += z.Value.Msgsize()
   337  	}
   338  	s += msgp.Int32Size + msgp.BytesPrefixSize + len(z.PublicKey) + msgp.BytesPrefixSize + len(z.Data) + msgp.BytesPrefixSize + len(z.Signature)
   339  	return
   340  }
   341  
   342  // DecodeMsg implements msgp.Decodable
   343  func (z *MessageContextSequencer) DecodeMsg(dc *msgp.Reader) (err error) {
   344  	var zb0001 uint32
   345  	zb0001, err = dc.ReadArrayHeader()
   346  	if err != nil {
   347  		err = msgp.WrapError(err)
   348  		return
   349  	}
   350  	if zb0001 != 8 {
   351  		err = msgp.ArrayError{Wanted: 8, Got: zb0001}
   352  		return
   353  	}
   354  	err = z.Hash.DecodeMsg(dc)
   355  	if err != nil {
   356  		err = msgp.WrapError(err, "Hash")
   357  		return
   358  	}
   359  	var zb0002 uint32
   360  	zb0002, err = dc.ReadArrayHeader()
   361  	if err != nil {
   362  		err = msgp.WrapError(err, "ParentsHash")
   363  		return
   364  	}
   365  	if cap(z.ParentsHash) >= int(zb0002) {
   366  		z.ParentsHash = (z.ParentsHash)[:zb0002]
   367  	} else {
   368  		z.ParentsHash = make([]types.Hash, zb0002)
   369  	}
   370  	for za0001 := range z.ParentsHash {
   371  		err = z.ParentsHash[za0001].DecodeMsg(dc)
   372  		if err != nil {
   373  			err = msgp.WrapError(err, "ParentsHash", za0001)
   374  			return
   375  		}
   376  	}
   377  	z.MineNonce, err = dc.ReadUint64()
   378  	if err != nil {
   379  		err = msgp.WrapError(err, "MineNonce")
   380  		return
   381  	}
   382  	z.AccountNonce, err = dc.ReadUint64()
   383  	if err != nil {
   384  		err = msgp.WrapError(err, "AccountNonce")
   385  		return
   386  	}
   387  	err = z.Issuer.DecodeMsg(dc)
   388  	if err != nil {
   389  		err = msgp.WrapError(err, "Issuer")
   390  		return
   391  	}
   392  	z.PublicKey, err = dc.ReadBytes(z.PublicKey)
   393  	if err != nil {
   394  		err = msgp.WrapError(err, "PublicKey")
   395  		return
   396  	}
   397  	z.Signature, err = dc.ReadBytes(z.Signature)
   398  	if err != nil {
   399  		err = msgp.WrapError(err, "Signature")
   400  		return
   401  	}
   402  	err = z.StateRoot.DecodeMsg(dc)
   403  	if err != nil {
   404  		err = msgp.WrapError(err, "StateRoot")
   405  		return
   406  	}
   407  	return
   408  }
   409  
   410  // EncodeMsg implements msgp.Encodable
   411  func (z *MessageContextSequencer) EncodeMsg(en *msgp.Writer) (err error) {
   412  	// array header, size 8
   413  	err = en.Append(0x98)
   414  	if err != nil {
   415  		return
   416  	}
   417  	err = z.Hash.EncodeMsg(en)
   418  	if err != nil {
   419  		err = msgp.WrapError(err, "Hash")
   420  		return
   421  	}
   422  	err = en.WriteArrayHeader(uint32(len(z.ParentsHash)))
   423  	if err != nil {
   424  		err = msgp.WrapError(err, "ParentsHash")
   425  		return
   426  	}
   427  	for za0001 := range z.ParentsHash {
   428  		err = z.ParentsHash[za0001].EncodeMsg(en)
   429  		if err != nil {
   430  			err = msgp.WrapError(err, "ParentsHash", za0001)
   431  			return
   432  		}
   433  	}
   434  	err = en.WriteUint64(z.MineNonce)
   435  	if err != nil {
   436  		err = msgp.WrapError(err, "MineNonce")
   437  		return
   438  	}
   439  	err = en.WriteUint64(z.AccountNonce)
   440  	if err != nil {
   441  		err = msgp.WrapError(err, "AccountNonce")
   442  		return
   443  	}
   444  	err = z.Issuer.EncodeMsg(en)
   445  	if err != nil {
   446  		err = msgp.WrapError(err, "Issuer")
   447  		return
   448  	}
   449  	err = en.WriteBytes(z.PublicKey)
   450  	if err != nil {
   451  		err = msgp.WrapError(err, "PublicKey")
   452  		return
   453  	}
   454  	err = en.WriteBytes(z.Signature)
   455  	if err != nil {
   456  		err = msgp.WrapError(err, "Signature")
   457  		return
   458  	}
   459  	err = z.StateRoot.EncodeMsg(en)
   460  	if err != nil {
   461  		err = msgp.WrapError(err, "StateRoot")
   462  		return
   463  	}
   464  	return
   465  }
   466  
   467  // MarshalMsg implements msgp.Marshaler
   468  func (z *MessageContextSequencer) MarshalMsg(b []byte) (o []byte, err error) {
   469  	o = msgp.Require(b, z.Msgsize())
   470  	// array header, size 8
   471  	o = append(o, 0x98)
   472  	o, err = z.Hash.MarshalMsg(o)
   473  	if err != nil {
   474  		err = msgp.WrapError(err, "Hash")
   475  		return
   476  	}
   477  	o = msgp.AppendArrayHeader(o, uint32(len(z.ParentsHash)))
   478  	for za0001 := range z.ParentsHash {
   479  		o, err = z.ParentsHash[za0001].MarshalMsg(o)
   480  		if err != nil {
   481  			err = msgp.WrapError(err, "ParentsHash", za0001)
   482  			return
   483  		}
   484  	}
   485  	o = msgp.AppendUint64(o, z.MineNonce)
   486  	o = msgp.AppendUint64(o, z.AccountNonce)
   487  	o, err = z.Issuer.MarshalMsg(o)
   488  	if err != nil {
   489  		err = msgp.WrapError(err, "Issuer")
   490  		return
   491  	}
   492  	o = msgp.AppendBytes(o, z.PublicKey)
   493  	o = msgp.AppendBytes(o, z.Signature)
   494  	o, err = z.StateRoot.MarshalMsg(o)
   495  	if err != nil {
   496  		err = msgp.WrapError(err, "StateRoot")
   497  		return
   498  	}
   499  	return
   500  }
   501  
   502  // UnmarshalMsg implements msgp.Unmarshaler
   503  func (z *MessageContextSequencer) UnmarshalMsg(bts []byte) (o []byte, err error) {
   504  	var zb0001 uint32
   505  	zb0001, bts, err = msgp.ReadArrayHeaderBytes(bts)
   506  	if err != nil {
   507  		err = msgp.WrapError(err)
   508  		return
   509  	}
   510  	if zb0001 != 8 {
   511  		err = msgp.ArrayError{Wanted: 8, Got: zb0001}
   512  		return
   513  	}
   514  	bts, err = z.Hash.UnmarshalMsg(bts)
   515  	if err != nil {
   516  		err = msgp.WrapError(err, "Hash")
   517  		return
   518  	}
   519  	var zb0002 uint32
   520  	zb0002, bts, err = msgp.ReadArrayHeaderBytes(bts)
   521  	if err != nil {
   522  		err = msgp.WrapError(err, "ParentsHash")
   523  		return
   524  	}
   525  	if cap(z.ParentsHash) >= int(zb0002) {
   526  		z.ParentsHash = (z.ParentsHash)[:zb0002]
   527  	} else {
   528  		z.ParentsHash = make([]types.Hash, zb0002)
   529  	}
   530  	for za0001 := range z.ParentsHash {
   531  		bts, err = z.ParentsHash[za0001].UnmarshalMsg(bts)
   532  		if err != nil {
   533  			err = msgp.WrapError(err, "ParentsHash", za0001)
   534  			return
   535  		}
   536  	}
   537  	z.MineNonce, bts, err = msgp.ReadUint64Bytes(bts)
   538  	if err != nil {
   539  		err = msgp.WrapError(err, "MineNonce")
   540  		return
   541  	}
   542  	z.AccountNonce, bts, err = msgp.ReadUint64Bytes(bts)
   543  	if err != nil {
   544  		err = msgp.WrapError(err, "AccountNonce")
   545  		return
   546  	}
   547  	bts, err = z.Issuer.UnmarshalMsg(bts)
   548  	if err != nil {
   549  		err = msgp.WrapError(err, "Issuer")
   550  		return
   551  	}
   552  	z.PublicKey, bts, err = msgp.ReadBytesBytes(bts, z.PublicKey)
   553  	if err != nil {
   554  		err = msgp.WrapError(err, "PublicKey")
   555  		return
   556  	}
   557  	z.Signature, bts, err = msgp.ReadBytesBytes(bts, z.Signature)
   558  	if err != nil {
   559  		err = msgp.WrapError(err, "Signature")
   560  		return
   561  	}
   562  	bts, err = z.StateRoot.UnmarshalMsg(bts)
   563  	if err != nil {
   564  		err = msgp.WrapError(err, "StateRoot")
   565  		return
   566  	}
   567  	o = bts
   568  	return
   569  }
   570  
   571  // Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
   572  func (z *MessageContextSequencer) Msgsize() (s int) {
   573  	s = 1 + z.Hash.Msgsize() + msgp.ArrayHeaderSize
   574  	for za0001 := range z.ParentsHash {
   575  		s += z.ParentsHash[za0001].Msgsize()
   576  	}
   577  	s += msgp.Uint64Size + msgp.Uint64Size + z.Issuer.Msgsize() + msgp.BytesPrefixSize + len(z.PublicKey) + msgp.BytesPrefixSize + len(z.Signature) + z.StateRoot.Msgsize()
   578  	return
   579  }