Skip to content

Commit

Permalink
fix logic errors
Browse files Browse the repository at this point in the history
  • Loading branch information
hansieodendaal committed Oct 11, 2024
1 parent bd75bdb commit 3e76b55
Show file tree
Hide file tree
Showing 4 changed files with 136 additions and 102 deletions.
18 changes: 3 additions & 15 deletions base_layer/wallet/src/base_node_service/monitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,11 +130,7 @@ where
.obtain_base_node_wallet_rpc_client()
.await
.ok_or(BaseNodeMonitorError::NodeShuttingDown)?;
trace!(
target: LOG_TARGET,
"Obtain RPC client {} ms",
timer.elapsed().as_millis()
);
trace!(target: LOG_TARGET, "Obtain RPC client {} ms", timer.elapsed().as_millis());

let base_node_id = match self.wallet_connectivity.get_current_base_node_peer_node_id() {
Some(n) => n,
Expand All @@ -155,22 +151,14 @@ where
.and_then(|metadata| {
ChainMetadata::try_from(metadata).map_err(BaseNodeMonitorError::InvalidBaseNodeResponse)
})?;
trace!(
target: LOG_TARGET,
"Obtain tip info in {} ms",
timer.elapsed().as_millis()
);
trace!(target: LOG_TARGET, "Obtain tip info in {} ms", timer.elapsed().as_millis());

let timer = Instant::now();
let latency = match client.get_last_request_latency() {
Some(latency) => latency,
None => continue,
};
trace!(
target: LOG_TARGET,
"Obtain latency info in {} ms",
timer.elapsed().as_millis()
);
trace!(target: LOG_TARGET, "Obtain latency info in {} ms", timer.elapsed().as_millis());

self.db.set_chain_metadata(chain_metadata.clone())?;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ impl BaseNodePeerManager {
}

/// Get the last connection attempt stats
pub fn get_last_connection_attempt(&self) -> Option<Duration> {
pub fn time_since_last_connection_attempt(&self) -> Option<Duration> {
if let Some(stats) = self.last_connection_attempt.clone() {
if stats.peer_index == self.current_peer_index {
Some(stats.attempt_time.elapsed())
Expand All @@ -106,7 +106,7 @@ impl BaseNodePeerManager {

impl Display for BaseNodePeerManager {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
let last_connection_attempt = match self.get_last_connection_attempt() {
let last_connection_attempt = match self.time_since_last_connection_attempt() {
Some(stats) => format!("{:?}", stats.as_secs()),
None => "Never".to_string(),
};
Expand Down
Loading

0 comments on commit 3e76b55

Please sign in to comment.