-
Notifications
You must be signed in to change notification settings - Fork 59
/
attesterslashing_encoding.go
130 lines (107 loc) · 2.81 KB
/
attesterslashing_encoding.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
// Code generated by fastssz. DO NOT EDIT.
package phase0
import (
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the AttesterSlashing object
func (a *AttesterSlashing) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(a)
}
// MarshalSSZTo ssz marshals the AttesterSlashing object to a target array
func (a *AttesterSlashing) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(8)
// Offset (0) 'Attestation1'
dst = ssz.WriteOffset(dst, offset)
if a.Attestation1 == nil {
a.Attestation1 = new(IndexedAttestation)
}
offset += a.Attestation1.SizeSSZ()
// Offset (1) 'Attestation2'
dst = ssz.WriteOffset(dst, offset)
if a.Attestation2 == nil {
a.Attestation2 = new(IndexedAttestation)
}
offset += a.Attestation2.SizeSSZ()
// Field (0) 'Attestation1'
if dst, err = a.Attestation1.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'Attestation2'
if dst, err = a.Attestation2.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the AttesterSlashing object
func (a *AttesterSlashing) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 8 {
return ssz.ErrSize
}
tail := buf
var o0, o1 uint64
// Offset (0) 'Attestation1'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
// Offset (1) 'Attestation2'
if o1 = ssz.ReadOffset(buf[4:8]); o1 > size || o0 > o1 {
return ssz.ErrOffset
}
// Field (0) 'Attestation1'
{
buf = tail[o0:o1]
if a.Attestation1 == nil {
a.Attestation1 = new(IndexedAttestation)
}
if err = a.Attestation1.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (1) 'Attestation2'
{
buf = tail[o1:]
if a.Attestation2 == nil {
a.Attestation2 = new(IndexedAttestation)
}
if err = a.Attestation2.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the AttesterSlashing object
func (a *AttesterSlashing) SizeSSZ() (size int) {
size = 8
// Field (0) 'Attestation1'
if a.Attestation1 == nil {
a.Attestation1 = new(IndexedAttestation)
}
size += a.Attestation1.SizeSSZ()
// Field (1) 'Attestation2'
if a.Attestation2 == nil {
a.Attestation2 = new(IndexedAttestation)
}
size += a.Attestation2.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the AttesterSlashing object
func (a *AttesterSlashing) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(a)
}
// HashTreeRootWith ssz hashes the AttesterSlashing object with a hasher
func (a *AttesterSlashing) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'Attestation1'
if err = a.Attestation1.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Attestation2'
if err = a.Attestation2.HashTreeRootWith(hh); err != nil {
return
}
hh.Merkleize(indx)
return
}