ApeWorX / ApeWorX/py-trie

Code Refactoring

Offen
#78 11 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
111
Forks
54
Ø Merge
27 Min.
Gemergte PRs (30 T.)
1

Beschreibung

### What was wrong?
The whole code base is a bit hard to read and could be structured better.

### How can it be fixed?
The code base can be refactored with the following improvements
* Make seperate classes for `Leaf Nodes`, `Branch Nodes`, `Extension Nodes` which in turn inherit a common class `BaseNode`. The class `BaseNode` should contain the following
* Type of the Node (`Leaf` or `Branch` or `Extension`)
* List of all the keys contained in the Node - (List of size 1 for `Extension` and `Leaf` nodes. List of size 16 for `Branch` nodes).
* `value` contained in the node (If has nothing, then `Null`)
* `get_all_children` method
* Node `Encode` and `Decode` methods
* `parse_node` method
* Common `BaseTrie` class should be implemented from which the `BinaryTrie` and the `HexaryTrie` should be implemented.
* Changing the test cases correspondingly to the above changes
* Adding Benchmarks to compare the performance (benchmark architecture similar to `py-evm`)

Beitragsleitfaden

Beitragsleitfaden öffnen

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.