Skip to content

Commit 378c3fa

Browse files
committed
f simln-lib/feat: report payments to sim_node scorer
This commit handles the case where a payment_hash being tracked does not have a payment path associated with it, meaning the payment was not dispatched and scorer should not be updated
1 parent b53265a commit 378c3fa

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

simln-lib/src/sim_node.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,17 @@ impl<T: SimNetwork, C: Clock> LightningNode for SimNode<T, C> {
751751
let track_result = res.map_err(|e| LightningError::TrackPaymentError(format!("channel receive err: {}", e)))?;
752752
if let Ok(ref payment_result) = track_result {
753753
let duration = self.clock.now().duration_since(UNIX_EPOCH)?;
754-
if payment_result.payment_outcome == PaymentOutcome::Success {
755-
self.scorer.lock().await.payment_path_successful(&in_flight.path, duration);
756-
} else if let PaymentOutcome::IndexFailure(index) = payment_result.payment_outcome {
757-
self.scorer.lock().await.payment_path_failed(&in_flight.path, index.try_into().unwrap(), duration);
754+
match &in_flight.path {
755+
Some(path) => {
756+
if payment_result.payment_outcome == PaymentOutcome::Success {
757+
self.scorer.lock().await.payment_path_successful(path, duration);
758+
} else if let PaymentOutcome::IndexFailure(index) = payment_result.payment_outcome {
759+
self.scorer.lock().await.payment_path_failed(path, index.try_into().unwrap(), duration);
760+
}
761+
},
762+
None => {
763+
log::warn!("No path found for payment hash {}, cannot update scorer.", hex::encode(hash.0));
764+
}
758765
}
759766
}
760767
track_result

0 commit comments

Comments
 (0)