Skip to content

Commit

Permalink
Sergi's suggestions 4
Browse files Browse the repository at this point in the history
  • Loading branch information
mariocynicys committed Aug 7, 2023
1 parent d60f998 commit 83b3872
Showing 1 changed file with 20 additions and 24 deletions.
44 changes: 20 additions & 24 deletions teos/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,17 +137,17 @@ impl Responder {
}
}

/// Returns whether the [Responder] has been created from scratch (fresh) or from backed-up data.
/// Returns whether the [Responder] have been created from scratch (fresh) or from backed-up data.
pub fn is_fresh(&self) -> bool {
self.get_trackers_count() == 0
}

/// Gets the total number of trackers in the responder.
/// Gets the total number of trackers in the [Responder].
pub(crate) fn get_trackers_count(&self) -> usize {
self.dbm.lock().unwrap().get_trackers_count()
}

/// Checks whether the responder have gone through a reorg and some transactions should to be resent.
/// Checks whether the [Responder] have gone through a reorg and some transactions should to be resent.
fn coming_from_reorg(&self) -> bool {
!self.reorged_trackers.lock().unwrap().is_empty()
}
Expand Down Expand Up @@ -234,28 +234,24 @@ impl Responder {
.unwrap();
// Remove that uuid from reorged trackers if it was confirmed.
reorged_trackers.remove(&uuid);
} else {
match status {
// We will end up here with h >= current_height if this tracker was confirmed on another fork (reorg).
ConfirmationStatus::ConfirmedIn(h) if current_height > h => {
let confirmations = current_height - h;
if confirmations == constants::IRREVOCABLY_RESOLVED {
// Tracker is deep enough in the chain, it can be deleted
completed_trackers.push(uuid);
} else {
log::info!("{uuid} received a confirmation (count={confirmations})");
}
}
ConfirmationStatus::InMempoolSince(h) if current_height > h => {
// Log all transactions that have missed confirmations
log::info!(
"Transaction missed a confirmation: {} (missed conf count: {})",
penalty_txid,
current_height - h
);
}
_ => {}
} else if reorged_trackers.contains(&uuid) {
// Don't consider reorged trackers since they have wrong DB status.
continue;
} else if let ConfirmationStatus::ConfirmedIn(h) = status {
let confirmations = current_height - h;
if confirmations == constants::IRREVOCABLY_RESOLVED {
// Tracker is deep enough in the chain, it can be deleted
completed_trackers.push(uuid);
} else {
log::info!("{uuid} received a confirmation (count={confirmations})");
}
} else if let ConfirmationStatus::InMempoolSince(h) = status {
// Log all transactions that have missed confirmations
log::info!(
"Transaction missed a confirmation: {} (missed conf count: {})",
penalty_txid,
current_height - h
);
}
}

Expand Down

0 comments on commit 83b3872

Please sign in to comment.