Fast ssz now expects HashTreeRootWith(hh ssz.HashWalker) (err error) in its HashTreeRoot interface. I believe the implementation is as simple as:
func (u *Uint256) HashTreeRootWith(hh ssz.HashWalker) (err error) {
bytes := make([]byte, 32)
bytes, err = u.MarshalSSZTo(bytes)
if err != nil {
return
}
hh.AppendBytes32(bytes)
return
}
but I have been known to make mistakes.
Further, fastssz's MarshalSSZTo(buf []byte) ([]byte, error) interface function expects the implementation to append to the end of buf, not to overwrite it. Unfortunately, this library overwrites instead, and a wrapper is needed (one is needed anyway for sszgen to work):
type Uint256 struct {
repr *uint256.Int `ssz:"-"`
}
[...]
func (u *Uint256) MarshalSSZTo(buf []byte) ([]byte, error) {
bytes, err := u.repr.MarshalSSZ()
if err != nil {
return nil, err
}
return append(buf, bytes...), nil
}
Fast ssz now expects
HashTreeRootWith(hh ssz.HashWalker) (err error)in itsHashTreeRootinterface. I believe the implementation is as simple as:but I have been known to make mistakes.
Further, fastssz's
MarshalSSZTo(buf []byte) ([]byte, error)interface function expects the implementation to append to the end ofbuf, not to overwrite it. Unfortunately, this library overwrites instead, and a wrapper is needed (one is needed anyway for sszgen to work):