From 28be32a910beade2e10a4f6adb864e2f0ad8667d Mon Sep 17 00:00:00 2001 From: pedro bufulin Date: Wed, 6 Nov 2024 14:42:48 -0300 Subject: [PATCH 1/3] feat: make fn full_receipts public --- crates/firehose-protos/src/ethereum_v2/eth_block.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/crates/firehose-protos/src/ethereum_v2/eth_block.rs b/crates/firehose-protos/src/ethereum_v2/eth_block.rs index be080e5b..980b0152 100644 --- a/crates/firehose-protos/src/ethereum_v2/eth_block.rs +++ b/crates/firehose-protos/src/ethereum_v2/eth_block.rs @@ -159,7 +159,7 @@ impl Block { Ok(calculate_transaction_root(&transactions)) } - fn full_receipts(&self) -> Result, ProtosError> { + pub fn full_receipts(&self) -> Result, ProtosError> { self.transaction_traces .iter() .map(FullReceipt::try_from) @@ -261,8 +261,8 @@ impl Block { } } -struct FullReceipt { - receipt: ReceiptWithBloom, +pub struct FullReceipt { + pub receipt: ReceiptWithBloom, state_root: Vec, } From e899275eb8bca785cebb9f137c79529a1d69d4f6 Mon Sep 17 00:00:00 2001 From: pedro bufulin Date: Wed, 6 Nov 2024 14:45:33 -0300 Subject: [PATCH 2/3] docs: add rustdoc for public function --- crates/firehose-protos/src/ethereum_v2/eth_block.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/firehose-protos/src/ethereum_v2/eth_block.rs b/crates/firehose-protos/src/ethereum_v2/eth_block.rs index 980b0152..8513fa0a 100644 --- a/crates/firehose-protos/src/ethereum_v2/eth_block.rs +++ b/crates/firehose-protos/src/ethereum_v2/eth_block.rs @@ -159,6 +159,12 @@ impl Block { Ok(calculate_transaction_root(&transactions)) } + /// Converts the transaction traces of the current block into a vector of `FullReceipt` objects. + /// + /// # Arguments + /// + /// * `block` reference to the block containing the `Vec` + /// pub fn full_receipts(&self) -> Result, ProtosError> { self.transaction_traces .iter() From 91f3bbfd436802021bdf1168ba241d72ae47f84d Mon Sep 17 00:00:00 2001 From: pedro bufulin Date: Wed, 6 Nov 2024 15:02:39 -0300 Subject: [PATCH 3/3] refactor: add getter remove public exposure for ReceiptWithBloom --- crates/firehose-protos/src/ethereum_v2/eth_block.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/crates/firehose-protos/src/ethereum_v2/eth_block.rs b/crates/firehose-protos/src/ethereum_v2/eth_block.rs index 8513fa0a..17a81081 100644 --- a/crates/firehose-protos/src/ethereum_v2/eth_block.rs +++ b/crates/firehose-protos/src/ethereum_v2/eth_block.rs @@ -268,7 +268,7 @@ impl Block { } pub struct FullReceipt { - pub receipt: ReceiptWithBloom, + receipt: ReceiptWithBloom, state_root: Vec, } @@ -338,6 +338,11 @@ impl FullReceipt { self.receipt.encode_inner(encoded, false); } + /// Returns a reference to the [`ReceiptWithBloom`] for this [`FullReceipt`] + pub fn get_receipt_wb(&self) -> &ReceiptWithBloom { + &self.receipt + } + /// Encodes receipt header using [RLP serialization](https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp) fn rlp_header(&self) -> RlpHeader { let payload_length = self.state_root.as_slice().length()