Skip to content
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
1 change: 1 addition & 0 deletions crates/rpc-types-debug/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ workspace = true

[dependencies]
alloy-primitives = { workspace = true, features = ["serde"] }
alloy-rlp.workspace = true

serde.workspace = true
serde_with = { workspace = true, features = ["alloc", "base64"] }
Expand Down
22 changes: 22 additions & 0 deletions crates/rpc-types-debug/src/execution_witness.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
use alloc::vec::Vec;
use alloy_primitives::Bytes;
use alloy_rlp::Encodable;
use serde::{Deserialize, Serialize};

/// Represents the execution witness of a block. Contains lists of required preimages and
Expand Down Expand Up @@ -62,3 +63,24 @@ pub struct ExecutionWitness {
/// 256 block headers. However note, we may not need all 256, like in the example above.
pub headers: Vec<Bytes>,
}

impl ExecutionWitness {
/// Sets the `headers` field from already RLP-encoded headers.
pub fn with_rlp_headers(mut self, headers: Vec<Bytes>) -> Self {
self.headers = headers;
self
}

/// Sets the `headers` field by RLP-encoding each item.
pub fn with_headers<H: Encodable>(mut self, headers: impl IntoIterator<Item = H>) -> Self {
self.headers = headers
.into_iter()
.map(|header| {
let mut buf = Vec::new();
header.encode(&mut buf);
buf.into()
})
.collect();
self
}
}
Loading