From 05887b8772f60138b73fda06359ab20669b91989 Mon Sep 17 00:00:00 2001 From: Sahil-4555 Date: Tue, 16 Dec 2025 11:11:43 +0530 Subject: [PATCH] core/rawdb: refactor blockReceiptsKey to prealloc + copy --- core/rawdb/schema.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index a43b01e9d0..6b566d64df 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -235,7 +235,15 @@ func blockBodyKey(number uint64, hash common.Hash) []byte { // blockReceiptsKey = blockReceiptsPrefix + num (uint64 big endian) + hash func blockReceiptsKey(number uint64, hash common.Hash) []byte { - return append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...) + totalLen := len(blockReceiptsPrefix) + 8 + common.HashLength + out := make([]byte, totalLen) + + off := 0 + off += copy(out[off:], blockReceiptsPrefix) + off += copy(out[off:], encodeBlockNumber(number)) + copy(out[off:], hash.Bytes()) + + return out } // txLookupKey = txLookupPrefix + hash