import ./trie_defs, ./binary, ./binaries, ./db, ./trie_utils, ./trie_bitseq type DB = TrieDatabaseRef # TODO: replace the usages of this with regular asserts InvalidKeyError* = object of Defect template query(db: DB, nodeHash: TrieNodeKey): seq[byte] = db.get(nodeHash) proc checkIfBranchExistImpl(db: DB; nodeHash: TrieNodeKey; keyPrefix: TrieBitSeq): bool = if nodeHash == zeroHash: return false let node = parseNode(db.query(nodeHash)) case node.kind: of LEAF_TYPE: if keyPrefix.len != 0: return false return true of KV_TYPE: if keyPrefix.len == 0: return true if keyPrefix.len < node.keyPath.len: if keyPrefix == node.keyPath[0..