From a9b09a7552ffa3b6d5df9ba41f34d34f023bdf59 Mon Sep 17 00:00:00 2001 From: Roman Krasiuk Date: Thu, 5 Oct 2023 21:34:02 +0300 Subject: [PATCH] chore: `BlobsBundle::take` (#4925) --- crates/rpc/rpc-types/src/eth/engine/payload.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/crates/rpc/rpc-types/src/eth/engine/payload.rs b/crates/rpc/rpc-types/src/eth/engine/payload.rs index 316f760fbe..98a43d9f69 100644 --- a/crates/rpc/rpc-types/src/eth/engine/payload.rs +++ b/crates/rpc/rpc-types/src/eth/engine/payload.rs @@ -242,6 +242,21 @@ impl From> for BlobsBundleV1 { } } +impl BlobsBundleV1 { + /// Take `len` blob data from the bundle. + /// + /// # Panics + /// + /// If len is more than the blobs bundle len. + pub fn take(&mut self, len: usize) -> (Vec, Vec, Vec) { + ( + self.commitments.drain(0..len).collect(), + self.proofs.drain(0..len).collect(), + self.blobs.drain(0..len).collect(), + ) + } +} + /// An execution payload, which can be either [ExecutionPayloadV1], [ExecutionPayloadV2], or /// [ExecutionPayloadV3]. #[derive(Clone, Debug, PartialEq, Eq)]