github.com/amazechain/amc@v0.1.3/api/protocol/sync_pb/generated.ssz.go (about)

     1  // Code generated by fastssz. DO NOT EDIT.
     2  // Hash: b39bb565b34add934304fdd716d14cb913acca74f226a8fd1f0c0c390e3bc247
     3  package sync_pb
     4  
     5  import (
     6  	types_pb "github.com/amazechain/amc/api/protocol/types_pb"
     7  	ssz "github.com/prysmaticlabs/fastssz"
     8  )
     9  
    10  // MarshalSSZ ssz marshals the HeadersByRangeRequest object
    11  func (h *HeadersByRangeRequest) MarshalSSZ() ([]byte, error) {
    12  	return ssz.MarshalSSZ(h)
    13  }
    14  
    15  // MarshalSSZTo ssz marshals the HeadersByRangeRequest object to a target array
    16  func (h *HeadersByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
    17  	dst = buf
    18  	offset := int(20)
    19  
    20  	// Offset (0) 'StartBlockNumber'
    21  	dst = ssz.WriteOffset(dst, offset)
    22  	if h.StartBlockNumber == nil {
    23  		h.StartBlockNumber = new(types_pb.H256)
    24  	}
    25  	offset += h.StartBlockNumber.SizeSSZ()
    26  
    27  	// Field (1) 'Count'
    28  	dst = ssz.MarshalUint64(dst, h.Count)
    29  
    30  	// Field (2) 'Step'
    31  	dst = ssz.MarshalUint64(dst, h.Step)
    32  
    33  	// Field (0) 'StartBlockNumber'
    34  	if dst, err = h.StartBlockNumber.MarshalSSZTo(dst); err != nil {
    35  		return
    36  	}
    37  
    38  	return
    39  }
    40  
    41  // UnmarshalSSZ ssz unmarshals the HeadersByRangeRequest object
    42  func (h *HeadersByRangeRequest) UnmarshalSSZ(buf []byte) error {
    43  	var err error
    44  	size := uint64(len(buf))
    45  	if size < 20 {
    46  		return ssz.ErrSize
    47  	}
    48  
    49  	tail := buf
    50  	var o0 uint64
    51  
    52  	// Offset (0) 'StartBlockNumber'
    53  	if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
    54  		return ssz.ErrOffset
    55  	}
    56  
    57  	if o0 < 20 {
    58  		return ssz.ErrInvalidVariableOffset
    59  	}
    60  
    61  	// Field (1) 'Count'
    62  	h.Count = ssz.UnmarshallUint64(buf[4:12])
    63  
    64  	// Field (2) 'Step'
    65  	h.Step = ssz.UnmarshallUint64(buf[12:20])
    66  
    67  	// Field (0) 'StartBlockNumber'
    68  	{
    69  		buf = tail[o0:]
    70  		if h.StartBlockNumber == nil {
    71  			h.StartBlockNumber = new(types_pb.H256)
    72  		}
    73  		if err = h.StartBlockNumber.UnmarshalSSZ(buf); err != nil {
    74  			return err
    75  		}
    76  	}
    77  	return err
    78  }
    79  
    80  // SizeSSZ returns the ssz encoded size in bytes for the HeadersByRangeRequest object
    81  func (h *HeadersByRangeRequest) SizeSSZ() (size int) {
    82  	size = 20
    83  
    84  	// Field (0) 'StartBlockNumber'
    85  	if h.StartBlockNumber == nil {
    86  		h.StartBlockNumber = new(types_pb.H256)
    87  	}
    88  	size += h.StartBlockNumber.SizeSSZ()
    89  
    90  	return
    91  }
    92  
    93  // HashTreeRoot ssz hashes the HeadersByRangeRequest object
    94  func (h *HeadersByRangeRequest) HashTreeRoot() ([32]byte, error) {
    95  	return ssz.HashWithDefaultHasher(h)
    96  }
    97  
    98  // HashTreeRootWith ssz hashes the HeadersByRangeRequest object with a hasher
    99  func (h *HeadersByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
   100  	indx := hh.Index()
   101  
   102  	// Field (0) 'StartBlockNumber'
   103  	if err = h.StartBlockNumber.HashTreeRootWith(hh); err != nil {
   104  		return
   105  	}
   106  
   107  	// Field (1) 'Count'
   108  	hh.PutUint64(h.Count)
   109  
   110  	// Field (2) 'Step'
   111  	hh.PutUint64(h.Step)
   112  
   113  	if ssz.EnableVectorizedHTR {
   114  		hh.MerkleizeVectorizedHTR(indx)
   115  	} else {
   116  		hh.Merkleize(indx)
   117  	}
   118  	return
   119  }
   120  
   121  // MarshalSSZ ssz marshals the Ping object
   122  func (p *Ping) MarshalSSZ() ([]byte, error) {
   123  	return ssz.MarshalSSZ(p)
   124  }
   125  
   126  // MarshalSSZTo ssz marshals the Ping object to a target array
   127  func (p *Ping) MarshalSSZTo(buf []byte) (dst []byte, err error) {
   128  	dst = buf
   129  
   130  	// Field (0) 'SeqNumber'
   131  	dst = ssz.MarshalUint64(dst, p.SeqNumber)
   132  
   133  	return
   134  }
   135  
   136  // UnmarshalSSZ ssz unmarshals the Ping object
   137  func (p *Ping) UnmarshalSSZ(buf []byte) error {
   138  	var err error
   139  	size := uint64(len(buf))
   140  	if size != 8 {
   141  		return ssz.ErrSize
   142  	}
   143  
   144  	// Field (0) 'SeqNumber'
   145  	p.SeqNumber = ssz.UnmarshallUint64(buf[0:8])
   146  
   147  	return err
   148  }
   149  
   150  // SizeSSZ returns the ssz encoded size in bytes for the Ping object
   151  func (p *Ping) SizeSSZ() (size int) {
   152  	size = 8
   153  	return
   154  }
   155  
   156  // HashTreeRoot ssz hashes the Ping object
   157  func (p *Ping) HashTreeRoot() ([32]byte, error) {
   158  	return ssz.HashWithDefaultHasher(p)
   159  }
   160  
   161  // HashTreeRootWith ssz hashes the Ping object with a hasher
   162  func (p *Ping) HashTreeRootWith(hh *ssz.Hasher) (err error) {
   163  	indx := hh.Index()
   164  
   165  	// Field (0) 'SeqNumber'
   166  	hh.PutUint64(p.SeqNumber)
   167  
   168  	if ssz.EnableVectorizedHTR {
   169  		hh.MerkleizeVectorizedHTR(indx)
   170  	} else {
   171  		hh.Merkleize(indx)
   172  	}
   173  	return
   174  }
   175  
   176  // MarshalSSZ ssz marshals the Status object
   177  func (s *Status) MarshalSSZ() ([]byte, error) {
   178  	return ssz.MarshalSSZ(s)
   179  }
   180  
   181  // MarshalSSZTo ssz marshals the Status object to a target array
   182  func (s *Status) MarshalSSZTo(buf []byte) (dst []byte, err error) {
   183  	dst = buf
   184  	offset := int(8)
   185  
   186  	// Offset (0) 'GenesisHash'
   187  	dst = ssz.WriteOffset(dst, offset)
   188  	if s.GenesisHash == nil {
   189  		s.GenesisHash = new(types_pb.H256)
   190  	}
   191  	offset += s.GenesisHash.SizeSSZ()
   192  
   193  	// Offset (1) 'CurrentHeight'
   194  	dst = ssz.WriteOffset(dst, offset)
   195  	if s.CurrentHeight == nil {
   196  		s.CurrentHeight = new(types_pb.H256)
   197  	}
   198  	offset += s.CurrentHeight.SizeSSZ()
   199  
   200  	// Field (0) 'GenesisHash'
   201  	if dst, err = s.GenesisHash.MarshalSSZTo(dst); err != nil {
   202  		return
   203  	}
   204  
   205  	// Field (1) 'CurrentHeight'
   206  	if dst, err = s.CurrentHeight.MarshalSSZTo(dst); err != nil {
   207  		return
   208  	}
   209  
   210  	return
   211  }
   212  
   213  // UnmarshalSSZ ssz unmarshals the Status object
   214  func (s *Status) UnmarshalSSZ(buf []byte) error {
   215  	var err error
   216  	size := uint64(len(buf))
   217  	if size < 8 {
   218  		return ssz.ErrSize
   219  	}
   220  
   221  	tail := buf
   222  	var o0, o1 uint64
   223  
   224  	// Offset (0) 'GenesisHash'
   225  	if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
   226  		return ssz.ErrOffset
   227  	}
   228  
   229  	if o0 < 8 {
   230  		return ssz.ErrInvalidVariableOffset
   231  	}
   232  
   233  	// Offset (1) 'CurrentHeight'
   234  	if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
   235  		return ssz.ErrOffset
   236  	}
   237  
   238  	// Field (0) 'GenesisHash'
   239  	{
   240  		buf = tail[o0:o1]
   241  		if s.GenesisHash == nil {
   242  			s.GenesisHash = new(types_pb.H256)
   243  		}
   244  		if err = s.GenesisHash.UnmarshalSSZ(buf); err != nil {
   245  			return err
   246  		}
   247  	}
   248  
   249  	// Field (1) 'CurrentHeight'
   250  	{
   251  		buf = tail[o1:]
   252  		if s.CurrentHeight == nil {
   253  			s.CurrentHeight = new(types_pb.H256)
   254  		}
   255  		if err = s.CurrentHeight.UnmarshalSSZ(buf); err != nil {
   256  			return err
   257  		}
   258  	}
   259  	return err
   260  }
   261  
   262  // SizeSSZ returns the ssz encoded size in bytes for the Status object
   263  func (s *Status) SizeSSZ() (size int) {
   264  	size = 8
   265  
   266  	// Field (0) 'GenesisHash'
   267  	if s.GenesisHash == nil {
   268  		s.GenesisHash = new(types_pb.H256)
   269  	}
   270  	size += s.GenesisHash.SizeSSZ()
   271  
   272  	// Field (1) 'CurrentHeight'
   273  	if s.CurrentHeight == nil {
   274  		s.CurrentHeight = new(types_pb.H256)
   275  	}
   276  	size += s.CurrentHeight.SizeSSZ()
   277  
   278  	return
   279  }
   280  
   281  // HashTreeRoot ssz hashes the Status object
   282  func (s *Status) HashTreeRoot() ([32]byte, error) {
   283  	return ssz.HashWithDefaultHasher(s)
   284  }
   285  
   286  // HashTreeRootWith ssz hashes the Status object with a hasher
   287  func (s *Status) HashTreeRootWith(hh *ssz.Hasher) (err error) {
   288  	indx := hh.Index()
   289  
   290  	// Field (0) 'GenesisHash'
   291  	if err = s.GenesisHash.HashTreeRootWith(hh); err != nil {
   292  		return
   293  	}
   294  
   295  	// Field (1) 'CurrentHeight'
   296  	if err = s.CurrentHeight.HashTreeRootWith(hh); err != nil {
   297  		return
   298  	}
   299  
   300  	if ssz.EnableVectorizedHTR {
   301  		hh.MerkleizeVectorizedHTR(indx)
   302  	} else {
   303  		hh.Merkleize(indx)
   304  	}
   305  	return
   306  }
   307  
   308  // MarshalSSZ ssz marshals the ForkData object
   309  func (f *ForkData) MarshalSSZ() ([]byte, error) {
   310  	return ssz.MarshalSSZ(f)
   311  }
   312  
   313  // MarshalSSZTo ssz marshals the ForkData object to a target array
   314  func (f *ForkData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
   315  	dst = buf
   316  	offset := int(8)
   317  
   318  	// Offset (0) 'CurrentVersion'
   319  	dst = ssz.WriteOffset(dst, offset)
   320  	if f.CurrentVersion == nil {
   321  		f.CurrentVersion = new(types_pb.H256)
   322  	}
   323  	offset += f.CurrentVersion.SizeSSZ()
   324  
   325  	// Offset (1) 'GenesisValidatorsRoot'
   326  	dst = ssz.WriteOffset(dst, offset)
   327  	if f.GenesisValidatorsRoot == nil {
   328  		f.GenesisValidatorsRoot = new(types_pb.H256)
   329  	}
   330  	offset += f.GenesisValidatorsRoot.SizeSSZ()
   331  
   332  	// Field (0) 'CurrentVersion'
   333  	if dst, err = f.CurrentVersion.MarshalSSZTo(dst); err != nil {
   334  		return
   335  	}
   336  
   337  	// Field (1) 'GenesisValidatorsRoot'
   338  	if dst, err = f.GenesisValidatorsRoot.MarshalSSZTo(dst); err != nil {
   339  		return
   340  	}
   341  
   342  	return
   343  }
   344  
   345  // UnmarshalSSZ ssz unmarshals the ForkData object
   346  func (f *ForkData) UnmarshalSSZ(buf []byte) error {
   347  	var err error
   348  	size := uint64(len(buf))
   349  	if size < 8 {
   350  		return ssz.ErrSize
   351  	}
   352  
   353  	tail := buf
   354  	var o0, o1 uint64
   355  
   356  	// Offset (0) 'CurrentVersion'
   357  	if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
   358  		return ssz.ErrOffset
   359  	}
   360  
   361  	if o0 < 8 {
   362  		return ssz.ErrInvalidVariableOffset
   363  	}
   364  
   365  	// Offset (1) 'GenesisValidatorsRoot'
   366  	if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
   367  		return ssz.ErrOffset
   368  	}
   369  
   370  	// Field (0) 'CurrentVersion'
   371  	{
   372  		buf = tail[o0:o1]
   373  		if f.CurrentVersion == nil {
   374  			f.CurrentVersion = new(types_pb.H256)
   375  		}
   376  		if err = f.CurrentVersion.UnmarshalSSZ(buf); err != nil {
   377  			return err
   378  		}
   379  	}
   380  
   381  	// Field (1) 'GenesisValidatorsRoot'
   382  	{
   383  		buf = tail[o1:]
   384  		if f.GenesisValidatorsRoot == nil {
   385  			f.GenesisValidatorsRoot = new(types_pb.H256)
   386  		}
   387  		if err = f.GenesisValidatorsRoot.UnmarshalSSZ(buf); err != nil {
   388  			return err
   389  		}
   390  	}
   391  	return err
   392  }
   393  
   394  // SizeSSZ returns the ssz encoded size in bytes for the ForkData object
   395  func (f *ForkData) SizeSSZ() (size int) {
   396  	size = 8
   397  
   398  	// Field (0) 'CurrentVersion'
   399  	if f.CurrentVersion == nil {
   400  		f.CurrentVersion = new(types_pb.H256)
   401  	}
   402  	size += f.CurrentVersion.SizeSSZ()
   403  
   404  	// Field (1) 'GenesisValidatorsRoot'
   405  	if f.GenesisValidatorsRoot == nil {
   406  		f.GenesisValidatorsRoot = new(types_pb.H256)
   407  	}
   408  	size += f.GenesisValidatorsRoot.SizeSSZ()
   409  
   410  	return
   411  }
   412  
   413  // HashTreeRoot ssz hashes the ForkData object
   414  func (f *ForkData) HashTreeRoot() ([32]byte, error) {
   415  	return ssz.HashWithDefaultHasher(f)
   416  }
   417  
   418  // HashTreeRootWith ssz hashes the ForkData object with a hasher
   419  func (f *ForkData) HashTreeRootWith(hh *ssz.Hasher) (err error) {
   420  	indx := hh.Index()
   421  
   422  	// Field (0) 'CurrentVersion'
   423  	if err = f.CurrentVersion.HashTreeRootWith(hh); err != nil {
   424  		return
   425  	}
   426  
   427  	// Field (1) 'GenesisValidatorsRoot'
   428  	if err = f.GenesisValidatorsRoot.HashTreeRootWith(hh); err != nil {
   429  		return
   430  	}
   431  
   432  	if ssz.EnableVectorizedHTR {
   433  		hh.MerkleizeVectorizedHTR(indx)
   434  	} else {
   435  		hh.Merkleize(indx)
   436  	}
   437  	return
   438  }
   439  
   440  // MarshalSSZ ssz marshals the BodiesByRangeRequest object
   441  func (b *BodiesByRangeRequest) MarshalSSZ() ([]byte, error) {
   442  	return ssz.MarshalSSZ(b)
   443  }
   444  
   445  // MarshalSSZTo ssz marshals the BodiesByRangeRequest object to a target array
   446  func (b *BodiesByRangeRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
   447  	dst = buf
   448  	offset := int(20)
   449  
   450  	// Offset (0) 'StartBlockNumber'
   451  	dst = ssz.WriteOffset(dst, offset)
   452  	if b.StartBlockNumber == nil {
   453  		b.StartBlockNumber = new(types_pb.H256)
   454  	}
   455  	offset += b.StartBlockNumber.SizeSSZ()
   456  
   457  	// Field (1) 'Count'
   458  	dst = ssz.MarshalUint64(dst, b.Count)
   459  
   460  	// Field (2) 'Step'
   461  	dst = ssz.MarshalUint64(dst, b.Step)
   462  
   463  	// Field (0) 'StartBlockNumber'
   464  	if dst, err = b.StartBlockNumber.MarshalSSZTo(dst); err != nil {
   465  		return
   466  	}
   467  
   468  	return
   469  }
   470  
   471  // UnmarshalSSZ ssz unmarshals the BodiesByRangeRequest object
   472  func (b *BodiesByRangeRequest) UnmarshalSSZ(buf []byte) error {
   473  	var err error
   474  	size := uint64(len(buf))
   475  	if size < 20 {
   476  		return ssz.ErrSize
   477  	}
   478  
   479  	tail := buf
   480  	var o0 uint64
   481  
   482  	// Offset (0) 'StartBlockNumber'
   483  	if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
   484  		return ssz.ErrOffset
   485  	}
   486  
   487  	if o0 < 20 {
   488  		return ssz.ErrInvalidVariableOffset
   489  	}
   490  
   491  	// Field (1) 'Count'
   492  	b.Count = ssz.UnmarshallUint64(buf[4:12])
   493  
   494  	// Field (2) 'Step'
   495  	b.Step = ssz.UnmarshallUint64(buf[12:20])
   496  
   497  	// Field (0) 'StartBlockNumber'
   498  	{
   499  		buf = tail[o0:]
   500  		if b.StartBlockNumber == nil {
   501  			b.StartBlockNumber = new(types_pb.H256)
   502  		}
   503  		if err = b.StartBlockNumber.UnmarshalSSZ(buf); err != nil {
   504  			return err
   505  		}
   506  	}
   507  	return err
   508  }
   509  
   510  // SizeSSZ returns the ssz encoded size in bytes for the BodiesByRangeRequest object
   511  func (b *BodiesByRangeRequest) SizeSSZ() (size int) {
   512  	size = 20
   513  
   514  	// Field (0) 'StartBlockNumber'
   515  	if b.StartBlockNumber == nil {
   516  		b.StartBlockNumber = new(types_pb.H256)
   517  	}
   518  	size += b.StartBlockNumber.SizeSSZ()
   519  
   520  	return
   521  }
   522  
   523  // HashTreeRoot ssz hashes the BodiesByRangeRequest object
   524  func (b *BodiesByRangeRequest) HashTreeRoot() ([32]byte, error) {
   525  	return ssz.HashWithDefaultHasher(b)
   526  }
   527  
   528  // HashTreeRootWith ssz hashes the BodiesByRangeRequest object with a hasher
   529  func (b *BodiesByRangeRequest) HashTreeRootWith(hh *ssz.Hasher) (err error) {
   530  	indx := hh.Index()
   531  
   532  	// Field (0) 'StartBlockNumber'
   533  	if err = b.StartBlockNumber.HashTreeRootWith(hh); err != nil {
   534  		return
   535  	}
   536  
   537  	// Field (1) 'Count'
   538  	hh.PutUint64(b.Count)
   539  
   540  	// Field (2) 'Step'
   541  	hh.PutUint64(b.Step)
   542  
   543  	if ssz.EnableVectorizedHTR {
   544  		hh.MerkleizeVectorizedHTR(indx)
   545  	} else {
   546  		hh.Merkleize(indx)
   547  	}
   548  	return
   549  }