Skip to content

Commit

Permalink
mode: fix highest_block_number (#1305)
Browse files Browse the repository at this point in the history
  • Loading branch information
mriccobene authored Jul 2, 2023
1 parent 1c59386 commit 6d0aab1
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions silkworm/node/db/access_layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -916,8 +916,11 @@ BlockNum DataModel::highest_block_number() const {
const auto data{header_cursor->to_last(/*.throw_not_found*/ false)};
if (data.done && data.key.size() >= sizeof(uint64_t)) {
ByteView key = from_slice(data.key);
ByteView block_num = key.substr(0, sizeof(BlockNum));
return endian::load_big_u64(block_num.data());
ByteView block_num_data = key.substr(0, sizeof(BlockNum));
BlockNum block_num = endian::load_big_u64(block_num_data.data());
if (block_num > 0) { // skip genesis block if present
return block_num;
}
}

// If none is found on db, then ask the snapshot repository (if any) for highest block
Expand Down

0 comments on commit 6d0aab1

Please sign in to comment.