Skip to content

Commit 84c6be3

Browse files
committed
Prefactor: Simplify state transitions, drop lock around PaymentQueue
The previous transition pattern of `OutboundJITChannelState` was never great: we'd take `&mut self`, only to also return `Self` and required updating the state externally to the state transtion methods. In addition, we previously wrapped `PaymentQueue` in an `Arc<Mutex<..>>` to avoid cloning them during state transtions. Here, we clean up all of this, having the state transtion methods updating the state in-place and merely returning an `action` in the method's `Result`s. We also use `core::mem::take` to move the `payment_queue` to the new states without reallocation.
1 parent 2c3f11d commit 84c6be3

File tree

2 files changed

+167
-161
lines changed

2 files changed

+167
-161
lines changed

lightning-liquidity/src/lsps2/payment_queue.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ impl PaymentQueue {
5454
}
5555
}
5656

57+
impl Default for PaymentQueue {
58+
fn default() -> Self {
59+
Self { payments: Vec::new() }
60+
}
61+
}
62+
5763
#[cfg(test)]
5864
mod tests {
5965
use super::*;

0 commit comments

Comments
 (0)