From 7f2b32a6d40d304a5bc3b14313c3ebc4d07dcc78 Mon Sep 17 00:00:00 2001
From: bgallois <benjamin@gallois.cc>
Date: Fri, 1 Mar 2024 16:03:00 +0100
Subject: [PATCH] replace session by pool

---
 client/distance/src/lib.rs  | 10 +++++-----
 distance-oracle/src/api.rs  |  2 +-
 distance-oracle/src/lib.rs  |  6 +++---
 pallets/distance/src/lib.rs |  4 ++--
 4 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/client/distance/src/lib.rs b/client/distance/src/lib.rs
index 7cb3b69e0..cc87d880b 100644
--- a/client/distance/src/lib.rs
+++ b/client/distance/src/lib.rs
@@ -48,7 +48,7 @@ where
     };
     let owner_key = sp_runtime::AccountId32::new(owner_key.0);
 
-    let session_index = client
+    let pool_index = client
         .storage(
             parent,
             &StorageKey(
@@ -66,11 +66,11 @@ where
             &StorageKey(
                 frame_support::storage::storage_prefix(
                     b"Distance",
-                    match session_index {
+                    match pool_index {
                         0 => b"EvaluationPool0",
                         1 => b"EvaluationPool1",
                         2 => b"EvaluationPool2",
-                        _ => unreachable!("n%3<3"),
+                        _ => unreachable!("n<3"),
                     },
                 )
                 .to_vec(),
@@ -90,9 +90,9 @@ where
     // Read evaluation result from file, if it exists
     log::debug!(
         "🧙 [distance oracle] Reading evaluation result from file {:?}",
-        distance_dir.clone().join(session_index.to_string())
+        distance_dir.clone().join(pool_index.to_string())
     );
-    let evaluation_result = match std::fs::read(distance_dir.join(session_index.to_string())) {
+    let evaluation_result = match std::fs::read(distance_dir.join(pool_index.to_string())) {
         Ok(data) => data,
         Err(e) => {
             match e.kind() {
diff --git a/distance-oracle/src/api.rs b/distance-oracle/src/api.rs
index 3aeaa7f8f..db6f48911 100644
--- a/distance-oracle/src/api.rs
+++ b/distance-oracle/src/api.rs
@@ -71,7 +71,7 @@ pub async fn current_pool(
                 debug!("Looking at Pool0 for pool index {}", current_pool_index);
                 runtime::storage().distance().evaluation_pool0()
             }
-            _ => unreachable!("n%3<3"),
+            _ => unreachable!("n<3"),
         })
         .await
         .expect("Cannot fetch current pool")
diff --git a/distance-oracle/src/lib.rs b/distance-oracle/src/lib.rs
index 0fe796fb1..c59d89b7c 100644
--- a/distance-oracle/src/lib.rs
+++ b/distance-oracle/src/lib.rs
@@ -127,8 +127,8 @@ pub async fn run_and_save(client: &api::Client, settings: Settings) {
         .flatten()
     {
         if let Ok(entry_name) = entry.file_name().into_string() {
-            if let Ok(entry_session) = entry_name.parse::<isize>() {
-                if current_pool_index as isize - entry_session > 3 {
+            if let Ok(entry_pool) = entry_name.parse::<isize>() {
+                if current_pool_index as isize - entry_pool > 3 {
                     files_to_remove.push(entry.path());
                 }
             }
@@ -187,7 +187,7 @@ pub async fn run(
         });
     }
 
-    info!("Evaluating distance for session {}", current_pool_index);
+    info!("Evaluating distance for pool {}", current_pool_index);
     let evaluation_block = api::evaluation_block(client, parent_hash).await;
 
     // member idty -> issued certs
diff --git a/pallets/distance/src/lib.rs b/pallets/distance/src/lib.rs
index 03a6c5bb3..6b75618ba 100644
--- a/pallets/distance/src/lib.rs
+++ b/pallets/distance/src/lib.rs
@@ -340,7 +340,7 @@ pub mod pallet {
                 0 => EvaluationPool2::<T>::mutate(f),
                 1 => EvaluationPool0::<T>::mutate(f),
                 2 => EvaluationPool1::<T>::mutate(f),
-                _ => unreachable!("index % 3 < 3"),
+                _ => unreachable!("index < 3"),
             }
         }
 
@@ -361,7 +361,7 @@ pub mod pallet {
                 0 => EvaluationPool0::<T>::mutate(f),
                 1 => EvaluationPool1::<T>::mutate(f),
                 2 => EvaluationPool2::<T>::mutate(f),
-                _ => unreachable!("index % 3 < 3"),
+                _ => unreachable!("index < 3"),
             }
         }
 
-- 
GitLab