Skip to content

Commit 64802f3

Browse files
committed
f Avoid cloning pending payment ids
Avoid copying the full id list during manual BOLT11 lookups. Holding the index lock while reading the in-memory store does not change persistence ordering. Co-Authored-By: HAL 9000
1 parent 8302b2c commit 64802f3

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

src/payment/pending_payment_store.rs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,9 @@ where
244244
pub(crate) fn get_pending_manual_bolt11_by_payment_hash(
245245
&self, payment_hash: &PaymentHash,
246246
) -> Option<PendingPaymentDetails> {
247-
let ids = self
248-
.manual_bolt11_payment_hash_index
249-
.lock()
250-
.expect("lock")
251-
.get(payment_hash)
252-
.cloned()
253-
.unwrap_or_default();
254-
ids.into_iter().find_map(|id| self.inner.get(&id))
247+
let index = self.manual_bolt11_payment_hash_index.lock().expect("lock");
248+
let ids = index.get(payment_hash)?;
249+
ids.iter().find_map(|id| self.inner.get(id))
255250
}
256251

257252
fn build_manual_bolt11_payment_hash_index(

0 commit comments

Comments
 (0)