-
Notifications
You must be signed in to change notification settings - Fork 59
/
synccommitteecontribution_ssz.go
112 lines (86 loc) · 2.95 KB
/
synccommitteecontribution_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
// 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 SyncCommitteeContribution object
func (s *SyncCommitteeContribution) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SyncCommitteeContribution object to a target array
func (s *SyncCommitteeContribution) 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) 'SubcommitteeIndex'
dst = ssz.MarshalUint64(dst, s.SubcommitteeIndex)
// Field (3) 'AggregationBits'
if size := len(s.AggregationBits); size != 16 {
err = ssz.ErrBytesLengthFn("SyncCommitteeContribution.AggregationBits", size, 16)
return
}
dst = append(dst, s.AggregationBits...)
// Field (4) 'Signature'
dst = append(dst, s.Signature[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the SyncCommitteeContribution object
func (s *SyncCommitteeContribution) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 160 {
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) 'SubcommitteeIndex'
s.SubcommitteeIndex = ssz.UnmarshallUint64(buf[40:48])
// Field (3) 'AggregationBits'
if cap(s.AggregationBits) == 0 {
s.AggregationBits = make([]byte, 0, len(buf[48:64]))
}
s.AggregationBits = append(s.AggregationBits, buf[48:64]...)
// Field (4) 'Signature'
copy(s.Signature[:], buf[64:160])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SyncCommitteeContribution object
func (s *SyncCommitteeContribution) SizeSSZ() (size int) {
size = 160
return
}
// HashTreeRoot ssz hashes the SyncCommitteeContribution object
func (s *SyncCommitteeContribution) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SyncCommitteeContribution object with a hasher
func (s *SyncCommitteeContribution) 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) 'SubcommitteeIndex'
hh.PutUint64(s.SubcommitteeIndex)
// Field (3) 'AggregationBits'
if size := len(s.AggregationBits); size != 16 {
err = ssz.ErrBytesLengthFn("SyncCommitteeContribution.AggregationBits", size, 16)
return
}
hh.PutBytes(s.AggregationBits)
// Field (4) 'Signature'
hh.PutBytes(s.Signature[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the SyncCommitteeContribution object
func (s *SyncCommitteeContribution) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(s)
}