-
Notifications
You must be signed in to change notification settings - Fork 2
/
rootsForHistory_encoding.go
94 lines (80 loc) · 2.24 KB
/
rootsForHistory_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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
// Code generated by fastssz. DO NOT EDIT.
// Hash: 392022371031953539c833a4e646ed3a419b560d4ea1d7c087a1ef59bc0cf410
// Version: 0.1.3
package proof
import (
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the RootsForHistory object
func (r *RootsForHistory) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(r)
}
// MarshalSSZTo ssz marshals the RootsForHistory object to a target array
func (r *RootsForHistory) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'Roots'
if size := len(r.Roots); size != 8192 {
err = ssz.ErrVectorLengthFn("RootsForHistory.Roots", size, 8192)
return
}
for ii := 0; ii < 8192; ii++ {
if size := len(r.Roots[ii]); size != 32 {
err = ssz.ErrBytesLengthFn("RootsForHistory.Roots[ii]", size, 32)
return
}
dst = append(dst, r.Roots[ii]...)
}
return
}
// UnmarshalSSZ ssz unmarshals the RootsForHistory object
func (r *RootsForHistory) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 262144 {
return ssz.ErrSize
}
// Field (0) 'Roots'
r.Roots = make([][]byte, 8192)
for ii := 0; ii < 8192; ii++ {
if cap(r.Roots[ii]) == 0 {
r.Roots[ii] = make([]byte, 0, len(buf[0:262144][ii*32:(ii+1)*32]))
}
r.Roots[ii] = append(r.Roots[ii], buf[0:262144][ii*32:(ii+1)*32]...)
}
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the RootsForHistory object
func (r *RootsForHistory) SizeSSZ() (size int) {
size = 262144
return
}
// HashTreeRoot ssz hashes the RootsForHistory object
func (r *RootsForHistory) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(r)
}
// HashTreeRootWith ssz hashes the RootsForHistory object with a hasher
func (r *RootsForHistory) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'Roots'
{
if size := len(r.Roots); size != 8192 {
err = ssz.ErrVectorLengthFn("RootsForHistory.Roots", size, 8192)
return
}
subIndx := hh.Index()
for _, i := range r.Roots {
if len(i) != 32 {
err = ssz.ErrBytesLength
return
}
hh.Append(i)
}
hh.Merkleize(subIndx)
}
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the RootsForHistory object
func (r *RootsForHistory) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(r)
}