Commit 8b995e6
committed
Prefactor: Simplify state transitions, drop lock around
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.PaymentQueue
1 parent 0d7b1d3 commit 8b995e6
File tree
2 files changed
+147
-173
lines changed- lightning-liquidity/src/lsps2
2 files changed
+147
-173
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | 14 | | |
22 | 15 | | |
23 | 16 | | |
| |||
55 | 48 | | |
56 | 49 | | |
57 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
0 commit comments