# Nimbus # Copyright (c) 2023-2024 Status Research & Development GmbH # Licensed under either of # * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or # http://www.apache.org/licenses/LICENSE-2.0) # * MIT license ([LICENSE-MIT](LICENSE-MIT) or # http://opensource.org/licenses/MIT) # at your option. This file may not be copied, modified, or distributed except # according to those terms. # This implementation of getBranch on the CoreDbPhkRef type is a temporary solution # which can be removed once we get an equivient proc defined on the CoreDbPhkRef type # in the db layer. {.push raises: [].} import eth/[rlp, trie/nibbles], "."/[core_db] type TrieNodeKey = object hash: KeccakHash usedBytes: uint8 template len(key: TrieNodeKey): int = key.usedBytes.int template asDbKey(k: TrieNodeKey): untyped = doAssert k.usedBytes == 32 k.hash.data template extensionNodeKey(r: Rlp): auto = hexPrefixDecode r.listElem(0).toBytes proc getLocalBytes(x: TrieNodeKey): seq[byte] = ## This proc should be used on nodes using the optimization ## of short values within the key. doAssert x.usedBytes < 32 x.hash.data[0..