Skip to content

Optimize SessionPersister trait for better ownership semantics#962

Merged
arminsabouri merged 1 commit intopayjoin:masterfrom
bc1cindy:fix/ref-args-persist-402
Aug 19, 2025
Merged

Optimize SessionPersister trait for better ownership semantics#962
arminsabouri merged 1 commit intopayjoin:masterfrom
bc1cindy:fix/ref-args-persist-402

Conversation

@bc1cindy
Copy link
Contributor

@bc1cindy bc1cindy commented Aug 16, 2025

Part of #402 - Take arguments by reference where possible

Optimize SessionPersister trait for better ownership semantics

  • Change save_event signature from &Self::SessionEvent to Self::SessionEvent
  • Implement Arc optimization for InMemoryTestPersister
  • Update all trait implementers across CLI and FFI modules
  • Optimize session replay to eliminate duplicate conversions and sender clones
  • Remove 19 unnecessary clones from persist operations

All tests passing

@coveralls
Copy link
Collaborator

coveralls commented Aug 16, 2025

Pull Request Test Coverage Report for Build 17043170207

Details

  • 43 of 43 (100.0%) changed or added relevant lines in 4 files are covered.
  • 7 unchanged lines in 1 file lost coverage.
  • Overall coverage increased (+0.06%) to 86.373%

Files with Coverage Reduction New Missed Lines %
payjoin/src/core/persist.rs 7 96.87%
Totals Coverage Status
Change from base Build 17019408534: 0.06%
Covered Lines: 7733
Relevant Lines: 8953

💛 - Coveralls

@bc1cindy bc1cindy marked this pull request as ready for review August 16, 2025 00:36
@bc1cindy
Copy link
Contributor Author

The Format test in CI continues to not run and this appears to be related to #956

@bc1cindy bc1cindy force-pushed the fix/ref-args-persist-402 branch from b2ecfc4 to be5e590 Compare August 16, 2025 22:31
@bc1cindy
Copy link
Contributor Author

The Format test in CI continues to not run and this appears to be related to #956

It was a conflict with homebrew rust! Uninstalled it and now the format test works perfectly in CI!

All checks passing

Copy link
Collaborator

@arminsabouri arminsabouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall great clean up! Just have a nit and a question. Thanks

- Change save_event signature from &Self::SessionEvent to Self::SessionEvent
- Implement Arc optimization for InMemoryTestPersister
- Update all trait implementers across CLI and FFI modules
- Optimize session replay to eliminate duplicate conversions and sender clones
- Remove 19 unnecessary clones from persist operations
@bc1cindy bc1cindy force-pushed the fix/ref-args-persist-402 branch from be5e590 to d7c1722 Compare August 18, 2025 14:13
@bc1cindy
Copy link
Contributor Author

bc1cindy commented Aug 18, 2025

Hey @arminsabouri, thanks for the review!

Fixed the destructuring nits, you were right, it's much cleaner with named bindings. Found a third occurrence following the same pattern and fixed that one too. All three now use RejectFatal(event, error) instead of the .0 and .1 access.

About the mem::take suggestion , I gave it a try but SendSession doesn't implement Default (got E0277 when I tested). Since we're explicitly resetting to the Uninitialized state rather than some generic default, mem::replace actually makes more sense here anyway. It's clearer about the intent.

Let me know if you spot anything else!

All checks passing and ready for re-review.

Copy link
Collaborator

@arminsabouri arminsabouri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

utACK d7c1722

@arminsabouri arminsabouri merged commit 423788d into payjoin:master Aug 19, 2025
16 checks passed
@benalleng benalleng mentioned this pull request Aug 20, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants