Skip to content

Commit 0dca601

Browse files
committed
export block key, header key and keyBytesToHex
1 parent 4b72c5a commit 0dca601

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

core/rawdb/schema.go

+12
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ func headerKey(number uint64, hash common.Hash) []byte {
167167
return append(append(headerPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
168168
}
169169

170+
func HeaderKey(number uint64, hash common.Hash) []byte {
171+
return headerKey(number, hash)
172+
}
173+
170174
// headerTDKey = headerPrefix + num (uint64 big endian) + hash + headerTDSuffix
171175
func headerTDKey(number uint64, hash common.Hash) []byte {
172176
return append(headerKey(number, hash), headerTDSuffix...)
@@ -187,11 +191,19 @@ func blockBodyKey(number uint64, hash common.Hash) []byte {
187191
return append(append(blockBodyPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
188192
}
189193

194+
func BlockBodyKey(number uint64, hash common.Hash) []byte {
195+
return blockBodyKey(number, hash)
196+
}
197+
190198
// blockReceiptsKey = blockReceiptsPrefix + num (uint64 big endian) + hash
191199
func blockReceiptsKey(number uint64, hash common.Hash) []byte {
192200
return append(append(blockReceiptsPrefix, encodeBlockNumber(number)...), hash.Bytes()...)
193201
}
194202

203+
func BlockReceiptsKey(number uint64, hash common.Hash) []byte {
204+
return blockReceiptsKey(number, hash)
205+
}
206+
195207
// txLookupKey = txLookupPrefix + hash
196208
func txLookupKey(hash common.Hash) []byte {
197209
return append(txLookupPrefix, hash.Bytes()...)

trie/encoding.go

+4
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,10 @@ func keybytesToHex(str []byte) []byte {
104104
return nibbles
105105
}
106106

107+
func KeybytesToHex(str []byte) []byte {
108+
return keybytesToHex(str)
109+
}
110+
107111
// hexToKeybytes turns hex nibbles into key bytes.
108112
// This can only be used for keys of even length.
109113
func hexToKeybytes(hex []byte) []byte {

0 commit comments

Comments
 (0)