Skip to content

Commit d4f3a32

Browse files
committed
Handle payment_store update failure in PaymentClaimable.
1 parent 3f1c842 commit d4f3a32

File tree

1 file changed

+29
-20
lines changed

1 file changed

+29
-20
lines changed

src/event.rs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -498,11 +498,13 @@ where
498498
status: Some(PaymentStatus::Failed),
499499
..PaymentDetailsUpdate::new(payment_id)
500500
};
501-
self.payment_store.update(&update).unwrap_or_else(|e| {
502-
log_error!(self.logger, "Failed to access payment store: {}", e);
503-
panic!("Failed to access payment store");
504-
});
505-
return Ok(());
501+
return match self.payment_store.update(&update) {
502+
Ok(_) => Ok(()),
503+
Err(e) => {
504+
log_error!(self.logger, "Failed to access payment store: {}", e);
505+
Err(ReplayEvent())
506+
},
507+
};
506508
}
507509

508510
if info.status == PaymentStatus::Succeeded
@@ -520,11 +522,13 @@ where
520522
status: Some(PaymentStatus::Failed),
521523
..PaymentDetailsUpdate::new(payment_id)
522524
};
523-
self.payment_store.update(&update).unwrap_or_else(|e| {
524-
log_error!(self.logger, "Failed to access payment store: {}", e);
525-
panic!("Failed to access payment store");
526-
});
527-
return Ok(());
525+
return match self.payment_store.update(&update) {
526+
Ok(_) => Ok(()),
527+
Err(e) => {
528+
log_error!(self.logger, "Failed to access payment store: {}", e);
529+
Err(ReplayEvent())
530+
},
531+
};
528532
}
529533

530534
let max_total_opening_fee_msat = match info.kind {
@@ -559,11 +563,13 @@ where
559563
status: Some(PaymentStatus::Failed),
560564
..PaymentDetailsUpdate::new(payment_id)
561565
};
562-
self.payment_store.update(&update).unwrap_or_else(|e| {
563-
log_error!(self.logger, "Failed to access payment store: {}", e);
564-
panic!("Failed to access payment store");
565-
});
566-
return Ok(());
566+
return match self.payment_store.update(&update) {
567+
Ok(_) => Ok(()),
568+
Err(e) => {
569+
log_error!(self.logger, "Failed to access payment store: {}", e);
570+
Err(ReplayEvent())
571+
},
572+
};
567573
}
568574

569575
// If this is known by the store but ChannelManager doesn't know the preimage,
@@ -715,10 +721,13 @@ where
715721
status: Some(PaymentStatus::Failed),
716722
..PaymentDetailsUpdate::new(payment_id)
717723
};
718-
self.payment_store.update(&update).unwrap_or_else(|e| {
719-
log_error!(self.logger, "Failed to access payment store: {}", e);
720-
panic!("Failed to access payment store");
721-
});
724+
return match self.payment_store.update(&update) {
725+
Ok(_) => Ok(()),
726+
Err(e) => {
727+
log_error!(self.logger, "Failed to access payment store: {}", e);
728+
Err(ReplayEvent())
729+
},
730+
};
722731
}
723732
},
724733
LdkEvent::PaymentClaimed {
@@ -796,7 +805,7 @@ where
796805
payment_id,
797806
e
798807
);
799-
panic!("Failed to access payment store");
808+
return Err(ReplayEvent());
800809
},
801810
}
802811

0 commit comments

Comments
 (0)