From be5ad01680aa5342c88dfe900de3cebfbf56bc4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aleksandar=20Terenti=C4=87?= Date: Tue, 22 Oct 2024 08:41:03 +0200 Subject: [PATCH] Skip genesis hash verification for DEV --- core/src/network/rpc/client.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/src/network/rpc/client.rs b/core/src/network/rpc/client.rs index 342203656..697a2deb3 100644 --- a/core/src/network/rpc/client.rs +++ b/core/src/network/rpc/client.rs @@ -85,7 +85,10 @@ struct ConnectionAttempt { result: T, } -struct GenesisHash(H256); +enum GenesisHash { + Dev, + Hash(H256), +} impl GenesisHash { fn from_hex(hex_str: &str) -> Result { @@ -95,7 +98,7 @@ impl GenesisHash { hex_str ); // Return a dummy hash for development - return Ok(Self(H256::zero())); + return Ok(Self::Dev); } let bytes: [u8; 32] = from_hex(hex_str) @@ -103,11 +106,14 @@ impl GenesisHash { .try_into() .map_err(|_| ClientCreationError::InvalidGenesisHash(hex_str.to_string()))?; - Ok(Self(H256::from(bytes))) + Ok(Self::Hash(H256::from(bytes))) } fn matches(&self, other: &H256) -> bool { - self.0.eq(other) + match self { + GenesisHash::Dev => true, + GenesisHash::Hash(hash) => hash.eq(other), + } } }