From e857b9d1a2785e8e2a6abde4ba4b51fb0ffb3590 Mon Sep 17 00:00:00 2001 From: Georgios Konstantopoulos Date: Tue, 24 Sep 2019 23:06:45 +0900 Subject: [PATCH] chore: address review comments --- crates/interledger-api/src/routes/accounts.rs | 11 ++++++++ crates/interledger-btp/src/client.rs | 2 ++ crates/interledger-store-redis/src/account.rs | 25 ++++++------------- 3 files changed, 21 insertions(+), 17 deletions(-) diff --git a/crates/interledger-api/src/routes/accounts.rs b/crates/interledger-api/src/routes/accounts.rs index 1b4378378..b77de0143 100644 --- a/crates/interledger-api/src/routes/accounts.rs +++ b/crates/interledger-api/src/routes/accounts.rs @@ -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, @@ -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( service: S, account: A, diff --git a/crates/interledger-btp/src/client.rs b/crates/interledger-btp/src/client.rs index a36c03d86..db779f1bc 100644 --- a/crates/interledger-btp/src/client.rs +++ b/crates/interledger-btp/src/client.rs @@ -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)) diff --git a/crates/interledger-store-redis/src/account.rs b/crates/interledger-store-redis/src/account.rs index 7f1ec4373..2a99bb256 100644 --- a/crates/interledger-store-redis/src/account.rs +++ b/crates/interledger-store-redis/src/account.rs @@ -86,23 +86,14 @@ impl Account { ) -> Result { 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 {