Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions payjoin/src/receive/v2/persist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl persist::Value for Receiver<WithContext> {
/// Each event can be used to transition the receiver state machine to a new state
pub enum SessionEvent {
Created(SessionContext),
UncheckedProposal(v1::UncheckedProposal),
UncheckedProposal((v1::UncheckedProposal, Option<crate::HpkePublicKey>)),
Copy link
Contributor

@DanGould DanGould Jun 11, 2025

Choose a reason for hiding this comment

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

This 2-state type is misuse of Option IMO. If this is really what the type is, it should be a variant with Publickey and without public key

see misuse resistance here: https://youtu.be/qfknfCsICUM?si=tEqhp50GxCiYwwuZ&t=2142

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Agreed. But doesnt this line of thinking apply to SessionContext as well?

e: Option<HpkePublicKey>,

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This 2-state type is misuse of Option IMO.

This is not 2 states. The tuple represents what information was learned by handling the state transition.

Copy link
Contributor

@DanGould DanGould Jun 11, 2025

Choose a reason for hiding this comment

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

But doesnt this line of thinking apply to SessionContext as well?

Yes, perhaps SessionContext should be 2 separate structs

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I actually had it as 2 structs in the sketch branch but removed to reduce the diff.
How would you prioritize this? Techdebt or needs to be fixed now

Copy link
Contributor

Choose a reason for hiding this comment

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

can you point me to your fix?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I just checked the branch. It looks like I revereted that change. Might be somewhere in the history.
It was essentially a wrapper around session context with the reply key. Deref trick can be employed to get rid of the wrapper.session_context.X boilerplate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

git reflog is your friend :)

MaybeInputsOwned(v1::MaybeInputsOwned),
MaybeInputsSeen(v1::MaybeInputsSeen),
OutputsUnknown(v1::OutputsUnknown),
Expand Down Expand Up @@ -80,7 +80,11 @@ mod tests {

let test_cases = vec![
SessionEvent::Created(SHARED_CONTEXT.clone()),
SessionEvent::UncheckedProposal(unchecked_proposal),
SessionEvent::UncheckedProposal((unchecked_proposal.clone(), None)),
SessionEvent::UncheckedProposal((
unchecked_proposal,
Some(crate::HpkeKeyPair::gen_keypair().1),
)),
SessionEvent::MaybeInputsOwned(maybe_inputs_owned),
SessionEvent::MaybeInputsSeen(maybe_inputs_seen),
SessionEvent::OutputsUnknown(outputs_unknown),
Expand Down