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

Migration to 0.3 & Async/Await #582

Closed
wants to merge 38 commits into from
Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
8f4b917
docs(service): Add missing docs for interledger-service
gakonst Dec 30, 2019
67095a3
feat(service): upgrade to futures 0.3
gakonst Dec 30, 2019
e96d71b
feat(service): add async-trait
gakonst Jan 2, 2020
fbf0ab1
feat(service): remove boxes
gakonst Jan 2, 2020
b35da6b
feat(service): remove boxes
gakonst Jan 2, 2020
5a3f36b
feat(ildcp): move to futures 0.3 and async/await
gakonst Jan 2, 2020
9ef91f7
chore: update cargo.lock
gakonst Jan 2, 2020
2a02842
feat(router): move to futures 0.3 and async/await
gakonst Jan 2, 2020
d335f4e
feat(packet): implement From<Fulfill/Reject> for bytes05::BytesMut
gakonst Jan 3, 2020
680a83e
feat(http): move to futures 0.3 and add async/await
gakonst Jan 3, 2020
26c82b4
feat(http): Get ILP over HTTP working + tests
gakonst Jan 3, 2020
bdb283d
chore(service): Temporarily disable tracing
gakonst Jan 6, 2020
b5a39f4
feat(ccp): update futures and traits
gakonst Jan 6, 2020
22d2aac
feat(ccp): move to futures 0.3 and async/await
gakonst Jan 6, 2020
3ff26ae
feat(ccp): WIP - Re-enable the problematic code
gakonst Jan 7, 2020
44f65a1
feat(settlement): move to futures 0.3 and async/await
gakonst Jan 7, 2020
5c60e39
feat(service-util): move to futures 0.3 and async/await
gakonst Jan 7, 2020
4734309
fix(service): re-enable trace
gakonst Jan 7, 2020
738b606
fix(ccp): fix Mutex errors
gakonst Jan 8, 2020
3f1819c
feat(btp): move to futures 0.3 and async/await
gakonst Jan 8, 2020
3adeacb
feat(stream): move to futures 0.3 and async/await
gakonst Jan 8, 2020
b9488ad
feat(spsp): move to futures 0.3 and async/await
gakonst Jan 8, 2020
fb0722c
feat(api): WIP - move to futures 0.3 and async/await blocked on Warp
gakonst Jan 9, 2020
737c044
feat(store): move to futures 0.3 and async/await
gakonst Jan 9, 2020
d6e9fef
fix(service): refactor wrapped services to accept futures
gakonst Jan 10, 2020
f831435
fix(api/btp/util): Re-enable unimplemented functions
gakonst Jan 10, 2020
10f4cd0
feat(ilp-node): Make the node compile
gakonst Jan 10, 2020
d98f190
feat(api): Update node_settings API
gakonst Jan 10, 2020
eec3843
feat(api): wip on accounts API working
gakonst Jan 10, 2020
3f7f6a8
chore(various): random wips which need cleanup
gakonst Jan 10, 2020
d316689
feat(api): Migrate full API to 0.3 and async/await
gakonst Jan 13, 2020
4e301c5
test(e2e): three-nodes and exchange rates tests pass
gakonst Jan 13, 2020
d7437fe
fix(ccp): clippy lints
gakonst Jan 13, 2020
8674b1f
fix(api/service-util): Fix scoped format compilation error
gakonst Jan 13, 2020
b9a90c8
feat(btp): Implement WebSocket wrapper for Warp <> Tungstenite compat
gakonst Jan 15, 2020
22fb5ba
feat(btp): Implement WebSocket wrapper for Warp <> Tungstenite compat
gakonst Jan 15, 2020
6a70382
feat(btp): Get the rest of BTP working
gakonst Jan 15, 2020
f8a83e7
test(btp/three-nodes): BTP and Three nodes tests are working
gakonst Jan 15, 2020
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
166 changes: 164 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 6 additions & 1 deletion crates/interledger-ildcp/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,13 @@ repository = "https://github.com/interledger-rs/interledger-rs"
[dependencies]
bytes = { version = "0.4.12", default-features = false }
byteorder = { version = "1.3.2", default-features = false }
futures = { version = "0.1.29", default-features = false }
futures = { version = "0.3", default-features = false }
Copy link
Contributor

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.

interledger-packet = { path = "../interledger-packet", version = "^0.4.0", default-features = false }
interledger-service = { path = "../interledger-service", version = "^0.4.0", default-features = false }
lazy_static = { version = "1.4.0", default-features = false }
log = { version = "0.4.8", default-features = false }
async-trait = "0.1.22"

[dev-dependencies]
tokio = { version = "0.2.6", features = ["macros","rt-core"]}
uuid = { version = "0.8.1", features = ["v4"] }
30 changes: 13 additions & 17 deletions crates/interledger-ildcp/src/client.rs
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
);
})?;
Copy link
Contributor

Choose a reason for hiding this comment

The 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 map_errs, like those in this function. Doesn't need to be part of this effort, but async/await makes our code so much cleaner that instances like these really really stand out.

debug!("Got ILDCP response: {:?}", response);
Ok(response)
}
Loading