Skip to content

Commit

Permalink
feat: Add bytes to Bytecode (#1396)
Browse files Browse the repository at this point in the history
* fix(eip2935): Preload blockchash storage address

* chore: add bytes fn
  • Loading branch information
rakita authored May 12, 2024
1 parent aeefcda commit d4b0ebc
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/primitives/src/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,26 @@ impl Bytecode {
!matches!(self, Self::LegacyRaw(_))
}

/// Returns bytes
#[inline]
pub fn bytes(&self) -> Bytes {
match self {
Self::LegacyRaw(bytes) => bytes.clone(),
Self::LegacyAnalyzed(analyzed) => analyzed.bytecode().clone(),
Self::Eof(eof) => eof.raw().clone(),
}
}

/// Returns bytes slice
#[inline]
pub fn bytes_slice(&self) -> &[u8] {
match self {
Self::LegacyRaw(bytes) => bytes,
Self::LegacyAnalyzed(analyzed) => analyzed.bytecode(),
Self::Eof(eof) => eof.raw(),
}
}

/// Returns a reference to the original bytecode.
#[inline]
pub fn original_bytes(&self) -> Bytes {
Expand Down

0 comments on commit d4b0ebc

Please sign in to comment.