-
Notifications
You must be signed in to change notification settings - Fork 58
/
synccommitteemessage_ssz.go
92 lines (69 loc) · 2.3 KB
/
synccommitteemessage_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: 3788614e00eec4f1965525d5d47a3f0341227525e7e3c2bd84f6500e73c4c20d
// Version: 0.1.3
package altair
import (
"github.com/attestantio/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the SyncCommitteeMessage object
func (s *SyncCommitteeMessage) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SyncCommitteeMessage object to a target array
func (s *SyncCommitteeMessage) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'Slot'
dst = ssz.MarshalUint64(dst, uint64(s.Slot))
// Field (1) 'BeaconBlockRoot'
dst = append(dst, s.BeaconBlockRoot[:]...)
// Field (2) 'ValidatorIndex'
dst = ssz.MarshalUint64(dst, uint64(s.ValidatorIndex))
// Field (3) 'Signature'
dst = append(dst, s.Signature[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the SyncCommitteeMessage object
func (s *SyncCommitteeMessage) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 144 {
return ssz.ErrSize
}
// Field (0) 'Slot'
s.Slot = phase0.Slot(ssz.UnmarshallUint64(buf[0:8]))
// Field (1) 'BeaconBlockRoot'
copy(s.BeaconBlockRoot[:], buf[8:40])
// Field (2) 'ValidatorIndex'
s.ValidatorIndex = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[40:48]))
// Field (3) 'Signature'
copy(s.Signature[:], buf[48:144])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeMessage object
func (s *SyncCommitteeMessage) SizeSSZ() (size int) {
size = 144
return
}
// HashTreeRoot ssz hashes the SyncCommitteeMessage object
func (s *SyncCommitteeMessage) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SyncCommitteeMessage object with a hasher
func (s *SyncCommitteeMessage) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'Slot'
hh.PutUint64(uint64(s.Slot))
// Field (1) 'BeaconBlockRoot'
hh.PutBytes(s.BeaconBlockRoot[:])
// Field (2) 'ValidatorIndex'
hh.PutUint64(uint64(s.ValidatorIndex))
// Field (3) 'Signature'
hh.PutBytes(s.Signature[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the SyncCommitteeMessage object
func (s *SyncCommitteeMessage) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(s)
}