diff --git a/core/types/block.go b/core/types/block.go index 61877c4db7..42f8c6fd04 100644 --- a/core/types/block.go +++ b/core/types/block.go @@ -459,24 +459,15 @@ func CalcUncleHash(uncles []*Header) common.Hash { // CalcRequestsHash creates the block requestsHash value for a list of requests. func CalcRequestsHash(requests [][]byte) common.Hash { - // compute intermediate hashes - hashes := make([][32]byte, len(requests)) - h := sha256.New() - for i, item := range requests { - h.Reset() - h.Write(item) - var sum [32]byte - h.Sum(sum[:0]) - hashes[i] = sum + h1, h2 := sha256.New(), sha256.New() + var buf common.Hash + for _, item := range requests { + h1.Reset() + h1.Write(item) + h2.Write(h1.Sum(buf[:0])) } - // final hash - h.Reset() - for _, hash := range hashes { - h.Write(hash[:]) - } - var result common.Hash - h.Sum(result[:0]) - return result + h2.Sum(buf[:0]) + return buf } // NewBlockWithHeader creates a block with the given header data. The