-
Notifications
You must be signed in to change notification settings - Fork 61
/
syncaggregate_encoding.go
78 lines (62 loc) · 1.9 KB
/
syncaggregate_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
// Code generated by fastssz. DO NOT EDIT.
// Hash: 00c3ecc9ba2fba242b66ec559fda8c6fe9d5f5c475d8af447a071f2344ee4110
package altair
import (
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the SyncAggregate object
func (s *SyncAggregate) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(s)
}
// MarshalSSZTo ssz marshals the SyncAggregate object to a target array
func (s *SyncAggregate) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'SyncCommitteeBits'
if len(s.SyncCommitteeBits) != 64 {
err = ssz.ErrBytesLength
return
}
dst = append(dst, s.SyncCommitteeBits...)
// Field (1) 'SyncCommitteeSignature'
dst = append(dst, s.SyncCommitteeSignature[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the SyncAggregate object
func (s *SyncAggregate) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 160 {
return ssz.ErrSize
}
// Field (0) 'SyncCommitteeBits'
if cap(s.SyncCommitteeBits) == 0 {
s.SyncCommitteeBits = make([]byte, 0, len(buf[0:64]))
}
s.SyncCommitteeBits = append(s.SyncCommitteeBits, buf[0:64]...)
// Field (1) 'SyncCommitteeSignature'
copy(s.SyncCommitteeSignature[:], buf[64:160])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the SyncAggregate object
func (s *SyncAggregate) SizeSSZ() (size int) {
size = 160
return
}
// HashTreeRoot ssz hashes the SyncAggregate object
func (s *SyncAggregate) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(s)
}
// HashTreeRootWith ssz hashes the SyncAggregate object with a hasher
func (s *SyncAggregate) HashTreeRootWith(hh *ssz.Hasher) (err error) {
indx := hh.Index()
// Field (0) 'SyncCommitteeBits'
if len(s.SyncCommitteeBits) != 64 {
err = ssz.ErrBytesLength
return
}
hh.PutBytes(s.SyncCommitteeBits)
// Field (1) 'SyncCommitteeSignature'
hh.PutBytes(s.SyncCommitteeSignature[:])
hh.Merkleize(indx)
return
}