-
Notifications
You must be signed in to change notification settings - Fork 159
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 Blockheader #169
Refactor Blockheader #169
Conversation
blockchain/blocks/src/tipset.rs
Outdated
@@ -64,54 +66,50 @@ impl Tipset { | |||
if i > 0 { | |||
// Skip redundant check | |||
// check parent cids are equal | |||
if !headers[i].parents.equals(headers[0].parents.clone()) { | |||
if headers[i].parents() != headers[0].parents() { |
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.
This always compares header[0] with header[0] as parents() returns the cids for header[0]. The equals
method made a full comparison.
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.
my mistake, should have verified when I switched
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.
note: equals right now does the same as an equality check. Is there a plan to change this in the future? Right now it requires all cids to be in same order
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.
Not that I am aware, it just needs to ensure that the parent cids are equal
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.
but does the ordering matter? if not then the traditional compare would be sufficient, if not then this equals function doesn't do what you think it does
build()
(no validation or cache generation used for testing or specific generation) orbuild_and_validate()
(TODO for validating header and then generates bytes and Cid cache)update_cache
to do exactly this)Some of this can be opinionated, so please give opinions on how you think this should look to future proof our usage of it and not require more refactors.