-
Notifications
You must be signed in to change notification settings - Fork 39
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
Conversation
06b0243
to
540446a
Compare
6bdda52
to
d256e93
Compare
There was a problem hiding this 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="; |
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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> { |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
payjoin-cli/src/app.rs
Outdated
@@ -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| { |
There was a problem hiding this comment.
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) ?
There was a problem hiding this comment.
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.
Updated readme & rebased on master but otherwise this is that same as when @jbesraa reviewed |
close #134