From 3caa4613d99590cd5f9d0ff772f463ffcf698306 Mon Sep 17 00:00:00 2001 From: iceseer Date: Tue, 2 May 2023 21:44:53 +0300 Subject: [PATCH] fixed division to zero Signed-off-by: iceseer --- core/consensus/babe/impl/block_header_appender_impl.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/consensus/babe/impl/block_header_appender_impl.cpp b/core/consensus/babe/impl/block_header_appender_impl.cpp index d6f37565ef..eff5655b04 100644 --- a/core/consensus/babe/impl/block_header_appender_impl.cpp +++ b/core/consensus/babe/impl/block_header_appender_impl.cpp @@ -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(time_delta) + .count(); SL_LOG(self->logger_, self->speed_data_.block_number ? log::Level::INFO : static_cast(-1), @@ -144,10 +147,7 @@ namespace kagome::consensus::babe { block_delta, self->speed_data_.block_number, block_info.number, - block_delta - / std::chrono::duration_cast( - time_delta) - .count()); + td != 0ull ? block_delta / td : 0ull); self->speed_data_.block_number = block_info.number; self->speed_data_.time = now; }