Skip to content

Commit

Permalink
Refector to make code clear.
Browse files Browse the repository at this point in the history
  • Loading branch information
yarkinwho committed May 7, 2024
1 parent ef3593b commit 1108b05
Showing 1 changed file with 7 additions and 11 deletions.
18 changes: 7 additions & 11 deletions src/engine_plugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,19 +142,15 @@ class engine_plugin_impl : std::enable_shared_from_this<engine_plugin_impl> {
// 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 {
auto res = silkworm::db::read_canonical_header(txn, start_height);
if(!res) return {};

for (int i = 0; i < 32; ++i) {
if (res->prev_randao.bytes[i]) {
SILK_INFO << "Found block at: " << "#" << start_height;
return res;
}
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;
}
while(--start_height > 0);
return {};
return res;
}

std::optional<silkworm::Block> get_canonical_block_at_height(std::optional<uint64_t> height) {
Expand Down

0 comments on commit 1108b05

Please sign in to comment.