-
Notifications
You must be signed in to change notification settings - Fork 8
/
submitblockrequest_ssz.go
176 lines (145 loc) · 3.9 KB
/
submitblockrequest_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
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
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
// Code generated by fastssz. DO NOT EDIT.
// Hash: ab124b93579f8996010b3c7fe144fdc154d151bbcb4848aa2eb177c45631019e
// Version: 0.1.3
package deneb
import (
v1 "github.com/attestantio/go-builder-client/api/v1"
"github.com/attestantio/go-eth2-client/spec/deneb"
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the SubmitBlockRequest object
func (s *SubmitBlockRequest) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SubmitBlockRequest object to a target array
func (s *SubmitBlockRequest) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(340)
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(v1.BidTrace)
}
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
// Offset (1) 'ExecutionPayload'
dst = ssz.WriteOffset(dst, offset)
if s.ExecutionPayload == nil {
s.ExecutionPayload = new(deneb.ExecutionPayload)
}
offset += s.ExecutionPayload.SizeSSZ()
// Offset (2) 'BlobsBundle'
dst = ssz.WriteOffset(dst, offset)
if s.BlobsBundle == nil {
s.BlobsBundle = new(BlobsBundle)
}
offset += s.BlobsBundle.SizeSSZ()
// Field (3) 'Signature'
dst = append(dst, s.Signature[:]...)
// Field (1) 'ExecutionPayload'
if dst, err = s.ExecutionPayload.MarshalSSZTo(dst); err != nil {
return
}
// Field (2) 'BlobsBundle'
if dst, err = s.BlobsBundle.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SubmitBlockRequest object
func (s *SubmitBlockRequest) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 340 {
return ssz.ErrSize
}
tail := buf
var o1, o2 uint64
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(v1.BidTrace)
}
if err = s.Message.UnmarshalSSZ(buf[0:236]); err != nil {
return err
}
// Offset (1) 'ExecutionPayload'
if o1 = ssz.ReadOffset(buf[236:240]); o1 > size {
return ssz.ErrOffset
}
if o1 < 340 {
return ssz.ErrInvalidVariableOffset
}
// Offset (2) 'BlobsBundle'
if o2 = ssz.ReadOffset(buf[240:244]); o2 > size || o1 > o2 {
return ssz.ErrOffset
}
// Field (3) 'Signature'
copy(s.Signature[:], buf[244:340])
// Field (1) 'ExecutionPayload'
{
buf = tail[o1:o2]
if s.ExecutionPayload == nil {
s.ExecutionPayload = new(deneb.ExecutionPayload)
}
if err = s.ExecutionPayload.UnmarshalSSZ(buf); err != nil {
return err
}
}
// Field (2) 'BlobsBundle'
{
buf = tail[o2:]
if s.BlobsBundle == nil {
s.BlobsBundle = new(BlobsBundle)
}
if err = s.BlobsBundle.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SubmitBlockRequest object
func (s *SubmitBlockRequest) SizeSSZ() (size int) {
size = 340
// Field (1) 'ExecutionPayload'
if s.ExecutionPayload == nil {
s.ExecutionPayload = new(deneb.ExecutionPayload)
}
size += s.ExecutionPayload.SizeSSZ()
// Field (2) 'BlobsBundle'
if s.BlobsBundle == nil {
s.BlobsBundle = new(BlobsBundle)
}
size += s.BlobsBundle.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SubmitBlockRequest object
func (s *SubmitBlockRequest) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SubmitBlockRequest object with a hasher
func (s *SubmitBlockRequest) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(v1.BidTrace)
}
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'ExecutionPayload'
if err = s.ExecutionPayload.HashTreeRootWith(hh); err != nil {
return
}
// Field (2) 'BlobsBundle'
if err = s.BlobsBundle.HashTreeRootWith(hh); err != nil {
return
}
// Field (3) 'Signature'
hh.PutBytes(s.Signature[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the SubmitBlockRequest object
func (s *SubmitBlockRequest) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(s)
}