Faster verification of HexaryTrieFog.explore inputs
- Dominant language
- Python
- Stars
- 111
- Forks
- 54
- Avg merge
- 27m
- Merged PRs (30d)
- 1
Description
> It seems like we should be able to do *better* if we modeled the data as a tree. IIUC the current approach is super-linear in runtime complexity.
```python
tree = {}
for segment in sub_segments:
sub_tree = tree
for nibble in segment:
sub_tree.setdefault(nibble, {})
if not isinstance(sub_tree[nibble], collections.Mapping):
... # we've detected a that `segment` is a superset of `sub_tree[nibble]`
sub_tree = sub_tree[nibble]
# once the segment terminates, we store the full segment at that position
# so that we can later detect segments that are prefixes of other segments.
sub_tree[segment[-1]] = segment
```
> I think the untested psuedocode above has `O(n)` complexity.
_Originally posted by @pipermerriam in https://github.com/ethereum/py-trie/pull/95_
Contributor guide
Assessment
This issue has not been assessed yet.