-
Notifications
You must be signed in to change notification settings - Fork 129
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
fix(lib/trie): Check for root in EncodeAndHash #2359
Changes from all commits
9852ed0
38d9157
32f4e17
d29ad2a
78690f0
7446b9c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -18,11 +18,11 @@ type recorder interface { | |||||||
|
||||||||
// findAndRecord search for a desired key recording all the nodes in the path including the desired node | ||||||||
func findAndRecord(t *Trie, key []byte, recorder recorder) error { | ||||||||
return find(t.root, key, recorder) | ||||||||
return find(t.root, key, recorder, true) | ||||||||
} | ||||||||
|
||||||||
func find(parent Node, key []byte, recorder recorder) error { | ||||||||
enc, hash, err := parent.EncodeAndHash() | ||||||||
func find(parent Node, key []byte, recorder recorder, isCurrentRoot bool) error { | ||||||||
enc, hash, err := parent.EncodeAndHash(isCurrentRoot) | ||||||||
if err != nil { | ||||||||
return err | ||||||||
} | ||||||||
|
@@ -49,5 +49,5 @@ func find(parent Node, key []byte, recorder recorder) error { | |||||||
return nil | ||||||||
} | ||||||||
|
||||||||
return find(b.Children[key[length]], key[length+1:], recorder) | ||||||||
return find(b.Children[key[length]], key[length+1:], recorder, false) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah rename as you wish. I just like setting constants inline to avoid looking up the argument names in the function. Lazy me I guess 😄 |
||||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit for extreme readability