''' if len(full) < len(part): return False return full[:len(part)] == part (NODE_TYPE_BLANK, NODE_TYPE_LEAF, NODE_TYPE_EXTENSION, NODE_TYPE_BRANCH) = tuple(range(4)) def is_key_value_type(node_type): return node_type in [NODE_TYPE_LEAF, NODE_TYPE_EXTENSION] BLANK_NODE = b'' BLANK_ROOT = sha3rlp(BLANK_NODE) DEATH_ROW_OFFSET = 2**62 def transient_trie_exception(*args): raise Exception("Transient trie") class Trie: def __init__(self, db: BaseDB, root_hash=BLANK_ROOT, transient=False): '''it also present a dictionary like interface :param db key value database :root: blank or trie node in form of [key, value] or [v0,v1..v15,v] ''' self._db = db # Pass in a database object directly
NODE_TYPE_EXTENSION, NODE_TYPE_BRANCH ) = tuple(range(4)) def is_key_value_type(node_type): return node_type in [NODE_TYPE_LEAF, NODE_TYPE_EXTENSION] def key_nibbles_from_key_value_node(node): return without_terminator(unpack_to_nibbles(node[0])) BLANK_NODE = b'' BLANK_ROOT = sha3rlp(BLANK_NODE) DEATH_ROW_OFFSET = 2**62 def transient_trie_exception(*args): raise Exception("Transient trie") class Trie: def __init__(self, db: BaseDB, root_hash=BLANK_ROOT, transient=False): '''it also present a dictionary like interface :param db key value database :root: blank or trie node in form of [key, value] or [v0,v1..v15,v] '''