Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add is_ethereum trait fn #12197

Merged
merged 1 commit into from
Oct 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions crates/chainspec/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ pub trait EthChainSpec: Send + Sync + Unpin + Debug {
fn is_optimism(&self) -> bool {
self.chain().is_optimism()
}

/// Returns `true` if this chain contains Ethereum configuration.
fn is_ethereum(&self) -> bool {
self.chain().is_ethereum()
}
}

impl EthChainSpec for ChainSpec {
Expand Down
5 changes: 2 additions & 3 deletions crates/net/discv5/src/network_stack_id.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@ impl NetworkStackId {
/// ENR fork ID kv-pair key, for an Optimism CL node.
pub const OPSTACK: &'static [u8] = b"opstack";

#[allow(clippy::missing_const_for_fn)]
/// Returns the [`NetworkStackId`] that matches the given chain spec.
pub fn id(chain: impl EthChainSpec) -> Option<&'static [u8]> {
if chain.chain().is_optimism() {
if chain.is_optimism() {
return Some(Self::OPEL)
} else if chain.chain().is_ethereum() {
} else if chain.is_ethereum() {
return Some(Self::ETH)
}

Expand Down
Loading