forked from attestantio/go-eth2-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
blstoexecutionchange_ssz.go
82 lines (62 loc) · 2.12 KB
/
blstoexecutionchange_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
// Code generated by fastssz. DO NOT EDIT.
// Hash: 1d60b2f7503ae62dbe1b1eec7aef63ac15e11b4caf0d99046583503ea742c88a
package capella
import (
"github.com/jefmcl/go-eth2-client/spec/phase0"
ssz "github.com/ferranbt/fastssz"
)
// MarshalSSZ ssz marshals the BLSToExecutionChange object
func (b *BLSToExecutionChange) MarshalSSZ() ([]byte, error) {
return ssz.MarshalSSZ(b)
}
// MarshalSSZTo ssz marshals the BLSToExecutionChange object to a target array
func (b *BLSToExecutionChange) MarshalSSZTo(buf []byte) (dst []byte, err error) {
dst = buf
// Field (0) 'ValidatorIndex'
dst = ssz.MarshalUint64(dst, uint64(b.ValidatorIndex))
// Field (1) 'FromBLSPubkey'
dst = append(dst, b.FromBLSPubkey[:]...)
// Field (2) 'ToExecutionAddress'
dst = append(dst, b.ToExecutionAddress[:]...)
return
}
// UnmarshalSSZ ssz unmarshals the BLSToExecutionChange object
func (b *BLSToExecutionChange) UnmarshalSSZ(buf []byte) error {
var err error
size := uint64(len(buf))
if size != 76 {
return ssz.ErrSize
}
// Field (0) 'ValidatorIndex'
b.ValidatorIndex = phase0.ValidatorIndex(ssz.UnmarshallUint64(buf[0:8]))
// Field (1) 'FromBLSPubkey'
copy(b.FromBLSPubkey[:], buf[8:56])
// Field (2) 'ToExecutionAddress'
copy(b.ToExecutionAddress[:], buf[56:76])
return err
}
// SizeSSZ returns the ssz encoded size in bytes for the BLSToExecutionChange object
func (b *BLSToExecutionChange) SizeSSZ() (size int) {
size = 76
return
}
// HashTreeRoot ssz hashes the BLSToExecutionChange object
func (b *BLSToExecutionChange) HashTreeRoot() ([32]byte, error) {
return ssz.HashWithDefaultHasher(b)
}
// HashTreeRootWith ssz hashes the BLSToExecutionChange object with a hasher
func (b *BLSToExecutionChange) HashTreeRootWith(hh ssz.HashWalker) (err error) {
indx := hh.Index()
// Field (0) 'ValidatorIndex'
hh.PutUint64(uint64(b.ValidatorIndex))
// Field (1) 'FromBLSPubkey'
hh.PutBytes(b.FromBLSPubkey[:])
// Field (2) 'ToExecutionAddress'
hh.PutBytes(b.ToExecutionAddress[:])
hh.Merkleize(indx)
return
}
// GetTree ssz hashes the BLSToExecutionChange object
func (b *BLSToExecutionChange) GetTree() (*ssz.Node, error) {
return ssz.ProofTree(b)
}