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 3cd235e
Showing 1 changed file with 19 additions and 23 deletions.
42 changes: 19 additions & 23 deletions teos/src/responder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,12 @@ impl Responder {
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 3cd235e

Please sign in to comment.