Commit 7c02ca2
committed
Refactor initiate_async_payment to improve separation of concerns
1. Previously, `initiate_async_payment` handled both the outbound payment
state update (marking a static invoice as received) and the message
queuing for async payments. This tightly coupled two distinct
responsibilities within `ChannelManager`.
2. This refactor **separates concerns** by moving message queuing into
a separate function, allowing `initiate_async_payment` to focus solely
on updating `pending_outbound_payments`. This paves the way for moving
message queuing to `flow.rs` in upcoming commits, ensuring
`MessageRouter` logic remains independent of `ChannelManager`.
3. **This introduces a behavior change:** Since `pending_outbound_payments`
is now handled separately, we drop PersistenceNotifierGuard before queuing
messages. As a result, `NotifyOption` is no longer called for the message
queuing process.
4. **Why is this safe?** Because `pending_async_payments_messages` is
**not under `total_consistency_lock`**, meaning it does not require
persistence notifications. This aligns with the lock order tree and
maintains correct locking discipline.
By making this change, we improve modularity, enforce a cleaner separation
between `ChannelManager` and `MessageRouter`, and remove unnecessary
persistence dependencies.1 parent 4457ca0 commit 7c02ca2
1 file changed
+40
-32
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4480 | 4480 | | |
4481 | 4481 | | |
4482 | 4482 | | |
4483 | | - | |
| 4483 | + | |
4484 | 4484 | | |
4485 | 4485 | | |
4486 | 4486 | | |
| |||
4502 | 4502 | | |
4503 | 4503 | | |
4504 | 4504 | | |
4505 | | - | |
4506 | | - | |
4507 | | - | |
4508 | | - | |
4509 | | - | |
4510 | | - | |
4511 | | - | |
4512 | | - | |
4513 | | - | |
4514 | | - | |
4515 | | - | |
4516 | | - | |
4517 | | - | |
4518 | | - | |
4519 | | - | |
4520 | | - | |
4521 | | - | |
4522 | | - | |
4523 | | - | |
4524 | | - | |
4525 | | - | |
4526 | | - | |
4527 | | - | |
4528 | | - | |
4529 | | - | |
4530 | | - | |
4531 | | - | |
4532 | | - | |
4533 | | - | |
4534 | | - | |
4535 | | - | |
4536 | 4505 | | |
4537 | 4506 | | |
4538 | 4507 | | |
4539 | 4508 | | |
4540 | 4509 | | |
4541 | 4510 | | |
| 4511 | + | |
| 4512 | + | |
| 4513 | + | |
| 4514 | + | |
| 4515 | + | |
| 4516 | + | |
| 4517 | + | |
| 4518 | + | |
| 4519 | + | |
| 4520 | + | |
| 4521 | + | |
| 4522 | + | |
| 4523 | + | |
| 4524 | + | |
| 4525 | + | |
| 4526 | + | |
| 4527 | + | |
| 4528 | + | |
| 4529 | + | |
| 4530 | + | |
| 4531 | + | |
| 4532 | + | |
| 4533 | + | |
| 4534 | + | |
| 4535 | + | |
| 4536 | + | |
| 4537 | + | |
| 4538 | + | |
| 4539 | + | |
| 4540 | + | |
| 4541 | + | |
| 4542 | + | |
| 4543 | + | |
| 4544 | + | |
| 4545 | + | |
| 4546 | + | |
| 4547 | + | |
| 4548 | + | |
| 4549 | + | |
4542 | 4550 | | |
4543 | 4551 | | |
4544 | 4552 | | |
| |||
0 commit comments