-
Notifications
You must be signed in to change notification settings - Fork 70
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
Migration to 0.3 & Async/Await #582
Changes from 7 commits
8f4b917
67095a3
e96d71b
fbf0ab1
b35da6b
5a3f36b
9ef91f7
2a02842
d335f4e
680a83e
26c82b4
bdb283d
b5a39f4
22d2aac
3ff26ae
44f65a1
5c60e39
4734309
738b606
3f1819c
3adeacb
b9488ad
fb0722c
737c044
d6e9fef
f831435
10f4cd0
d98f190
eec3843
3f7f6a8
d316689
4e301c5
d7437fe
8674b1f
b9a90c8
22fb5ba
6a70382
f8a83e7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,30 @@ | ||
use super::packet::*; | ||
use futures::Future; | ||
use futures::future::TryFutureExt; | ||
use interledger_service::*; | ||
use log::{debug, error}; | ||
use std::convert::TryFrom; | ||
|
||
/// Get the ILP address and asset details for a given account. | ||
pub fn get_ildcp_info<S, A>( | ||
service: &mut S, | ||
account: A, | ||
) -> impl Future<Item = IldcpResponse, Error = ()> | ||
pub async fn get_ildcp_info<S, A>(service: &mut S, account: A) -> Result<IldcpResponse, ()> | ||
where | ||
S: IncomingService<A>, | ||
A: Account, | ||
{ | ||
let prepare = IldcpRequest {}.to_prepare(); | ||
service | ||
let fulfill = service | ||
.handle_request(IncomingRequest { | ||
from: account, | ||
prepare, | ||
}) | ||
.map_err(|err| error!("Error getting ILDCP info: {:?}", err)) | ||
.and_then(|fulfill| { | ||
let response = | ||
IldcpResponse::try_from(fulfill.into_data().freeze()).map_err(|err| { | ||
error!( | ||
"Unable to parse ILDCP response from fulfill packet: {:?}", | ||
err | ||
); | ||
})?; | ||
debug!("Got ILDCP response: {:?}", response); | ||
Ok(response) | ||
}) | ||
.await?; | ||
|
||
let response = IldcpResponse::try_from(fulfill.into_data().freeze()).map_err(|err| { | ||
error!( | ||
"Unable to parse ILDCP response from fulfill packet: {:?}", | ||
err | ||
); | ||
})?; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As I mention elsewhere, I'd love to introduce proper error return types so that we would no longer have to deal with so much wasted space due to |
||
debug!("Got ILDCP response: {:?}", response); | ||
Ok(response) | ||
} |
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.
futures is on 0.3.1 by now, might as well update directly to that.