Skip to content
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

Fixed division by zero #1588

Merged
merged 1 commit into from
May 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions core/consensus/babe/impl/block_header_appender_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,9 @@ namespace kagome::consensus::babe {
block_info.number - self->speed_data_.block_number;
auto const time_delta = now - self->speed_data_.time;
if (block_delta >= 10000 or time_delta >= std::chrono::minutes(1)) {
const auto td =
std::chrono::duration_cast<std::chrono::seconds>(time_delta)
.count();
SL_LOG(self->logger_,
self->speed_data_.block_number ? log::Level::INFO
: static_cast<log::Level>(-1),
Expand All @@ -144,10 +147,7 @@ namespace kagome::consensus::babe {
block_delta,
self->speed_data_.block_number,
block_info.number,
block_delta
/ std::chrono::duration_cast<std::chrono::seconds>(
time_delta)
.count());
td != 0ull ? block_delta / td : 0ull);
self->speed_data_.block_number = block_info.number;
self->speed_data_.time = now;
}
Expand Down