diff --git a/src/MempoolStatus.cpp b/src/MempoolStatus.cpp index d9b2b7a..75d9a54 100644 --- a/src/MempoolStatus.cpp +++ b/src/MempoolStatus.cpp @@ -24,11 +24,8 @@ void MempoolStatus::start_mempool_status_thread() { - if (mempool_refresh_time < 1) - { - // to protect from diviation by zero below. - mempool_refresh_time = 1; - } + // to protect from deviation by zero below. + mempool_refresh_time = std::max(1, mempool_refresh_time); if (!is_running) { @@ -39,8 +36,7 @@ MempoolStatus::start_mempool_status_thread() uint64_t loop_index {0}; // so that network status is checked every minute - uint64_t loop_index_divider = 60 / mempool_refresh_time; - loop_index_divider = loop_index_divider == 0 ? 1 : loop_index_divider; + uint64_t loop_index_divider = std::max(1, 60 / mempool_refresh_time); while (true) { @@ -192,7 +188,7 @@ MempoolStatus::read_mempool() - std::lock_guard lck (mempool_mutx); + Guard lck (mempool_mutx); // clear current mempool txs vector // repopulate it with each execution of read_mempool() @@ -265,7 +261,7 @@ MempoolStatus::read_network_info() vector MempoolStatus::get_mempool_txs() { - std::lock_guard lck (mempool_mutx); + Guard lck (mempool_mutx); return mempool_txs; } diff --git a/src/MempoolStatus.h b/src/MempoolStatus.h index bd3551f..25b9db6 100644 --- a/src/MempoolStatus.h +++ b/src/MempoolStatus.h @@ -22,6 +22,8 @@ namespace xmreg struct MempoolStatus { + using Guard = std::lock_guard; + struct mempool_tx { crypto::hash tx_hash;