From b6e66b8440956cb85d753887ae08be9837557ce5 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Thu, 11 Jan 2024 16:16:50 +0100 Subject: [PATCH 1/2] Fix invalid deduplication logic --- src/prover/mod.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/prover/mod.rs b/src/prover/mod.rs index b6ee87ac..6ad97962 100644 --- a/src/prover/mod.rs +++ b/src/prover/mod.rs @@ -86,7 +86,7 @@ pub struct ProverConfiguration { pub prover_type: ProverType, } -#[derive(Debug, Copy, Clone, sqlx::Type, PartialEq, Eq, Serialize, Deserialize, Default)] +#[derive(Debug, Copy, Clone, sqlx::Type, PartialEq, Eq, Hash, Serialize, Deserialize, Default)] #[serde(rename_all = "camelCase")] #[sqlx(type_name = "prover_enum", rename_all = "PascalCase")] pub enum ProverType { @@ -97,13 +97,17 @@ pub enum ProverType { impl Hash for ProverConfiguration { fn hash(&self, state: &mut H) { + self.url.hash(state); self.batch_size.hash(state); + self.prover_type.hash(state); } } impl PartialEq for ProverConfiguration { fn eq(&self, other: &Self) -> bool { - self.batch_size == other.batch_size + self.url.eq(&other.url) + && self.batch_size.eq(&other.batch_size) + && self.prover_type.eq(&other.prover_type) } } From d7a7706b5b12d4bd46f72fa2664810c9e52dcf15 Mon Sep 17 00:00:00 2001 From: Dzejkop Date: Thu, 11 Jan 2024 16:34:47 +0100 Subject: [PATCH 2/2] Fix edge case --- src/database/mod.rs | 3 +++ src/prover/mod.rs | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/database/mod.rs b/src/database/mod.rs index c3c2db7e..2e77d30e 100644 --- a/src/database/mod.rs +++ b/src/database/mod.rs @@ -1128,7 +1128,10 @@ mod test { let mock_provers = mock_provers(); db.insert_provers(mock_provers.clone()).await?; + db.remove_prover(100, ProverType::Insertion).await?; + db.remove_prover(100, ProverType::Deletion).await?; + let provers = db.get_provers().await?; assert_eq!(provers, HashSet::new()); diff --git a/src/prover/mod.rs b/src/prover/mod.rs index 6ad97962..d178fe0d 100644 --- a/src/prover/mod.rs +++ b/src/prover/mod.rs @@ -97,7 +97,6 @@ pub enum ProverType { impl Hash for ProverConfiguration { fn hash(&self, state: &mut H) { - self.url.hash(state); self.batch_size.hash(state); self.prover_type.hash(state); } @@ -105,9 +104,7 @@ impl Hash for ProverConfiguration { impl PartialEq for ProverConfiguration { fn eq(&self, other: &Self) -> bool { - self.url.eq(&other.url) - && self.batch_size.eq(&other.batch_size) - && self.prover_type.eq(&other.prover_type) + self.batch_size.eq(&other.batch_size) && self.prover_type.eq(&other.prover_type) } }