/
depositdata_ssz.go
102 lines (79 loc) · 2.49 KB
/
depositdata_ssz.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// Code generated by fastssz. DO NOT EDIT.
// Hash: fa97a18404df62375826ed5ee7ded00832a9164171537b8327e9357589e54c7a
// Version: 0.1.3
package phase0
import (
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the DepositData object
func (d *DepositData) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(d)
}
// MarshalSSZTo ssz marshals the DepositData object to a target array
func (d *DepositData) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'PublicKey'
dst = append(dst, d.PublicKey[:]...)
// Field (1) 'WithdrawalCredentials'
if size := len(d.WithdrawalCredentials); size != 32 {
err = ssz.ErrBytesLengthFn("DepositData.WithdrawalCredentials", size, 32)
return
}
dst = append(dst, d.WithdrawalCredentials...)
// Field (2) 'Amount'
dst = ssz.MarshalUint64(dst, uint64(d.Amount))
// Field (3) 'Signature'
dst = append(dst, d.Signature[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the DepositData object
func (d *DepositData) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 184 {
return ssz.ErrSize
}
// Field (0) 'PublicKey'
copy(d.PublicKey[:], buf[0:48])
// Field (1) 'WithdrawalCredentials'
if cap(d.WithdrawalCredentials) == 0 {
d.WithdrawalCredentials = make([]byte, 0, len(buf[48:80]))
}
d.WithdrawalCredentials = append(d.WithdrawalCredentials, buf[48:80]...)
// Field (2) 'Amount'
d.Amount = Gwei(ssz.UnmarshallUint64(buf[80:88]))
// Field (3) 'Signature'
copy(d.Signature[:], buf[88:184])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the DepositData object
func (d *DepositData) SizeSSZ() (size int) {
size = 184
return
}
// HashTreeRoot ssz hashes the DepositData object
func (d *DepositData) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(d)
}
// HashTreeRootWith ssz hashes the DepositData object with a hasher
func (d *DepositData) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'PublicKey'
hh.PutBytes(d.PublicKey[:])
// Field (1) 'WithdrawalCredentials'
if size := len(d.WithdrawalCredentials); size != 32 {
err = ssz.ErrBytesLengthFn("DepositData.WithdrawalCredentials", size, 32)
return
}
hh.PutBytes(d.WithdrawalCredentials)
// Field (2) 'Amount'
hh.PutUint64(uint64(d.Amount))
// Field (3) 'Signature'
hh.PutBytes(d.Signature[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the DepositData object
func (d *DepositData) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(d)
}