-
Notifications
You must be signed in to change notification settings - Fork 57
/
withdrawal_ssz.go
92 lines (69 loc) · 2.15 KB
/
withdrawal_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
// Code generated by fastssz. DO NOT EDIT.
// Hash: b64d375d32e69b033e6ff6cb1f2a9f16ac7bbeefd51bd11bd25ffeaa81762fcc
// Version: 0.1.3
package capella
import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the Withdrawal object
func (w *Withdrawal) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(w)
}
// MarshalSSZTo ssz marshals the Withdrawal object to a target array
func (w *Withdrawal) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'Index'
dst = ssz.MarshalUint64(dst, uint64(w.Index))
// Field (1) 'ValidatorIndex'
dst = ssz.MarshalUint64(dst, uint64(w.ValidatorIndex))
// Field (2) 'Address'
dst = append(dst, w.Address[:]...)
// Field (3) 'Amount'
dst = ssz.MarshalUint64(dst, uint64(w.Amount))
return
}
// UnmarshalSSZ ssz unmarshals the Withdrawal object
func (w *Withdrawal) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 44 {
return ssz.ErrSize
}
// Field (0) 'Index'
w.Index = WithdrawalIndex(ssz.UnmarshallUint64(buf[0:8]))
// Field (1) 'ValidatorIndex'
w.ValidatorIndex = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[8:16]))
// Field (2) 'Address'
copy(w.Address[:], buf[16:36])
// Field (3) 'Amount'
w.Amount = phase0.Gwei(ssz.UnmarshallUint64(buf[36:44]))
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the Withdrawal object
func (w *Withdrawal) SizeSSZ() (size int) {
size = 44
return
}
// HashTreeRoot ssz hashes the Withdrawal object
func (w *Withdrawal) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(w)
}
// HashTreeRootWith ssz hashes the Withdrawal object with a hasher
func (w *Withdrawal) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'Index'
hh.PutUint64(uint64(w.Index))
// Field (1) 'ValidatorIndex'
hh.PutUint64(uint64(w.ValidatorIndex))
// Field (2) 'Address'
hh.PutBytes(w.Address[:])
// Field (3) 'Amount'
hh.PutUint64(uint64(w.Amount))
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the Withdrawal object
func (w *Withdrawal) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(w)
}