diff --git a/broker/src/chain_tracker.rs b/broker/src/chain_tracker.rs index 11a8bd6..c4f5331 100644 --- a/broker/src/chain_tracker.rs +++ b/broker/src/chain_tracker.rs @@ -4,8 +4,8 @@ use anyhow::Result; use async_trait::async_trait; use rocket::tokio; use sphinx_signer::{parser, sphinx_glyph::topics}; -use std::time::Duration; use std::thread; +use std::time::Duration; use tokio::sync::mpsc; use vls_protocol::Error; use vls_protocol_client::{ClientResult, SignerPort}; diff --git a/broker/src/looper.rs b/broker/src/looper.rs index 2eff097..ffe280a 100644 --- a/broker/src/looper.rs +++ b/broker/src/looper.rs @@ -5,7 +5,6 @@ use log::*; use rocket::tokio::sync::mpsc; use secp256k1::PublicKey; use sphinx_signer::{parser, sphinx_glyph::topics}; -use std::num::Wrapping; use std::sync::atomic::{AtomicU16, Ordering}; use std::thread; use std::time::Duration; @@ -99,7 +98,7 @@ impl SignerLoop { fn do_loop(&mut self, settings: Option) -> Result<()> { // This counter is only used in the root loop to periodically send heartbeats to the hardware signer - let mut send_heartbeat = Wrapping(0u8); + let mut send_heartbeat = 0u8; loop { let raw_msg = self.client.read_raw()?; // debug!("loop {}: got raw", self.log_prefix); @@ -147,14 +146,13 @@ impl SignerLoop { self.client.write_vec(reply)?; // Only send heartbeat messages from the root loop, as roothandler alone can process them, not channelhandler // Send it every ten messages to prune extraneous data on hardware signer - if self.client_id.is_none() && send_heartbeat % Wrapping(10u8) == Wrapping(0u8) - { + if self.client_id.is_none() && send_heartbeat % 10u8 == 0u8 { let beat = msgs::GetHeartbeat {}; let _ = self.handle_message(beat.as_vec(), false)?; } } } - send_heartbeat += 1; + send_heartbeat = send_heartbeat.wrapping_add(1u8); } } diff --git a/broker/src/mqtt.rs b/broker/src/mqtt.rs index 0e3f51a..d0caa4a 100644 --- a/broker/src/mqtt.rs +++ b/broker/src/mqtt.rs @@ -185,7 +185,7 @@ fn pub_and_wait( drop(cs); if new_current != current { log::warn!("Client list changed, starting over!"); - counter = 0; + counter = 0u8; continue; } @@ -199,7 +199,7 @@ fn pub_and_wait( if new_current != current { log::info!("Client list changed, starting over!"); drop(cs); - counter = 0; + counter = 0u8; rep = None; break; } @@ -234,7 +234,7 @@ fn pub_and_wait( } else { log::debug!("retrying indefinitely"); } - counter = counter + 1; + counter = counter.wrapping_add(1u8); } }