Skip to content

Commit

Permalink
Fixed division to zero (#1588)
Browse files Browse the repository at this point in the history
Signed-off-by: iceseer <iceseer@gmail.com>
  • Loading branch information
iceseer authored May 2, 2023
1 parent 2d2f2e1 commit f5988cb
Showing 1 changed file with 4 additions and 4 deletions.
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

0 comments on commit f5988cb

Please sign in to comment.