mirror of
https://github.com/paradigmxyz/reth.git
synced 2026-01-28 00:28:20 -05:00
chore: use usize in internal functions (#9337)
This commit is contained in:
@@ -463,7 +463,8 @@ where
|
||||
index: Index,
|
||||
) -> RpcResult<Option<Bytes>> {
|
||||
trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getRawTransactionByBlockHashAndIndex");
|
||||
Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, hash.into(), index).await?)
|
||||
Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, hash.into(), index.into())
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// Handler for: `eth_getTransactionByBlockHashAndIndex`
|
||||
@@ -473,7 +474,8 @@ where
|
||||
index: Index,
|
||||
) -> RpcResult<Option<reth_rpc_types::Transaction>> {
|
||||
trace!(target: "rpc::eth", ?hash, ?index, "Serving eth_getTransactionByBlockHashAndIndex");
|
||||
Ok(EthTransactions::transaction_by_block_and_tx_index(self, hash.into(), index).await?)
|
||||
Ok(EthTransactions::transaction_by_block_and_tx_index(self, hash.into(), index.into())
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// Handler for: `eth_getRawTransactionByBlockNumberAndIndex`
|
||||
@@ -483,8 +485,12 @@ where
|
||||
index: Index,
|
||||
) -> RpcResult<Option<Bytes>> {
|
||||
trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getRawTransactionByBlockNumberAndIndex");
|
||||
Ok(EthTransactions::raw_transaction_by_block_and_tx_index(self, number.into(), index)
|
||||
.await?)
|
||||
Ok(EthTransactions::raw_transaction_by_block_and_tx_index(
|
||||
self,
|
||||
number.into(),
|
||||
index.into(),
|
||||
)
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// Handler for: `eth_getTransactionByBlockNumberAndIndex`
|
||||
@@ -494,7 +500,8 @@ where
|
||||
index: Index,
|
||||
) -> RpcResult<Option<reth_rpc_types::Transaction>> {
|
||||
trace!(target: "rpc::eth", ?number, ?index, "Serving eth_getTransactionByBlockNumberAndIndex");
|
||||
Ok(EthTransactions::transaction_by_block_and_tx_index(self, number.into(), index).await?)
|
||||
Ok(EthTransactions::transaction_by_block_and_tx_index(self, number.into(), index.into())
|
||||
.await?)
|
||||
}
|
||||
|
||||
/// Handler for: `eth_getTransactionReceipt`
|
||||
|
||||
@@ -19,7 +19,7 @@ use reth_rpc_types::{
|
||||
EIP1559TransactionRequest, EIP2930TransactionRequest, EIP4844TransactionRequest,
|
||||
LegacyTransactionRequest,
|
||||
},
|
||||
AnyTransactionReceipt, Index, Transaction, TransactionRequest, TypedTransactionRequest,
|
||||
AnyTransactionReceipt, Transaction, TransactionRequest, TypedTransactionRequest,
|
||||
};
|
||||
use reth_rpc_types_compat::transaction::from_recovered_with_block_context;
|
||||
use reth_transaction_pool::{TransactionOrigin, TransactionPool};
|
||||
@@ -184,7 +184,7 @@ pub trait EthTransactions: LoadTransaction {
|
||||
fn transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: BlockId,
|
||||
index: Index,
|
||||
index: usize,
|
||||
) -> impl Future<Output = EthResult<Option<Transaction>>> + Send
|
||||
where
|
||||
Self: LoadBlock,
|
||||
@@ -194,13 +194,13 @@ pub trait EthTransactions: LoadTransaction {
|
||||
let block_hash = block.hash();
|
||||
let block_number = block.number;
|
||||
let base_fee_per_gas = block.base_fee_per_gas;
|
||||
if let Some(tx) = block.into_transactions_ecrecovered().nth(index.into()) {
|
||||
if let Some(tx) = block.into_transactions_ecrecovered().nth(index) {
|
||||
return Ok(Some(from_recovered_with_block_context(
|
||||
tx,
|
||||
block_hash,
|
||||
block_number,
|
||||
base_fee_per_gas,
|
||||
index.into(),
|
||||
index,
|
||||
)))
|
||||
}
|
||||
}
|
||||
@@ -215,14 +215,14 @@ pub trait EthTransactions: LoadTransaction {
|
||||
fn raw_transaction_by_block_and_tx_index(
|
||||
&self,
|
||||
block_id: BlockId,
|
||||
index: Index,
|
||||
index: usize,
|
||||
) -> impl Future<Output = EthResult<Option<Bytes>>> + Send
|
||||
where
|
||||
Self: LoadBlock,
|
||||
{
|
||||
async move {
|
||||
if let Some(block) = self.block_with_senders(block_id).await? {
|
||||
if let Some(tx) = block.transactions().nth(index.into()) {
|
||||
if let Some(tx) = block.transactions().nth(index) {
|
||||
return Ok(Some(tx.envelope_encoded()))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user