mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 10:59:55 +00:00
small refactoring in payload crate (#6358)
This commit is contained in:
@ -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(entry) => Ok(*entry.get()),
|
||||
Entry::Vacant(entry) => {
|
||||
let slot = self.db.storage_ref(address, index)?;
|
||||
entry.insert(slot);
|
||||
Ok(slot)
|
||||
}
|
||||
}
|
||||
}
|
||||
Entry::Occupied(mut acc_entry) => match acc_entry.get_mut().storage.entry(index) {
|
||||
Entry::Occupied(entry) => Ok(*entry.get()),
|
||||
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)?;
|
||||
|
||||
@ -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),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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>| {
|
||||
Withdrawals::new(
|
||||
withdrawals
|
||||
.into_iter()
|
||||
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
|
||||
.collect(),
|
||||
)
|
||||
},
|
||||
);
|
||||
let withdraw = attributes.payload_attributes.withdrawals.map(|withdrawals| {
|
||||
Withdrawals::new(
|
||||
withdrawals.into_iter().map(convert_standalone_withdraw_to_withdrawal).collect(),
|
||||
)
|
||||
});
|
||||
|
||||
let payload_attributes = EthPayloadBuilderAttributes {
|
||||
id,
|
||||
|
||||
@ -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>| {
|
||||
Withdrawals::new(
|
||||
withdrawals
|
||||
.into_iter()
|
||||
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
|
||||
.collect(),
|
||||
)
|
||||
},
|
||||
);
|
||||
let withdraw = attributes.withdrawals.map(|withdrawals| {
|
||||
Withdrawals::new(
|
||||
withdrawals
|
||||
.into_iter()
|
||||
.map(convert_standalone_withdraw_to_withdrawal) // Removed the parentheses here
|
||||
.collect(),
|
||||
)
|
||||
});
|
||||
|
||||
Self {
|
||||
id,
|
||||
|
||||
Reference in New Issue
Block a user