Compare commits

...

2 Commits

Author SHA1 Message Date
satushh
179fc5782c changelog 2026-01-13 20:27:58 +05:30
satushh
741debab34 avoid unnecessary buffer allocation 2026-01-13 20:22:31 +05:30
2 changed files with 6 additions and 8 deletions

View File

@@ -238,14 +238,9 @@ func recomputeRootFromLayerVariable(idx int, item [32]byte, layers [][]*[32]byte
// AddInMixin describes a method from which a length mixin is added to the
// provided root.
func AddInMixin(root [32]byte, length uint64) ([32]byte, error) {
rootBuf := new(bytes.Buffer)
if err := binary.Write(rootBuf, binary.LittleEndian, length); err != nil {
return [32]byte{}, errors.Wrap(err, "could not marshal eth1data votes length")
}
// We need to mix in the length of the slice.
rootBufRoot := make([]byte, 32)
copy(rootBufRoot, rootBuf.Bytes())
return ssz.MixInLength(root, rootBufRoot), nil
var rootBufRoot [32]byte
binary.LittleEndian.PutUint64(rootBufRoot[:], length)
return ssz.MixInLength(root, rootBufRoot[:]), nil
}
// Merkleize 32-byte leaves into a Merkle trie for its adequate depth, returning

View File

@@ -0,0 +1,3 @@
### Changed
- Avoid unnessary heap allocation while calling MixInLength