mirror of
https://github.com/lightningdevkit/rust-lightning.git
synced 2025-02-24 23:08:36 +01:00
Remove pending probes on update_fail
Previously we had a memory leak where probes would not be removed from outbound_payments on htlc fail
This commit is contained in:
parent
30b9d9fbea
commit
a2b956d46e
2 changed files with 10 additions and 5 deletions
|
@ -1062,17 +1062,19 @@ impl OutboundPayments {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if !payment_is_probe && (!is_retryable_now || !payment_retryable || retry.is_none()) {
|
if payment_is_probe || !is_retryable_now || !payment_retryable || retry.is_none() {
|
||||||
let _ = payment.get_mut().mark_abandoned(); // we'll only Err if it's a legacy payment
|
let _ = payment.get_mut().mark_abandoned(); // we'll only Err if it's a legacy payment
|
||||||
is_retryable_now = false;
|
is_retryable_now = false;
|
||||||
}
|
}
|
||||||
if payment.get().remaining_parts() == 0 {
|
if payment.get().remaining_parts() == 0 {
|
||||||
all_paths_failed = true;
|
all_paths_failed = true;
|
||||||
if payment.get().abandoned() {
|
if payment.get().abandoned() {
|
||||||
full_failure_ev = Some(events::Event::PaymentFailed {
|
if !payment_is_probe {
|
||||||
payment_id: *payment_id,
|
full_failure_ev = Some(events::Event::PaymentFailed {
|
||||||
payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
|
payment_id: *payment_id,
|
||||||
});
|
payment_hash: payment.get().payment_hash().expect("PendingOutboundPayments::RetriesExceeded always has a payment hash set"),
|
||||||
|
});
|
||||||
|
}
|
||||||
payment.remove();
|
payment.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -941,6 +941,7 @@ fn successful_probe_yields_event() {
|
||||||
},
|
},
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
|
assert!(!nodes[0].node.has_pending_payments());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -986,6 +987,7 @@ fn failed_probe_yields_event() {
|
||||||
},
|
},
|
||||||
_ => panic!(),
|
_ => panic!(),
|
||||||
};
|
};
|
||||||
|
assert!(!nodes[0].node.has_pending_payments());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -1040,6 +1042,7 @@ fn onchain_failed_probe_yields_event() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
assert!(found_probe_failed);
|
assert!(found_probe_failed);
|
||||||
|
assert!(!nodes[0].node.has_pending_payments());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|
Loading…
Add table
Reference in a new issue