261}
262
263// SizeSSZ --
264func (g *Gwei) SizeSSZ() int {265 return 8
266}
267
255}
256
257// MarshalSSZ --
258func (g *Gwei) MarshalSSZ() ([]byte, error) {259 marshalled := fssz.MarshalUint64([]byte{}, uint64(*g))
260 return marshalled, nil
261}
246}
247
248// MarshalSSZTo --
249func (g *Gwei) MarshalSSZTo(dst []byte) ([]byte, error) {250 marshalled, err := g.MarshalSSZ()
251 if err != nil {
252 return nil, err
237}
238
239// UnmarshalSSZ --
240func (g *Gwei) UnmarshalSSZ(buf []byte) error {241 if len(buf) != g.SizeSSZ() {
242 return fmt.Errorf("expected buffer of length %d received %d", g.SizeSSZ(), len(buf))
243 }
231}
232
233// HashTreeRootWith --
234func (g Gwei) HashTreeRootWith(hh *fssz.Hasher) error {235 hh.PutUint64(uint64(g))
236 return nil
237}
(Go's FAQ)[https://go.dev/doc/faq#methodsonvaluesorpointers] recommends that method receivers should be consistent. If some of the methods of the type must have pointer receivers, the rest should too, so the method set is consistent regardless of how the type is used. This is because value and pointer receivers have different method sets.
package main
type foo struct {
a int
}
func (f foo) a() {}
func (f *foo) b() {
f.a = 10
}
package main
type foo struct {
a int
}
func (f *foo) a() {}
func (f *foo) b() {
f.a = 10
}