Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

export some of rawdb functions #402

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions core/rawdb/schema.go
Original file line number Diff line number Diff line change
Expand Up @@ -167,11 +167,19 @@ 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...)
}

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...)
Expand All @@ -187,11 +195,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()...)
Expand Down Expand Up @@ -255,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()...)
Expand Down
4 changes: 4 additions & 0 deletions trie/encoding.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down