small refactoring in payload crate (#6358)

This commit is contained in:
Thomas Coratger
2024-02-02 21:15:53 +01:00
committed by GitHub
parent 98e5dfe1ac
commit 3dcb04d558
4 changed files with 21 additions and 34 deletions

View File

@ -7,7 +7,6 @@ use reth_primitives::{
},
U256,
};
use std::{
cell::RefCell,
collections::{hash_map::Entry, HashMap},
@ -91,17 +90,10 @@ impl<'a, DB: DatabaseRef> Database for CachedReadsDbMut<'a, DB> {
fn storage(&mut self, address: Address, index: U256) -> Result<U256, Self::Error> {
match self.cached.accounts.entry(address) {
Entry::Occupied(mut acc_entry) => {
let acc_entry = acc_entry.get_mut();
match acc_entry.storage.entry(index) {
Entry::Occupied(mut acc_entry) => match acc_entry.get_mut().storage.entry(index) {
Entry::Occupied(entry) => Ok(*entry.get()),
Entry::Vacant(entry) => {
let slot = self.db.storage_ref(address, index)?;
entry.insert(slot);
Ok(slot)
}
}
}
Entry::Vacant(entry) => Ok(*entry.insert(self.db.storage_ref(address, index)?)),
},
Entry::Vacant(acc_entry) => {
// acc needs to be loaded for us to access slots.
let info = self.db.basic_ref(address)?;

View File

@ -25,8 +25,10 @@ where
/// Creates a new [NoopPayloadBuilderService].
pub fn new() -> (Self, PayloadBuilderHandle<Engine>) {
let (service_tx, command_rx) = mpsc::unbounded_channel();
let handle = PayloadBuilderHandle::new(service_tx);
(Self { command_rx: UnboundedReceiverStream::new(command_rx) }, handle)
(
Self { command_rx: UnboundedReceiverStream::new(command_rx) },
PayloadBuilderHandle::new(service_tx),
)
}
}

View File

@ -37,16 +37,11 @@ impl PayloadBuilderAttributes for OptimismPayloadBuilderAttributes {
(payload_id_optimism(&parent, &attributes, &transactions), transactions)
};
let withdraw = attributes.payload_attributes.withdrawals.map(
|withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal>| {
let withdraw = attributes.payload_attributes.withdrawals.map(|withdrawals| {
Withdrawals::new(
withdrawals
.into_iter()
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
.collect(),
withdrawals.into_iter().map(convert_standalone_withdraw_to_withdrawal).collect(),
)
},
);
});
let payload_attributes = EthPayloadBuilderAttributes {
id,

View File

@ -172,16 +172,14 @@ impl EthPayloadBuilderAttributes {
pub fn new(parent: B256, attributes: PayloadAttributes) -> Self {
let id = payload_id(&parent, &attributes);
let withdraw = attributes.withdrawals.map(
|withdrawals: Vec<reth_rpc_types::withdrawal::Withdrawal>| {
let withdraw = attributes.withdrawals.map(|withdrawals| {
Withdrawals::new(
withdrawals
.into_iter()
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
.collect(),
)
},
);
});
Self {
id,