Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Save + load send receive payjoin v2 cli sessions for asynchronicity #136

Merged
merged 5 commits into from
Dec 14, 2023

Conversation

DanGould
Copy link
Contributor

close #134

@DanGould DanGould force-pushed the async-cli branch 2 times, most recently from 06b0243 to 540446a Compare December 13, 2023 18:30
@DanGould DanGould marked this pull request as ready for review December 13, 2023 22:42
@DanGould DanGould force-pushed the async-cli branch 3 times, most recently from 6bdda52 to d256e93 Compare December 14, 2023 02:56
@DanGould DanGould requested a review from jbesraa December 14, 2023 03:40
Copy link
Contributor

@jbesraa jbesraa left a comment

Choose a reason for hiding this comment

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

Looks great and very readable.
Added a couple of comments with questions/clarifications

@@ -1097,7 +1117,9 @@ fn serialize_url(
}

#[cfg(test)]
mod tests {
mod test {
const ORIGINAL_PSBT: &str = "cHNidP8BAHMCAAAAAY8nutGgJdyYGXWiBEb45Hoe9lWGbkxh/6bNiOJdCDuDAAAAAAD+////AtyVuAUAAAAAF6kUHehJ8GnSdBUOOv6ujXLrWmsJRDCHgIQeAAAAAAAXqRR3QJbbz0hnQ8IvQ0fptGn+votneofTAAAAAAEBIKgb1wUAAAAAF6kU3k4ekGHKWRNbA1rV5tR5kEVDVNCHAQcXFgAUx4pFclNVgo1WWAdN1SYNX8tphTABCGsCRzBEAiB8Q+A6dep+Rz92vhy26lT0AjZn4PRLi8Bf9qoB/CMk0wIgP/Rj2PWZ3gEjUkTlhDRNAQ0gXwTO7t9n+V14pZ6oljUBIQMVmsAaoNWHVMS02LfTSe0e388LNitPa1UQZyOihY+FFgABABYAFEb2Giu6c4KO5YW0pfw3lGp9jMUUAAA=";
Copy link
Contributor

Choose a reason for hiding this comment

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


#[cfg(feature = "v2")]
impl SendStore {
fn new() -> Result<Self> {
Copy link
Contributor

Choose a reason for hiding this comment

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

maybe we should export a trait to cover the impls we have in both SendStore and ReceiveStore.. could make it easier for developers

Copy link
Contributor Author

@DanGould DanGould Dec 14, 2023

Choose a reason for hiding this comment

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

Perphaps payjoin-io could become an public API in the future even including default ureq implementations. This would be a higher level abstraction than payjoin

However, even in the target mutiny implementation *Store traits wouldn't be of much use yet since they're using a database to persist data like this, not the file system.

@@ -211,7 +217,7 @@ impl<'a> RequestBuilder<'a> {
pub fn build_recommended(
self,
min_fee_rate: FeeRate,
) -> Result<RequestContext<'a>, CreateRequestError> {
Copy link
Contributor

Choose a reason for hiding this comment

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

whats the motivation for removing this? is it the Mutex that holding the store?

Copy link
Contributor Author

@DanGould DanGould Dec 14, 2023

Choose a reason for hiding this comment

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

In order to persist data it needs to all be owned by the same struct so that it can be deserialized. Otherwise, the serialized format would need to reference another part of data, which is what this 'a lifetime signified, that uri: PjUri<'a> was in memory in another part of the program.

Now RequestContext parses the uri from RequestBuilder and owns the data so it may be persisted.

@@ -539,7 +576,7 @@ impl App {
)?;

// Receive Check 1: Can Broadcast
let proposal = proposal.check_can_broadcast(|tx| {
let proposal = proposal.check_broadcast_suitability(None, |tx| {
Copy link
Contributor

Choose a reason for hiding this comment

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

this will solve #113 (comment) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

We only need to persist the session context `ContextV2`, the
ohttp::ClientResponse context is per-request and can be created
from the persisted state.
@DanGould
Copy link
Contributor Author

Updated readme & rebased on master but otherwise this is that same as when @jbesraa reviewed

@DanGould DanGould merged commit 23fd195 into payjoin:master Dec 14, 2023
5 checks passed
@DanGould DanGould deleted the async-cli branch December 14, 2023 16:58
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.

Persist payjoin-cli v2 sessions for asynchronous operation
2 participants