-
Notifications
You must be signed in to change notification settings - Fork 59
/
signedbeaconblock_ssz.go
111 lines (89 loc) · 2.35 KB
/
signedbeaconblock_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
// Code generated by fastssz. DO NOT EDIT.
// Hash: 3788614e00eec4f1965525d5d47a3f0341227525e7e3c2bd84f6500e73c4c20d
// Version: 0.1.3
package altair
import (
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the SignedBeaconBlock object
func (s *SignedBeaconBlock) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SignedBeaconBlock object to a target array
func (s *SignedBeaconBlock) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
offset := int(100)
// Offset (0) 'Message'
dst = ssz.WriteOffset(dst, offset)
if s.Message == nil {
s.Message = new(BeaconBlock)
}
offset += s.Message.SizeSSZ()
// Field (1) 'Signature'
dst = append(dst, s.Signature[:]...)
// Field (0) 'Message'
if dst, err = s.Message.MarshalSSZTo(dst); err != nil {
return
}
return
}
// UnmarshalSSZ ssz unmarshals the SignedBeaconBlock object
func (s *SignedBeaconBlock) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size < 100 {
return ssz.ErrSize
}
tail := buf
var o0 uint64
// Offset (0) 'Message'
if o0 = ssz.ReadOffset(buf[0:4]); o0 > size {
return ssz.ErrOffset
}
if o0 < 100 {
return ssz.ErrInvalidVariableOffset
}
// Field (1) 'Signature'
copy(s.Signature[:], buf[4:100])
// Field (0) 'Message'
{
buf = tail[o0:]
if s.Message == nil {
s.Message = new(BeaconBlock)
}
if err = s.Message.UnmarshalSSZ(buf); err != nil {
return err
}
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SignedBeaconBlock object
func (s *SignedBeaconBlock) SizeSSZ() (size int) {
size = 100
// Field (0) 'Message'
if s.Message == nil {
s.Message = new(BeaconBlock)
}
size += s.Message.SizeSSZ()
return
}
// HashTreeRoot ssz hashes the SignedBeaconBlock object
func (s *SignedBeaconBlock) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SignedBeaconBlock object with a hasher
func (s *SignedBeaconBlock) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'Message'
if err = s.Message.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'Signature'
hh.PutBytes(s.Signature[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the SignedBeaconBlock object
func (s *SignedBeaconBlock) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(s)
}