From 0dca6013e87e6bd13c242b950226710a264efdaa Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 28 Jan 2025 14:20:39 +0100 Subject: [PATCH 1/3] export block key, header key and keyBytesToHex --- core/rawdb/schema.go | 12 ++++++++++++ trie/encoding.go | 4 ++++ 2 files changed, 16 insertions(+) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index dbf010be0c..4043d6788d 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -167,6 +167,10 @@ func headerKey(number uint64, hash common.Hash) []byte { return append(append(headerPrefix, encodeBlockNumber(number)...), hash.Bytes()...) } +func HeaderKey(number uint64, hash common.Hash) []byte { + return headerKey(number, hash) +} + // headerTDKey = headerPrefix + num (uint64 big endian) + hash + headerTDSuffix func headerTDKey(number uint64, hash common.Hash) []byte { return append(headerKey(number, hash), headerTDSuffix...) @@ -187,11 +191,19 @@ func blockBodyKey(number uint64, hash common.Hash) []byte { return append(append(blockBodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...) } +func BlockBodyKey(number uint64, hash common.Hash) []byte { + return blockBodyKey(number, hash) +} + // blockReceiptsKey = blockReceiptsPrefix + num (uint64 big endian) + hash func blockReceiptsKey(number uint64, hash common.Hash) []byte { return append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...) } +func BlockReceiptsKey(number uint64, hash common.Hash) []byte { + return blockReceiptsKey(number, hash) +} + // txLookupKey = txLookupPrefix + hash func txLookupKey(hash common.Hash) []byte { return append(txLookupPrefix, hash.Bytes()...) diff --git a/trie/encoding.go b/trie/encoding.go index 3284d3f8f0..30103bb621 100644 --- a/trie/encoding.go +++ b/trie/encoding.go @@ -104,6 +104,10 @@ func keybytesToHex(str []byte) []byte { return nibbles } +func KeybytesToHex(str []byte) []byte { + return keybytesToHex(str) +} + // hexToKeybytes turns hex nibbles into key bytes. // This can only be used for keys of even length. func hexToKeybytes(hex []byte) []byte { From fe38b30b55ddd3007526d79545feee11f4fa7645 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Wed, 29 Jan 2025 04:05:01 +0100 Subject: [PATCH 2/3] export headerTDKey --- core/rawdb/schema.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 4043d6788d..3c811b9a71 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -176,6 +176,10 @@ func headerTDKey(number uint64, hash common.Hash) []byte { return append(headerKey(number, hash), headerTDSuffix...) } +func HeaderTDKey(number uint64, hash common.Hash) []byte { + return headerTDKey(number, hash) +} + // headerHashKey = headerPrefix + num (uint64 big endian) + headerHashSuffix func headerHashKey(number uint64) []byte { return append(append(headerPrefix, encodeBlockNumber(number)...), headerHashSuffix...) From af50cd6095afe4d15843583ab031d464ced5ec48 Mon Sep 17 00:00:00 2001 From: Maciej Kulawik Date: Tue, 4 Feb 2025 23:03:58 +0100 Subject: [PATCH 3/3] export rawdb.codeKey --- core/rawdb/schema.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/core/rawdb/schema.go b/core/rawdb/schema.go index 3c811b9a71..00311ad1cd 100644 --- a/core/rawdb/schema.go +++ b/core/rawdb/schema.go @@ -271,6 +271,10 @@ func configKey(hash common.Hash) []byte { return append(configPrefix, hash.Bytes()...) } +func ConfigKey(hash common.Hash) []byte { + return configKey(hash) +} + // genesisStateSpecKey = genesisPrefix + hash func genesisStateSpecKey(hash common.Hash) []byte { return append(genesisPrefix, hash.Bytes()...)