mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
refactor: remove Receipts struct (#14130)
This commit is contained in:
@ -20,15 +20,12 @@ reth-static-file-types.workspace = true
|
||||
|
||||
# ethereum
|
||||
alloy-consensus.workspace = true
|
||||
alloy-primitives = { workspace = true, features = ["rand", "rlp"] }
|
||||
|
||||
# for eip-4844
|
||||
c-kzg = { workspace = true, features = ["serde"], optional = true }
|
||||
|
||||
# misc
|
||||
derive_more.workspace = true
|
||||
once_cell.workspace = true
|
||||
serde.workspace = true
|
||||
|
||||
# arbitrary utils
|
||||
arbitrary = { workspace = true, features = ["derive"], optional = true }
|
||||
@ -37,6 +34,7 @@ arbitrary = { workspace = true, features = ["derive"], optional = true }
|
||||
# eth
|
||||
reth-primitives-traits = { workspace = true, features = ["arbitrary", "test-utils"] }
|
||||
|
||||
alloy-primitives.workspace = true
|
||||
alloy-rlp.workspace = true
|
||||
alloy-eips = { workspace = true, features = ["arbitrary"] }
|
||||
alloy-genesis.workspace = true
|
||||
@ -58,21 +56,21 @@ std = [
|
||||
"alloy-consensus/std",
|
||||
"alloy-eips/std",
|
||||
"alloy-genesis/std",
|
||||
"alloy-primitives/std",
|
||||
"once_cell/std",
|
||||
"serde/std",
|
||||
"reth-ethereum-forks/std",
|
||||
"derive_more/std",
|
||||
"serde_json/std",
|
||||
"reth-ethereum-primitives/std",
|
||||
"alloy-rlp/std",
|
||||
"alloy-primitives/std",
|
||||
]
|
||||
reth-codec = [
|
||||
"std",
|
||||
"reth-primitives-traits/reth-codec",
|
||||
"reth-ethereum-primitives/reth-codec",
|
||||
]
|
||||
asm-keccak = ["alloy-primitives/asm-keccak"]
|
||||
asm-keccak = [
|
||||
"alloy-primitives/asm-keccak",
|
||||
]
|
||||
arbitrary = [
|
||||
"dep:arbitrary",
|
||||
"alloy-eips/arbitrary",
|
||||
@ -80,9 +78,9 @@ arbitrary = [
|
||||
"reth-ethereum-forks/arbitrary",
|
||||
"reth-primitives-traits/arbitrary",
|
||||
"alloy-consensus/arbitrary",
|
||||
"alloy-primitives/arbitrary",
|
||||
"reth-ethereum-primitives/arbitrary",
|
||||
"reth-codecs/arbitrary",
|
||||
"alloy-primitives/arbitrary",
|
||||
]
|
||||
secp256k1 = [
|
||||
"reth-primitives-traits/secp256k1",
|
||||
|
||||
@ -19,8 +19,6 @@
|
||||
#![cfg_attr(docsrs, feature(doc_cfg, doc_auto_cfg))]
|
||||
#![cfg_attr(not(feature = "std"), no_std)]
|
||||
|
||||
extern crate alloc;
|
||||
|
||||
mod block;
|
||||
mod receipt;
|
||||
pub use reth_static_file_types as static_file;
|
||||
@ -31,7 +29,7 @@ pub use block::{Block, BlockBody, SealedBlock};
|
||||
#[allow(deprecated)]
|
||||
pub use block::{BlockWithSenders, SealedBlockFor, SealedBlockWithSenders};
|
||||
|
||||
pub use receipt::{gas_spent_by_transactions, Receipt, Receipts};
|
||||
pub use receipt::{gas_spent_by_transactions, Receipt};
|
||||
pub use reth_primitives_traits::{
|
||||
logs_bloom, Account, Bytecode, GotExpected, GotExpectedBoxed, Header, HeaderError, Log,
|
||||
LogData, NodePrimitives, RecoveredBlock, SealedHeader, StorageEntry,
|
||||
|
||||
@ -1,69 +1,5 @@
|
||||
use alloc::{vec, vec::Vec};
|
||||
use alloy_primitives::B256;
|
||||
use derive_more::{DerefMut, From, IntoIterator};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Retrieves gas spent by transactions as a vector of tuples (transaction index, gas used).
|
||||
pub use reth_primitives_traits::receipt::gas_spent_by_transactions;
|
||||
|
||||
/// Receipt containing result of transaction execution.
|
||||
pub use reth_ethereum_primitives::Receipt;
|
||||
|
||||
/// A collection of receipts organized as a two-dimensional vector.
|
||||
#[derive(
|
||||
Clone,
|
||||
Debug,
|
||||
PartialEq,
|
||||
Eq,
|
||||
Serialize,
|
||||
Deserialize,
|
||||
From,
|
||||
derive_more::Deref,
|
||||
DerefMut,
|
||||
IntoIterator,
|
||||
)]
|
||||
pub struct Receipts<T = Receipt> {
|
||||
/// A two-dimensional vector of optional `Receipt` instances.
|
||||
pub receipt_vec: Vec<Vec<T>>,
|
||||
}
|
||||
|
||||
impl<T> Receipts<T> {
|
||||
/// Returns the length of the `Receipts` vector.
|
||||
pub fn len(&self) -> usize {
|
||||
self.receipt_vec.len()
|
||||
}
|
||||
|
||||
/// Returns true if the `Receipts` vector is empty.
|
||||
pub fn is_empty(&self) -> bool {
|
||||
self.receipt_vec.is_empty()
|
||||
}
|
||||
|
||||
/// Push a new vector of receipts into the `Receipts` collection.
|
||||
pub fn push(&mut self, receipts: Vec<T>) {
|
||||
self.receipt_vec.push(receipts);
|
||||
}
|
||||
|
||||
/// Retrieves all recorded receipts from index and calculates the root using the given closure.
|
||||
pub fn root_slow(&self, index: usize, f: impl FnOnce(&[&T]) -> B256) -> B256 {
|
||||
let receipts = self.receipt_vec[index].iter().collect::<Vec<_>>();
|
||||
f(receipts.as_slice())
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> From<Vec<T>> for Receipts<T> {
|
||||
fn from(block_receipts: Vec<T>) -> Self {
|
||||
Self { receipt_vec: vec![block_receipts.into_iter().collect()] }
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> FromIterator<Vec<T>> for Receipts<T> {
|
||||
fn from_iter<I: IntoIterator<Item = Vec<T>>>(iter: I) -> Self {
|
||||
iter.into_iter().collect::<Vec<_>>().into()
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Default for Receipts<T> {
|
||||
fn default() -> Self {
|
||||
Self { receipt_vec: Vec::new() }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user