Skip to content

Expose shortid method for SessionContext#698

Merged
arminsabouri merged 1 commit intopayjoin:masterfrom
benalleng:shortid-method
May 19, 2025
Merged

Expose shortid method for SessionContext#698
arminsabouri merged 1 commit intopayjoin:masterfrom
benalleng:shortid-method

Conversation

@benalleng
Copy link
Collaborator

@benalleng benalleng commented May 15, 2025

By exposing the shortid method for SessionContext it allows us to be able to track the id across all psbt intermediate steps and allows us to not need this method duplicated in every step of the process.

Closes #697

By exposing the shortid method for SessionContext it allows us to be
able to track the id across all psbt intermediate steps and allows us to
not need this method duplicated in every step of the process.
@benalleng benalleng requested a review from arminsabouri May 15, 2025 14:30
@coveralls
Copy link
Collaborator

Pull Request Test Coverage Report for Build 15047681959

Details

  • 12 of 15 (80.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.005%) to 82.242%

Changes Missing Coverage Covered Lines Changed/Added Lines %
payjoin/src/receive/v2/persist.rs 1 2 50.0%
payjoin/src/receive/multiparty/mod.rs 4 6 66.67%
Totals Coverage Status
Change from base Build 15031183812: -0.005%
Covered Lines: 5474
Relevant Lines: 6656

💛 - Coveralls

@benalleng
Copy link
Collaborator Author

benalleng commented May 15, 2025

Curious if you think you are satified with the changes to the method slightly to address #612 here too

@benalleng
Copy link
Collaborator Author

@nothingmuch I remember hearing you said you were planning on removing the id() method would that change ultimately make this change moot?

@nothingmuch
Copy link
Collaborator

nothingmuch commented May 15, 2025

@nothingmuch I remember hearing you said you were planning on removing the id() method would that change ultimately make this change moot?

hmm, i don't think so

If i understand the code correctly, .id() is only used in #642 for error reporting, the full SessionContexts are compared to each other directly, so this is just a way of reporting the sessions that this error condition is related to?

the idea of computing the ShortId derived from the receiver key associated with the session still make sense, we just wanted to move away from relying on the same short ID as the database key, as in here:

pub struct ReceiverToken(ShortId);

i was referring to this method:

pub fn id(&self) -> ShortId { id(&self.context.s) }

but honestly i kinda misspoke, i didn't consider if we need it for other reasons i just assumed we don't, and what i really meant was just to no longer use this for keying the database

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.

Simpler, cleaner and removes duplicate code. Seems like a win to me!

}

/// The per-session identifier
pub fn id(&self) -> ShortId {
Copy link
Collaborator

Choose a reason for hiding this comment

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

One thing did just come to mind. Does this need to be pub? IIRC only internal types need access to this?
Seems like it was pub previously as well.

Copy link
Contributor

Choose a reason for hiding this comment

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

should be pub(crate) because it's on SessionContext and not receiver.id()

@DanGould
Copy link
Contributor

DanGould commented May 19, 2025

If i understand the code correctly, .id() is only used in #642 for error reporting, the full SessionContexts are compared to each other directly, so this is just a way of reporting the sessions that this error condition is related to?

-- @nothingmuch

See BullBitcoin source id() usage. receiver.id() is used to identify the saved thing in the DB downstream until we get SessionEventLog. That's why this is pub.

@arminsabouri arminsabouri merged commit beaff5e into payjoin:master May 19, 2025
7 checks passed
spacebear21 added a commit to spacebear21/rust-payjoin that referenced this pull request May 19, 2025
It was removed from rust-payjoin in payjoin#698.
@spacebear21 spacebear21 mentioned this pull request May 19, 2025
spacebear21 added a commit to spacebear21/rust-payjoin that referenced this pull request May 20, 2025
It was removed from rust-payjoin in payjoin#698.
spacebear21 added a commit that referenced this pull request May 22, 2025
)

Because SessionContext itself is limited in visibility to the crate this
id method should also be limited to crate visibility.

Based on the conversation linked here,
#698 (comment)
Johnosezele pushed a commit to Johnosezele/rust-payjoin that referenced this pull request Jun 2, 2025
It was removed from rust-payjoin in payjoin#698.
node-smithxby72w added a commit to node-smithxby72w/rust-payjoin that referenced this pull request Sep 28, 2025
…713)

Because SessionContext itself is limited in visibility to the crate this
id method should also be limited to crate visibility.

Based on the conversation linked here,
payjoin/rust-payjoin#698 (comment)
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.

Expose Short Id on SessionContext

5 participants