Separate CClaimTrie into trie implementation and ClaimTrie / Write base template trie class #108
Labels
No labels
area: devops
area: discovery
area: docs
area: livestream
area: proposal
consider soon
Epic
good first issue
hacktoberfest
hard fork
help wanted
icebox
Invalid
level: 0
level: 1
level: 2
level: 3
level: 4
needs: exploration
needs: grooming
needs: priority
needs: repro
needs: tech design
on hold
priority: blocker
priority: high
priority: low
priority: medium
resilience
soft fork
Tom's Wishlist
type: bug
type: discussion
type: improvement
type: new feature
type: refactor
type: task
type: testing
unplanned
work in progress
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference: LBRYCommunity/lbrycrd#108
Loading…
Add table
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
The CClaimTrie class, which implements the Claim Trie, has a tight integration between the trie data structure and the logic involved in claims.
It would be nice if we had a base template trie class which the CClaimTrie class either inherits from, or used as a member variable (CClaimTrie would either way use a trie class where the node are CClaimTrieNodes). This will improve code readability and allow us to write unit tests exclusively for the trie class to verify its correctness instead of relying on integration tests.
Also, it will allow easier implementation of https://github.com/lbryio/lbrycrd/issues/106, as we should just be able to switch out the trie class while keeping the logic for claims intact.
I checked the class today, is there any way to find out which methods are responsible for the trie data structure and which ones are for the claim logic? Or that is kind of intuitive?
It's not intuitive at all (which is part of the problem) so here's some more details.
The "trie" data structure is your standard trie (aka prefix tie/digital trie) https://en.wikipedia.org/wiki/Trie . As far as I know, there is no deviation between the standard implementation and what we have implemented. Here are the important functions for this trie data structure that we use:
There is an insert() function implemented by updateName() which either adds a new node to the trie or replaces the old node with a new one: https://github.com/lbryio/lbrycrd/blob/master/src/claimtrie.cpp#L834
There is a find() / iterator (the iterator is left to right) function that traverses through the trie which is not implemented anywhere , but an example can be found here: https://github.com/lbryio/lbrycrd/blob/master/src/claimtrie.cpp#L915 (this kind of code is duplicated elsewhere and violates DRY principles) .
There is a erase() function which is implemented here that deletes a node and all its descendants https://github.com/lbryio/lbrycrd/blob/master/src/claimtrie.cpp#L879
Hope that makes a bit more sense.
I'm working on replacing the trie data structure with one from ethereum. When I do that, I'll separate the claim logic structure from the trie itself.