Skip to content

Commit

Permalink
chore: address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
gakonst committed Sep 24, 2019
1 parent 7f4eb5f commit e857b9d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 17 deletions.
11 changes: 11 additions & 0 deletions crates/interledger-api/src/routes/accounts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -433,6 +433,7 @@ where
ok(ilp_address)
})
.and_then(move |ilp_address| {
// TODO we may want to make this trigger the CcpRouteManager to request
let prepare = RouteControlRequest {
mode: Mode::Sync,
last_known_epoch: 0,
Expand Down Expand Up @@ -463,6 +464,16 @@ where
.and_then(move |_| Ok(()))
}

// Helper function which gets called whenever a new account is added or
// modified.
// Performed actions:
// 1. If they have a BTP uri configured: connect to their BTP socket
// 2. If they are a parent:
// 2a. Perform an ILDCP Request to get the address assigned to us by them, and
// update our store's address to that value
// 2b. Perform a RouteControl Request to make them send us any new routes
// 3. If they have a settlement engine endpoitn configured: Make a POST to the
// engine's account creation endpoint with the account's id
fn connect_to_external_services<S, A, T, B>(
service: S,
account: A,
Expand Down
2 changes: 2 additions & 0 deletions crates/interledger-btp/src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,8 @@ where
.to_bytes(),
);

// TODO check that the response is a success before proceeding
// (right now we just assume they'll close the connection if the auth didn't work)
connection
.send(auth_packet)
.map_err(move |_| error!("Error sending auth packet on connection: {}", url))
Expand Down
25 changes: 8 additions & 17 deletions crates/interledger-store-redis/src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,23 +86,14 @@ impl Account {
) -> Result<Account, ()> {
let ilp_address = match details.ilp_address {
Some(a) => a,
None => {
// if parent address ends with username, do not suffix
if details.username.to_string()
== parent_ilp_address.segments().rev().next().unwrap()
{
parent_ilp_address
} else {
parent_ilp_address
.with_suffix(details.username.as_bytes())
.map_err(|_| {
error!(
"Could not append username {} to address {}",
details.username, parent_ilp_address
)
})?
}
}
None => parent_ilp_address
.with_suffix(details.username.as_bytes())
.map_err(|_| {
error!(
"Could not append username {} to address {}",
details.username, parent_ilp_address
)
})?,
};

let http_endpoint = if let Some(ref url) = details.http_endpoint {
Expand Down

0 comments on commit e857b9d

Please sign in to comment.