Prechádzať zdrojové kódy

Save new credentials after trust migration, level up 1 -> 2

Vecna 1 rok pred
rodič
commit
21cae179fd
2 zmenil súbory, kde vykonal 17 pridanie a 5 odobranie
  1. 10 4
      src/bin/lox_client.rs
  2. 7 1
      src/client_lib.rs

+ 10 - 4
src/bin/lox_client.rs

@@ -98,9 +98,9 @@ async fn main() {
         (cred, bl)
     };
 
-    if matches.opt_present("L") {
+    let lox_cred = if matches.opt_present("L") {
         // If trust level is 0, do trust promotion, otherwise level up.
-        if lox_cred.trust_level == Scalar::zero() {
+        let cred = if lox_cred.trust_level == Scalar::zero() {
             let migration_cred =
                 trust_promotion(&server_addr, &lox_cred, get_lox_pub(&lox_auth_pubkeys)).await;
             let cred = trust_migration(
@@ -111,6 +111,7 @@ async fn main() {
                 get_migration_pub(&lox_auth_pubkeys),
             )
             .await;
+            cred
         } else {
             let encbuckets = get_reachability_credential(&server_addr).await;
             let cred = level_up(
@@ -121,6 +122,11 @@ async fn main() {
                 get_reachability_pub(&lox_auth_pubkeys),
             )
             .await;
-        }
-    }
+            cred
+        };
+        save_object(&cred, &lox_cred_filename);
+        cred
+    } else {
+        lox_cred
+    };
 }

+ 7 - 1
src/client_lib.rs

@@ -149,7 +149,13 @@ pub async fn level_up(
         &reachcred,
         lox_pub,
         reachability_pub,
-        today(Duration::ZERO),
+        //today(Duration::ZERO),
+
+        // The following line adds 31 days (from initial trust migration)
+        // plus 85 days for first level up.
+        // The server's testing code keeps track of time added as the
+        // program runs. This should be adapted to do that as well.
+        today(Duration::from_secs(60 * 60 * 24 * (31 + 85))), // FOR TESTING ONLY
     )
     .unwrap();
     let encoded_req: Vec<u8> = serde_json::to_vec(&req).unwrap();