Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor ProofNode to use interface #2176

Merged
merged 3 commits into from
Sep 24, 2024
Merged

Conversation

weiihann
Copy link
Contributor

@weiihann weiihann commented Sep 24, 2024

Description

This PR refactors the ProofNode struct into ProofNode interface where Binary and Edge implements it.

Rationale

Throughout the codebase, I noticed a similar pattern with ProofNode, that is:

if proofNode.Binary != nil {
  // ... do something
} else if proofNode.Edge != nil {
  // ... do something
}

This suggests that a ProofNode can be either a Binary node or an Edge node, but not both simultaneously. Therefore, ProofNode should be represented as an interface. This approach makes the code more intuitive and easier to read.

Copy link

codecov bot commented Sep 24, 2024

Codecov Report

Attention: Patch coverage is 88.88889% with 9 lines in your changes missing coverage. Please review.

Project coverage is 78.43%. Comparing base (67430de) to head (bd81c7b).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
core/trie/proof.go 88.88% 7 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2176      +/-   ##
==========================================
- Coverage   78.47%   78.43%   -0.05%     
==========================================
  Files         100      100              
  Lines        9234     9240       +6     
==========================================
+ Hits         7246     7247       +1     
- Misses       1350     1354       +4     
- Partials      638      639       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

core/trie/proof.go Outdated Show resolved Hide resolved
@rianhughes rianhughes self-requested a review September 24, 2024 11:11
core/trie/proof.go Outdated Show resolved Hide resolved
core/trie/proof.go Outdated Show resolved Hide resolved
core/trie/proof.go Outdated Show resolved Hide resolved
core/trie/proof.go Outdated Show resolved Hide resolved
core/trie/proof.go Outdated Show resolved Hide resolved
@kirugan kirugan merged commit 38638ca into main Sep 24, 2024
10 checks passed
@kirugan kirugan deleted the weiihann/refactor-proofnode branch September 24, 2024 12:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants