mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 19:09:54 +00:00
chore: simplify rpc block compat (#14225)
This commit is contained in:
@ -6,7 +6,7 @@ use alloy_primitives::U256;
|
||||
use alloy_rpc_types_eth::{
|
||||
Block, BlockTransactions, BlockTransactionsKind, Header, TransactionInfo,
|
||||
};
|
||||
use reth_primitives::{transaction::SignedTransactionIntoRecoveredExt, RecoveredBlock};
|
||||
use reth_primitives::RecoveredBlock;
|
||||
use reth_primitives_traits::{Block as BlockTrait, BlockBody, SealedHeader, SignedTransaction};
|
||||
|
||||
/// Converts the given primitive block into a [`Block`] response with the given
|
||||
@ -64,28 +64,23 @@ where
|
||||
B: BlockTrait,
|
||||
{
|
||||
let block_number = block.header().number();
|
||||
let base_fee_per_gas = block.header().base_fee_per_gas();
|
||||
|
||||
// NOTE: we can safely remove the body here because not needed to finalize the `Block` in
|
||||
// `from_block_with_transactions`, however we need to compute the length before
|
||||
let base_fee = block.header().base_fee_per_gas();
|
||||
let block_length = block.rlp_length();
|
||||
let transactions = block.body().transactions().to_vec();
|
||||
let transactions_with_senders = transactions.into_iter().zip(block.senders_iter().copied());
|
||||
let block_hash = Some(block.hash());
|
||||
let transactions = transactions_with_senders
|
||||
|
||||
let transactions = block
|
||||
.transactions_recovered()
|
||||
.enumerate()
|
||||
.map(|(idx, (tx, sender))| {
|
||||
let tx_hash = *tx.tx_hash();
|
||||
let signed_tx_ec_recovered = tx.with_signer(sender);
|
||||
.map(|(idx, tx)| {
|
||||
let tx_info = TransactionInfo {
|
||||
hash: Some(tx_hash),
|
||||
hash: Some(*tx.tx_hash()),
|
||||
block_hash,
|
||||
block_number: Some(block_number),
|
||||
base_fee: base_fee_per_gas,
|
||||
base_fee,
|
||||
index: Some(idx as u64),
|
||||
};
|
||||
|
||||
tx_resp_builder.fill(signed_tx_ec_recovered, tx_info)
|
||||
tx_resp_builder.fill(tx.cloned(), tx_info)
|
||||
})
|
||||
.collect::<Result<Vec<_>, T::Error>>()?;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user