-
Notifications
You must be signed in to change notification settings - Fork 5
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 issues when LIB recorded from previous shutdown is at the edge of a gap #213
Conversation
src/engine_plugin.cpp
Outdated
auto res = silkworm::db::read_canonical_header(txn, start_height); | ||
if(!res) return {}; | ||
|
||
for (int i = 0; i < 32; ++i) { |
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.
You can use !is_zero(res->prev_randao)
// the search process simple. | ||
SILK_INFO << "Search for block containing a valid eos id. Start from:" << "#" << start_height; | ||
silkworm::db::ROTxn txn(db_env); | ||
do { |
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.
why not just use while(start_height>0)
and decrement start_height
inside the while body?
while(--start_height > 0); | ||
return {}; | ||
} | ||
|
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.
// Alternative implementation
std::optional<silkworm::BlockHeader> res;
while(start_height>0) {
res = silkworm::db::read_canonical_header(txn, start_height);
if(res && !is_zero(res->prev_randao)) {
break;
}
--start_height;
}
return res;
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.
fixed as this
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.
Refactor to do while again to handle the genesis case properly.
Resolves #209