Skip to content

Commit

Permalink
Skip genesis hash verification for DEV
Browse files Browse the repository at this point in the history
  • Loading branch information
aterentic-ethernal committed Oct 22, 2024
1 parent f4c37c6 commit ddd8c82
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions core/src/network/rpc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,10 @@ struct ConnectionAttempt<T> {
result: T,
}

struct GenesisHash(H256);
enum GenesisHash {
Dev,
Hash(H256),
}

impl GenesisHash {
fn from_hex(hex_str: &str) -> Result<Self> {
Expand All @@ -95,19 +98,22 @@ 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)
.map_err(|_| ClientCreationError::InvalidGenesisHash(hex_str.to_string()))?
.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),
}
}
}

Expand Down

0 comments on commit ddd8c82

Please sign in to comment.