forked from ferranbt/fastssz
-
Notifications
You must be signed in to change notification settings - Fork 0
/
case4_encoding.go
134 lines (108 loc) · 2.68 KB
/
case4_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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
// Code generated by fastssz. DO NOT EDIT.
// Hash: 66053eefcc6dcfad1fe624b1b92bc03a744080d1627336be7d4457e7be9750c3
// Version: 0.1.2
package testcases
import (
ssz "github.com/ferranbt/fastssz"
"github.com/ferranbt/fastssz/sszgen/testcases/other"
alias "github.com/ferranbt/fastssz/sszgen/testcases/other2"
)
// MarshalSSZ ssz marshals the Case4 object
func (c *Case4) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(c)
}
// MarshalSSZTo ssz marshals the Case4 object to a target array
func (c *Case4) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'A'
if dst, err = c.A.MarshalSSZTo(dst); err != nil {
return
}
// Field (1) 'B'
if c.B == nil {
c.B = new(other.Case4Interface)
}
if dst, err = c.B.MarshalSSZTo(dst); err != nil {
return
}
// Field (2) 'C'
dst = ssz.MarshalUint64(dst, uint64(c.C))
// Field (3) 'D'
if size := len(c.D); size != 96 {
err = ssz.ErrBytesLengthFn("Case4.D", size, 96)
return
}
dst = append(dst, c.D...)
// Field (4) 'E'
dst = append(dst, c.E[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the Case4 object
func (c *Case4) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 392 {
return ssz.ErrSize
}
// Field (0) 'A'
if err = c.A.UnmarshalSSZ(buf[0:96]); err != nil {
return err
}
// Field (1) 'B'
if c.B == nil {
c.B = new(other.Case4Interface)
}
if err = c.B.UnmarshalSSZ(buf[96:192]); err != nil {
return err
}
// Field (2) 'C'
c.C = alias.Case4Slot(ssz.UnmarshallUint64(buf[192:200]))
// Field (3) 'D'
if cap(c.D) == 0 {
c.D = other.Case4Bytes(make([]byte, 0, len(buf[200:296])))
}
c.D = append(c.D, buf[200:296]...)
// Field (4) 'E'
copy(c.E[:], buf[296:392])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the Case4 object
func (c *Case4) SizeSSZ() (size int) {
size = 392
return
}
// HashTreeRoot ssz hashes the Case4 object
func (c *Case4) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(c)
}
// HashTreeRootWith ssz hashes the Case4 object with a hasher
func (c *Case4) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'A'
if err = c.A.HashTreeRootWith(hh); err != nil {
return
}
// Field (1) 'B'
if c.B == nil {
c.B = new(other.Case4Interface)
}
if err = c.B.HashTreeRootWith(hh); err != nil {
return
}
// Field (2) 'C'
hh.PutUint64(uint64(c.C))
// Field (3) 'D'
if size := len(c.D); size != 96 {
err = ssz.ErrBytesLengthFn("Case4.D", size, 96)
return
}
hh.PutBytes(c.D)
// Field (4) 'E'
hh.PutBytes(c.E[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the Case4 object
func (c *Case4) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(c)
}