mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-22 04:36:42 +00:00
core/rawdb: refactor blockReceiptsKey to prealloc + copy
This commit is contained in:
parent
8d4d653572
commit
05887b8772
1 changed files with 9 additions and 1 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue