Remove cli loops#1734
Conversation
0ceb3a8 to
d0bd8af
Compare
Coverage Report for CI Build 29265799698Coverage increased (+0.2%) to 86.174%Details
Uncovered Changes
Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
Replace the loops in the v2 sender and receiver flows with a driver: each step function performs one state transition and returns the next SendSession or ReceiveSession state, and process_sender_session/process_receiver_session loop over dispatch until the session terminates.
Wrap process_receiver_session in a select against the interrupt channel in receive_payjoin, mirroring how send_payjoin guards the sender driver. This is safe at any phase: transitions persist to the event log with no await between transition and save, so an interrupted session resumes from its last saved state via the resume command. The interrupt message now includes the session id, and read_from_directory becomes a plain single-step function like the other state handlers.
d0bd8af to
32630ff
Compare
bc1cindy
left a comment
There was a problem hiding this comment.
nice refactor!
the driver reads much cleaner than the recursion, and moving the interrupt select! up to wrap the whole receive session is a good improvement
| }; | ||
|
|
||
| match session.process_error_response(&err_bytes, err_ctx).save(persister) { | ||
| Ok(_) => Ok(ReceiveSession::Closed(ReceiverSessionOutcome::Aborted)), |
There was a problem hiding this comment.
success here returns Closed(Aborted) and driver maps it to Err("Session closed") (L809)
this path returned Ok(()) before
There was a problem hiding this comment.
Thanks for reviewing. Yeah I had noticed that too. Tbh I think the driver should not return an error just bc the session is closed. I am inclined to change this Err to Ok, what do you think? This is also how sender side is.
Also fyi this is gonna need some rebase and scope is going to expand a bit. Will let you know when ready for re-review.
|
Closed as superseded by #1737 |
Replace the loops in the v2 sender and receiver flows with a driver: each step function performs one state transition and returns the next SendSession or ReceiveSession state, and process_sender_session/process_receiver_session loop over dispatch until the session terminates. This is now feasible because the transient errors return the next state to be processed.
This was created as a suggested follow up from #1724 (comment).
Claude Fable was used to assist in creating these code changes.
Pull Request Checklist
Please confirm the following before requesting review:
AI
in the body of this PR.