Skip to content

Commit

Permalink
fix: use block id for block receipts (paradigmxyz#5105)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattsse committed Oct 20, 2023
1 parent 93e837e commit d3de32a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
6 changes: 2 additions & 4 deletions crates/rpc/rpc-api/src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,8 @@ pub trait EthApi {

/// Returns all transaction receipts for a given block.
#[method(name = "getBlockReceipts")]
async fn block_receipts(
&self,
number: BlockNumberOrTag,
) -> RpcResult<Option<Vec<TransactionReceipt>>>;
async fn block_receipts(&self, block_id: BlockId)
-> RpcResult<Option<Vec<TransactionReceipt>>>;

/// Returns an uncle block of the given block and index.
#[method(name = "getUncleByBlockHashAndIndex")]
Expand Down
8 changes: 4 additions & 4 deletions crates/rpc/rpc/src/eth/api/block.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
EthApi,
};
use reth_network_api::NetworkInfo;
use reth_primitives::{BlockId, BlockNumberOrTag, TransactionMeta};
use reth_primitives::{BlockId, TransactionMeta};

use reth_provider::{BlockReaderIdExt, ChainSpecProvider, EvmEnvProvider, StateProviderFactory};
use reth_rpc_types::{Index, RichBlock, TransactionReceipt};
Expand Down Expand Up @@ -59,13 +59,13 @@ where
/// Returns `None` if the block wasn't found.
pub(crate) async fn block_receipts(
&self,
number: BlockNumberOrTag,
block_id: BlockId,
) -> EthResult<Option<Vec<TransactionReceipt>>> {
let mut block_and_receipts = None;

if number.is_pending() {
if block_id.is_pending() {
block_and_receipts = self.provider().pending_block_and_receipts()?;
} else if let Some(block_hash) = self.provider().block_hash_for_id(number.into())? {
} else if let Some(block_hash) = self.provider().block_hash_for_id(block_id)? {
block_and_receipts = self.cache().get_block_and_receipts(block_hash).await?;
}

Expand Down
9 changes: 3 additions & 6 deletions crates/rpc/rpc/src/eth/api/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,9 @@ where
}

/// Handler for: `eth_getBlockReceipts`
async fn block_receipts(
&self,
number: BlockNumberOrTag,
) -> Result<Option<Vec<TransactionReceipt>>> {
trace!(target: "rpc::eth", ?number, "Serving eth_getBlockReceipts");
Ok(EthApi::block_receipts(self, number).await?)
async fn block_receipts(&self, block_id: BlockId) -> Result<Option<Vec<TransactionReceipt>>> {
trace!(target: "rpc::eth", ?block_id, "Serving eth_getBlockReceipts");
Ok(EthApi::block_receipts(self, block_id).await?)
}

/// Handler for: `eth_getUncleByBlockHashAndIndex`
Expand Down

0 comments on commit d3de32a

Please sign in to comment.