Skip to content

Commit 569c981

Browse files
authored
chore: derive PartialEq and Hash on EnvKzgSettings (#1494)
1 parent bdd1b8e commit 569c981

File tree

1 file changed

+1
-23
lines changed

1 file changed

+1
-23
lines changed

crates/primitives/src/kzg/env_settings.rs

+1-23
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@ use super::{
22
trusted_setup_points::{G1_POINTS, G2_POINTS},
33
KzgSettings,
44
};
5-
use core::hash::{Hash, Hasher};
65
use once_cell::race::OnceBox;
76
use std::{boxed::Box, sync::Arc};
87

98
/// KZG Settings that allow us to specify a custom trusted setup.
109
/// or use hardcoded default settings.
11-
#[derive(Debug, Clone, Default, Eq)]
10+
#[derive(Debug, Clone, Default, PartialEq, Eq, Hash)]
1211
pub enum EnvKzgSettings {
1312
/// Default mainnet trusted setup
1413
#[default]
@@ -17,27 +16,6 @@ pub enum EnvKzgSettings {
1716
Custom(Arc<c_kzg::KzgSettings>),
1817
}
1918

20-
// Implement PartialEq and Hash manually because `c_kzg::KzgSettings` does not implement them
21-
impl PartialEq for EnvKzgSettings {
22-
fn eq(&self, other: &Self) -> bool {
23-
match (self, other) {
24-
(Self::Default, Self::Default) => true,
25-
(Self::Custom(a), Self::Custom(b)) => Arc::ptr_eq(a, b),
26-
_ => false,
27-
}
28-
}
29-
}
30-
31-
impl Hash for EnvKzgSettings {
32-
fn hash<H: Hasher>(&self, state: &mut H) {
33-
core::mem::discriminant(self).hash(state);
34-
match self {
35-
Self::Default => {}
36-
Self::Custom(settings) => Arc::as_ptr(settings).hash(state),
37-
}
38-
}
39-
}
40-
4119
impl EnvKzgSettings {
4220
/// Return set KZG settings.
4321
///

0 commit comments

Comments
 (0)